diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-06-10 23:09:23 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-06-10 23:09:23 +0000 |
commit | f48042de9ebf4ab1d33b1b53ce799911ca1de990 (patch) | |
tree | 0a1b09e3df4d96e1e7db689e618c08873640c0a2 /nuttx/arch | |
parent | 1376ded6e0aebc3d6d1062518ed99592e9cc1e63 (diff) | |
download | px4-nuttx-f48042de9ebf4ab1d33b1b53ce799911ca1de990.tar.gz px4-nuttx-f48042de9ebf4ab1d33b1b53ce799911ca1de990.tar.bz2 px4-nuttx-f48042de9ebf4ab1d33b1b53ce799911ca1de990.zip |
Clean up AVR timer setup
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3692 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/arch')
-rw-r--r-- | nuttx/arch/avr/src/at90usb/at90usb_timerisr.c | 24 | ||||
-rw-r--r-- | nuttx/arch/avr/src/atmega/atmega_timerisr.c | 24 |
2 files changed, 40 insertions, 8 deletions
diff --git a/nuttx/arch/avr/src/at90usb/at90usb_timerisr.c b/nuttx/arch/avr/src/at90usb/at90usb_timerisr.c index 079433b8d..5e92acb5a 100644 --- a/nuttx/arch/avr/src/at90usb/at90usb_timerisr.c +++ b/nuttx/arch/avr/src/at90usb/at90usb_timerisr.c @@ -151,15 +151,31 @@ void up_timerinit(void) OCR1AH = (uint8_t)((uint16_t)MATCH >> 8); OCR1AL = (uint8_t)((uint16_t)MATCH & 0xff); - /* Setup clock source and compare match behaviour. */ + /* Setup clock source and compare match behaviour. + * + * TCRR1A: + * COM1A 0:1 = 00 -> Normal port operation + * COM1B 0:1 = 00 -> Normal port operation + * COM1C 0:1 = 00 -> Normal port operation + * WGM1 0:1 = 00 -> Clear Timer on Compare (CTC) modes of operation + */ + + TCCR1A = 0; + + /* TCCR1B: + * ICNC1 = 0 -> Input Capture Noise Canceler disabled + * ICES1 = 0 -> Input Capture Edge Select + * WGM 2:3 = 01 -> Clear Timer on Compare (CTC) modes of operation + * CS1 0:2 = xxx ->Selected pre-scaler. + */ - TCCR1A = 0x08 | PRESCALE; + TCCR1B = (1 << WGM12) | PRESCALE; /* Attach the timer interrupt vector */ - (void)irq_attach(AT90USB_IRQ_T2COMPA, (xcpt_t)up_timerisr); + (void)irq_attach(AT90USB_IRQ_T1COMPA, (xcpt_t)up_timerisr); /* Enable the interrupt on compare match A */ - TIMSK1 |= 0x10; + TIMSK1 |= (1 << OCIE1A); } diff --git a/nuttx/arch/avr/src/atmega/atmega_timerisr.c b/nuttx/arch/avr/src/atmega/atmega_timerisr.c index 6cd11e393..402add3d3 100644 --- a/nuttx/arch/avr/src/atmega/atmega_timerisr.c +++ b/nuttx/arch/avr/src/atmega/atmega_timerisr.c @@ -151,15 +151,31 @@ void up_timerinit(void) OCR1AH = (uint8_t)((uint16_t)MATCH >> 8); OCR1AL = (uint8_t)((uint16_t)MATCH & 0xff); - /* Setup clock source and compare match behaviour. */ + /* Setup clock source and compare match behaviour. + * + * TCRR1A: + * COM1A 0:1 = 00 -> Normal port operation + * COM1B 0:1 = 00 -> Normal port operation + * COM1C 0:1 = 00 -> Normal port operation + * WGM1 0:1 = 00 -> Clear Timer on Compare (CTC) modes of operation + */ + + TCCR1A = 0; + + /* TCCR1B: + * ICNC1 = 0 -> Input Capture Noise Canceler disabled + * ICES1 = 0 -> Input Capture Edge Select + * WGM 2:3 = 01 -> Clear Timer on Compare (CTC) modes of operation + * CS1 0:2 = xxx ->Selected pre-scaler. + */ - TCCR1A = 0x08 | PRESCALE; + TCCR1B = (1 << WGM12) | PRESCALE; /* Attach the timer interrupt vector */ - (void)irq_attach(AT90USB_IRQ_T2COMPA, (xcpt_t)up_timerisr); + (void)irq_attach(ATMEGA_IRQ_T1COMPA, (xcpt_t)up_timerisr); /* Enable the interrupt on compare match A */ - TIMSK1 |= 0x10; + TIMSK1 |= (1 << OCIE1A); } |