To use this file copy and paste this:
// #URL-lib "http://pin1.org/forthlib/flb/Interupts/b-shed.flb" into BV Terminal 3
or here to download.
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// Burst scheduler using timer 0
// Words are placed into the schedule by using s-add. It fills an area
// in memory with the words added. The other words are:
// ps. - to see the words in the list
// s-del - removes a word from the list
// s-pause - pause a word from the schedule
// s-resume - opposite
// s-start - starts timer0 and the scheduler
// s-clr - clears schedule table, muts be run for initialisation
// s-interval - returns variable address to set T0 interval in ms
//
// NOTE this method of scheduling services all of the words in the
// schedula lits at each T0 interrupt that is set by interval
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// REQUIRES:
// #URL-lib "http://pin1.org/forthlib/flb/General/soft1.flb" sid=99
// #URL-lib "http://pin1.org/forthlib/flb/General/pinsel.flb" sid=100
// #URL-lib "http://pin1.org/forthlib/flb/Interupts/interrupt.flb"
// CONSTANTS:
&e0004000 constant T0IR
&e0004004 constant T0TCR
&e0004008 constant T0TC
&e000400c constant T0PR
&e0004014 constant T0MCR
&e0004018 constant T0MR0
//
variable interval // in ms
80 constant s-size // in bytes, each cfa is 4 bytes
s-size vspace$ s-table // schedule table
Full Contents of File
&e0004000  constant  T0IR
&e0004004  constant  T0TCR
&e0004008  constant  T0TC
&e000400c  constant  T0PR
&e0004014  constant  T0MCR
&e0004018  constant  T0MR0
variable  interval       
80  constant  s-size   
s-size  vspace$  s-table   
: =s  &fffffffe  and  =  ;
 
: <0>s-clr  s-table  s-size  0  fill  ;   
: (ps)
    dup  1  and     
    if
        ."    "
    then   
    &fffffffe  and  8  -  stype  cr
;   
       
: <0>ps.
    s-size  s-table  +  s-table
    do
        i  @
        dup  0=
        if
            drop  leave
        else
               
        then
    4  +loop   
;                   
: <0>s-add
    0  swap 
    s-size  s-table  +  s-table
    do
        i  @  0=   
        if
            i  !  1-  leave   
        then       
    4  +loop
    -1  =  if  -1  else  drop  0  then  ;       
; 
: (s-del)
      s-size  s-table  +  swap   
      do
          i  4  +  @  i  !
      4  +loop
;
     
: <0>s-del
    0  swap 
    s-size  s-table  +  s-table
    do
        dup  i  @  =s   
        if
            i 
            -1       
            leave
        then
    4  +loop
    -1  =  if  2drop  -1  then  ;       
;
: (s-sus)
    s-size  s-table  +  s-table
    do
        dup  i  @  =s   
        if
            drop       
            i  @         
            swap  1  =  if  1+  else  &fffffffe  and  then
            i  !         
        then
    4  +loop
;
: <0>s-pause  1  swap    ;
: <0>s-resume  0  swap    ;
: setShed
        TIMER0  intSel     
        TIMER0  intEn       
        efiq       
;
: T0int
        1  t0IR  !       
        s-size  s-table  +  s-table
        do                   
            i  @  0  =
            if
                leave     
            else
                i  @  dup  1  and  0=  if  execute  else  drop  then   
            then
        4  +loop       
        TIMER0  intEn 
;
: <0>s-start
        interval  @  0=  if  10  interval  !  then
        pclk  1000 
        2  T0TCR  !             
        1  T0TCR  !             
        interval  @  t0MR0  !       
        3  t0MCR  !             
       
        [']  T0int   
        TIMER0       
        int>>         
        setShed                     
; 
: <0>s-intervalinterval  ;