Go Down

Topic: Attempting to set TC0 to interrupt at a specific frequency. Need help (Read 1 time) previous topic - next topic

ack47

Hello everyone,
I'm new to programming and thus far only really have experience using the AtMega16. I'm attempting to set up an interrupt at 1Khz using TimerCounter0 and setting RC (compare register) to a specific value to achieve this. Below is the code to hopefully do this. I was hoping someone could take a look, see if I'm on the right track or not.

TC_WPMR = 0x54494D;           //This is the password required to allow me to disable the security
TC_WPMR &= ~(0x00000001);  // Disabling security to allow to me write to specific registers
TC_CCR0 |= 0x00000001;       //Enabling clock for TC0
TC_CMR0 |= 0x0000C001;      //Setting to use Timer_Clock2 (Prescaler of eight). Also WAVSEL =2 and WAVE = 1, this sets the waveform selection and to enable it
TC_RC0 = 104999;                 // Compare value. Because of WAVSEK = 2 the counter will clear on compare
TC_IER0 |= 0x00000010;        //Enables the RC compare interrupt

This is what I have thus far. Like I said, any help would be greatly appreciated




stimmer

There are examples of how to do this in this thread:
http://arduino.cc/forum/index.php/topic,130423.0.html
Due VGA library - http://arduino.cc/forum/index.php/topic,150517.0.html

Go Up