Quantcast
Channel: Microcontrollers
Viewing all articles
Browse latest Browse all 4922

AVR Timer: CTC mode

$
0
0
Hello,

I learning AVR programming,

I have made a code to toggle AVR pin at an interval using interrupts

Here' the code

Code (Text):
  1. #include <avr/io.h>
  2. #include <avr/interrupt.h>
  3.  
  4. // initialize timer, interrupt and variable
  5. void timer1_init()
  6. {
  7.     // set up timer with prescaler = 64 and CTC mode
  8.     TCCR1B |= (1 << WGM12)|(1 << CS11)|(1 << CS10);
  9.  
  10.     TIMSK1 |= (1 << OCIE1B);        // Output Compare B Match Interrupt Enable
  11.     // initialize counter
  12.     TCNT1 = 0;
  13.  
  14.     // initialize compare...
AVR Timer: CTC mode

Viewing all articles
Browse latest Browse all 4922

Trending Articles