On Sep 28, 2011, at 6:47 AM, Jim Wagner wrote: > What is your system clock? > > Jim Wagner > > On Sep 27, 2011, at 10:41 PM, Philippe Habib wrote: > >> As it turned out, I need timer 0 to run PWM on a pin so I have to >> use timer 1 for my timer tick. >> >> Using what I learned from timer 0, I was hoping it would be easy to >> generate a 10ms tick using timer 1. >> >> Here is my setup: >> >> TCCR1A = (0 << WGM10) | (0 << WGM11); // Make sure these are low for >> CTC >> TCCR1B |= (0 << WGM12); // CTC mode >> TCCR1B |= (1 << CS12); // Use system clock Don't know why you have this here. >> TCCR1B |= (1 << CS10) | (0 << CS11) | (0 << CS12); // no div, full >> clock Combined with the above line you have a clock select value of 5 or divide by 1024, not 1 >> TIMSK1 = (1 << OCIE1A); // Set int for match on A >> >> OCR1A = 64000; // compare value >> // OCR1AH = 0xFF; // MSB >> // OCR1AL = 0x00; // LSB 64000 decimal is 0xFA00 This gives you a interrupt rate of .122 Hz or about every 8 seconds. (assuming 8MHz clock which I believe is the case). To get 100mS you would need: TCCR1B |= (0 << CS10) | (1 << CS11) | (0 << CS12); // divide by 8 OCR1A = 10000; > >
Message
Re: [AVR-Chat] More timer confusion
2011-09-28 by Clark Martin
Attachments
- No local attachments were found for this message.