Richard,
I have not programmed a 'mega32, but have used the 16 bit timer on the
tiny2313. It appears that you are incorrectly programming the timer as
an 8 bit timer. Timer1 is 16 bits. This may be your problem (or I may
be way off base).
Best regards,
Paul H.
--- In AVR-Chat@yahoogroups.com, "rlrsmith" <rlrsmith@y...> wrote:
>
> Having a problem with the Compare Output functions in Timer1 on an
> ATMega32.
> Have simulated the code under AVRStudio with various combinations of
> the top 4 bits of the TCCR1A register - the code only appears to
> affect the PIND register rather than the PORTD register. I can't
> spot the deliberate mistake - can anyone else help?
>
> Thanks,
>
> Richard Smith
> rlrsmith@y...
>
> Code listing below:
>
> #include <avr/io.h>
> #include <avr/interrupt.h>
> #include <avr/signal.h>
>
> INTERRUPT(SIG_OUTPUT_COMPARE1A)
> {
> }
>
> INTERRUPT(SIG_OUTPUT_COMPARE1B)
> {
> }
>
> int main(void)
> {
> DDRD=0xFF;
> PORTD = 0xFF;
>
> //Reset counter
> TCNT1 = 0;
>
> //Initiate timers
> TCCR1A = 0b10101100; //See pg.105
> TCCR1B = 0b00000000; //See pg.105
>
> //Clear output compare interrupt flags
> TIFR = (_BV(OCF1A)|_BV(OCF1B)); //See pg. 111
>
> //Enable output compare interrupts
> TIMSK = (_BV(OCIE1A)|_BV(OCIE1B)); //See pg. 110
>
> OCR1A = 0x00FF;
> OCR1B = 0x000F;
>
> // Start timer
> TCCR1B |= 0b00000010;
>
> sei();
> for(;;);
> }Message
Re: Compare Output Mode problem
2005-03-24 by paul_hvidston
Attachments
- No local attachments were found for this message.