aboutsummaryrefslogtreecommitdiff
path: root/forth/forth/avr/irqAtmega328.fs
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2018-09-29 01:02:00 +0200
committerDimitri Sokolyuk <demon@dim13.org>2018-09-29 01:02:00 +0200
commit79cabd5b1c8bcd9f50dc49e77776e713a57dff48 (patch)
tree6eb73857e9c174610839291cf05a02d77fc82b8c /forth/forth/avr/irqAtmega328.fs
parent247df3bb9d4c89d4e5ff18dcc23ba1c9532f28c0 (diff)
parent110a6411bae421260476eacf6173897c1d1f4b8a (diff)
Merge branch 'master' of dim13.org:elegoo
Diffstat (limited to 'forth/forth/avr/irqAtmega328.fs')
-rw-r--r--forth/forth/avr/irqAtmega328.fs42
1 files changed, 42 insertions, 0 deletions
diff --git a/forth/forth/avr/irqAtmega328.fs b/forth/forth/avr/irqAtmega328.fs
new file mode 100644
index 0000000..2f6a53f
--- /dev/null
+++ b/forth/forth/avr/irqAtmega328.fs
@@ -0,0 +1,42 @@
+\ *********************************************************************
+\ Interrupts example for FlashForth *
+\ Filename: irqAtmega328.txt *
+\ Date: 10.11.2014 *
+\ FF Version: 5.0 *
+\ MCU: Atmega328 *
+\ Copyright: Mikael Nordman *
+\ Author: Mikael Nordman *
+\ *********************************************************************
+\ FlashForth is licensed acording to the GNU General Public License*
+\ *********************************************************************
+\ Disable interrupt before removing the interrupt code
+irqOvf2Dis
+-irqOvf2
+marker -irqOvf2
+\ Timer 2 definitions from m328pdef.inc
+$b1 constant tccr2b
+$70 constant timsk2
+#10 constant ovf2Ivec
+
+\ Counter for timer overflows
+variable counter
+
+\ The interrupt routine
+: t2OverflowIsr
+ 1 counter +!
+;i
+
+: irqOvf2Init
+ \ Store the interrupt vector
+ ['] t2OverflowIsr ovf2Ivec int!
+ \ Activate counter 2
+ 3 tccr2b c!
+ \ Activate timer2 overflow interrupt
+ 1 timsk2 mset
+;
+: irqOvf2Dis
+ 1 timsk2 mclr
+;
+
+\ irqOvf2Init
+