
\ -------------------------------------------------------------
\  How to use the timer interrupt
\ -------------------------------------------------------------

 &+000 constant ticks
&+0000 constant reload

\ The interrupt handler needs to be a ( -- ) definition.

: irq-handler ."  {^o^} " ;

\ Write a jump opcode to the handler into the interrupt trampoline at address 1

' irq-handler 2 lshift &0- 3any 1 !

eint \ Ready to go, enable interrupts.
eint? t.

true 10000 - reload io! \ Timer triggers on overflow, set reload value to trigger in 1000 cycles
true ticks io!          \ Trigger an interrupt now! Else it would take some time for the counter to wrap over.

words

dint
eint? t.

words

