Pages: [1]   Go Down
Author Topic: Attempting to set TC0 to interrupt at a specific frequency. Need help  (Read 1153 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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


Offline Offline
God Member
Karma: 32
Posts: 507
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

There are examples of how to do this in this thread:,130423.0.html

Pages: [1]   Go Up
Jump to: