\ ********************************************************************* \ Interrupts example for FlashForth * \ Filename: irq.fth * \ Date: 15.1.2008 * \ FF Version: 3.2 * \ Copyright: Mikael Nordman * \ Author: Mikael Nordman * \ ********************************************************************* \ FlashForth is licensed acording to the GNU General Public License* \ ********************************************************************* \ NOTE: Always deactivate user interrupts before \ the interrupt word is removed. \ You must also clear any related interrupt enable bits \ and interrupt flags before zeroing the interrupt vector false di to irq ei -uirq marker -uirq ram hex $28 as3 incf, ( f d a -- ) $48 as3 infsnz, ( f d a -- ) : lfsr, ( k f -- ) 4 lshift over 8 rshift $f and or $ee00 or i, $ff and $f000 or i, ; 1 constant f, \ Destination File 0 constant a, \ Force Access Bank 1 con Treg $ffe6 con Tplus \ Treg (FSR1) is interrupt safe ram variable icnt \ Interrupt routine written in assembly : irq_asm [ icnt Treg lfsr, ] [ Tplus f, a, infsnz, ] [ Tplus f, a, incf, ] ;i ' irq_asm is irq \ \ Interrupt routine written in Forth \ ram variable icnt1 : irq_forth icnt1 @ 1+ icnt1 ! ;i ' irq_forth is irq \ Install the interrupt for warm start : init ['] irq_forth is irq ; ' init is turnkey