reorganize files
This commit is contained in:
12
module05/ex00/timer.c
Normal file
12
module05/ex00/timer.c
Normal file
@@ -0,0 +1,12 @@
|
||||
#include "header.h"
|
||||
|
||||
// Set up Timer1 in CTC mode to trigger every 20ms
|
||||
// With 16MHz clock and prescaler of 8, and OCR1A = 39999:
|
||||
// 16MHz/8/40000 = 50Hz = 20ms period
|
||||
void timer_1B_init() {
|
||||
TCCR1A = 0; // Normal operation, OC1A/OC1B disconnected
|
||||
TCCR1B = (1 << WGM12) | (1 << CS11); // CTC mode, prescaler = 8
|
||||
OCR1A = 39999; // Compare match value for 20ms
|
||||
|
||||
TIMSK1 = (1 << OCIE1B); // Enable Timer1 Compare B Match Interrupt
|
||||
}
|
||||
Reference in New Issue
Block a user