summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorukw2011-09-12 07:39:26 +0000
committerukw2011-09-12 07:39:26 +0000
commit7644ac04e209441d89d900125995b2d398cfd4b4 (patch)
tree963a9b4c4660a15d196df05b0acb8873f7bd0478 /main.c
parent1f54e86cd05ee6e47b5da32107d191f0983ccf04 (diff)
downloadirmp-7644ac04e209441d89d900125995b2d398cfd4b4.zip
version 2.0.0-pre7: added support for ATtiny84, added ISR in main.c, corrected timer1_init() for ATTiny85
git-svn-id: svn://mikrocontroller.net/irmp@77 aeb2e35e-bfc4-4214-b83c-9e8de998ed28
Diffstat (limited to 'main.c')
-rw-r--r--main.c33
1 files changed, 24 insertions, 9 deletions
diff --git a/main.c b/main.c
index 9877762..589bb88 100644
--- a/main.c
+++ b/main.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2009-2011 Frank Meyer - frank(at)fli4l.de
*
- * $Id: main.c,v 1.9 2011/04/11 12:54:25 fm Exp $
+ * $Id: main.c,v 1.10 2011/09/08 13:22:16 fm Exp $
*
* ATMEGA88 @ 8 MHz
*
@@ -32,21 +32,36 @@
void
timer1_init (void)
{
-#if defined (__AVR_ATtiny85__) // ATtiny85:
- OCR1A = (F_CPU / (2 * F_INTERRUPTS) / 2) - 1; // compare value: 1/28800 of CPU frequency, presc = 2
- TCCR1 = (1 << CTC1) | (1 << CS11); // switch CTC Mode on, set prescaler to 2
-#else // ATmegaXX:
- OCR1A = (F_CPU / (2 * F_INTERRUPTS)) - 1; // compare value: 1/28800 of CPU frequency
- TCCR1B = (1 << WGM12) | (1 << CS10); // switch CTC Mode on, set prescaler to 1
+#if defined (__AVR_ATtiny85__) // ATtiny85:
+ OCR1A = (F_CPU / F_INTERRUPTS / 4) - 1; // compare value: 1/15000 of CPU frequency, presc = 4
+ TCCR1 = (1 << CTC1) | (1 << CS11) | (1 << CS10); // switch CTC Mode on, set prescaler to 4
+#else // ATmegaXX:
+ OCR1A = (F_CPU / F_INTERRUPTS) - 1; // compare value: 1/15000 of CPU frequency
+ TCCR1B = (1 << WGM12) | (1 << CS10); // switch CTC Mode on, set prescaler to 1
#endif
#ifdef TIMSK1
- TIMSK1 = 1 << OCIE1A; // OCIE1A: Interrupt by timer compare
+ TIMSK1 = 1 << OCIE1A; // OCIE1A: Interrupt by timer compare
#else
- TIMSK = 1 << OCIE1A; // OCIE1A: Interrupt by timer compare
+ TIMSK = 1 << OCIE1A; // OCIE1A: Interrupt by timer compare
#endif
}
+/*---------------------------------------------------------------------------------------------------------------------------------------------------
+ * Timer 1 output compare A interrupt service routine, called every 1/15000 sec
+ *---------------------------------------------------------------------------------------------------------------------------------------------------
+ */
+#ifdef TIM1_COMPA_vect // ATtiny84
+ISR(TIM1_COMPA_vect)
+#else
+ISR(TIMER1_COMPA_vect)
+#endif
+{
+ (void) irmp_ISR(); // call irmp ISR
+ // call other timer interrupt routines...
+}
+
+
int
main (void)
{