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

Re: task waking through an interrupt (AVR)

From: Charles Ehrenpreis <charlese_at_adelphia.net>
Date: Sat, 18 Sep 2004 15:38:29 -0400

Frank,

This isn't an answer to the question as you've asked it, but I thought I'd
mention that on a project using SwiftX on the 69R000, instead of having a
task like MSTIMER, we used a single ISR driven by a hardware clock (ours
fires every 100 microseconds)which 'briefly' interrupts the multitasker
loop. We do low level things in this ISR and setup variables for various
tasks in the multitasker loop to 'act on' when they run.

Live long and prosper,
 
Charles

-----Original Message-----
From: swiftx-bounce_at_forth.com [mailto:swiftx-bounce_at_forth.com] On Behalf Of
Frank Boon
Sent: Saturday, September 18, 2004 12:51 PM
To: swiftx_at_forth.com
Subject: [swiftx] task waking through an interrupt (AVR)

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?

Thanks in advance,
Frank Boon
Metatronics

VARIABLE MSEC

|U| |S| |R| BACKGROUND MSTIMER

: MS_TASK ( task-addr -- )
  ACTIVATE
  BEGIN
    STOP
    MSEC @ 1 + MSEC !
  AGAIN
;

: MS_WAKE ( -- )
  WAKE MSTIMER @ C!
;

LABEL <MSTIMER> \ WAKE UP TIMER
       R0 PUSH
       SREG R0 IN R0 PUSH
       ZH PUSH ZL PUSH SH PUSH SL PUSH TH PUSH TL PUSH
       R17 PUSH R16 PUSH
      
       ' MS_WAKE RCALL

       R16 POP R17 POP
       TL POP TH POP SL POP SH POP ZL POP ZH POP
       R0 POP R0 SREG OUT
       R0 POP
       RETI
END-CODE

<MSTIMER> OC0addr INTERRUPT

: SETUP_MSTIMER
  MSTIMER BUILD MSTIMER MS_TASK
  \ setup timer of 1 ms
  $0C TCCR0 C!
  $FA OCR0 C!
  $00 ASSR C!
  TIMSK C@ $02 OR TIMSK C! \ ENABLE INTERRUPT
;
----------------------------------------------------------------------
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
----------------------------------------------------------------------

----------------------------------------------------------------------
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 - 12:38:16 PDT

This archive was generated by hypermail 2.2.0 : Tue Dec 02 2008 - 03:04:49 PST