embedded systems developers tools, cross compilers
  Home  |   SwiftX Archive  |   SwiftForth Archive  |

Re: task waking through an interrupt (AVR)

From: Charles Steinkuehler <charles_at_steinkuehler.net>
Date: Sat, 18 Sep 2004 13:47:46 -0500

Frank Boon wrote:
> Hello,
>
> I'm using a ATmega64 with SwiftX (AVR).
>
> The goal is to wake MSTIMER task every 1 ms. The task is still small
> for debugging purposes, will eventually become a timing wheel.
>
> But I can't get to wake the task through high-level forth, because it
> corrupts the system (why?)
> And my attempts of waking the task through assembler wouldn't work either.
>
> Does anybody have such an 'interrupt task wake-up' source code?

Yes...the following code wakes the LED-ALARM task on the output comapre
interrupt for timer2 (real-time clock). To wake a task just store the
"wake" value in it's task status (base address of the task):

LABEL <DELAY> \ Timer2 compare interrupt handler
    R0 PUSH SREG R0 IN R16 PUSH
    TIMSK R16 IN \ Disable Output Compare interrupt
                                     \ (protected)
    &OCIE2 R16 CBR
    R16 TIMSK OUT
    WAKE R16 LDI \ Set LED-ALARM task to wake on next
    R16 LED-ALARM @ STS \ pass of round-robin scheduler
    R16 POP R0 SREG OUT R0 POP
    RETI END-CODE

<DELAY> OC2addr INTERRUPT \ Timer2 compare interrupt vector

-- 
Charles Steinkuehler
charles_at_steinkuehler.net
----------------------------------------------------------------------
swiftx_at_forth.com          The SwiftX programming discussion email list
To unsubscribe, send subject "unsubscribe" to swiftx-request_at_forth.com
For list command help, send subject "help" to swiftx-request_at_forth.com
Message archives are located at http://www.forth.com/archive/swiftx
----------------------------------------------------------------------
This list is a forum for SwiftX users.  For product support and bug 
reports, please send email to support_at_forth.com
----------------------------------------------------------------------
Received on Sat Sep 18 2004 - 11:47:23 PDT

This archive was generated by hypermail 2.2.0 : Thu Nov 20 2008 - 03:04:47 PST