
\ ------------------------------------------------------------------------------
\   On how to use the timer interrupt
\ ------------------------------------------------------------------------------

$01F2 constant ticks
$01F4 constant reload

0 variable (ms)

: interrupt-handler ( -- )
  1 (ms) +!
  (ms) @ 8 rshift dup 1 rshift xor leds
;

\ Prepare reload value to divide incoming 40 MHz into 1000 Hz.
\ Negative, because ticks count upwards and the interrupt triggers on overflow

-40000 reload !

\ -40000 does not fit into 16 bits, but this is fine, as we only want the starting
\ values that overflows the register at the correct point in time.

\ The FemtoMSP430 only knows one interrupt, which is wired to the watchdog vector:

['] interrupt-handler irq-watchdog !

\ Enable interrupts to start blinking

eint
