aboutsummaryrefslogtreecommitdiff
path: root/forth/forth/avr/irqAtmega128.fs
blob: 43e20f9c428f858fc4405d121cbe637cadf56db2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
\ *********************************************************************
\    Interrupts example for FlashForth                                *
\    Filename:      irq.txt                                           *
\    Date:          04.10.2013                                        *
\    FF Version:    5.0                                               *
\    MCU:           Atmega128                                         *
\    Copyright:     Mikael Nordman                                    *
\    Author:        Mikael Nordman                                    *
\ *********************************************************************
\    FlashForth is licensed acording to the GNU General Public License*
\ *********************************************************************
\ Disable interrupt before removing the interrupt code
irqOvf3Dis
-irqOvf3
marker -irqOvf3
\ Timer 3 definitions from m128def.inc
$8a constant tccr3b
$7d constant etimsk
#30 constant ovf3Ivec

\ Counter for timer overflows
variable counter

\ The interrupt routine
: t3OverflowIsr
  1 counter +!
;i

: irqOvf3Init
  \ Store the interrupt vector
  ['] t3OverflowIsr ovf3Ivec int!
  \ Activate counter 3
  1 tccr3b mset
  \ Activate timer3 overflow interrupt
  4 etimsk mset
;
: irqOvf3Dis
  4 etimsk mclr
;

irqOvf3Init

counter @ u.
#1000 ms
counter @ u.