reorganize files

This commit is contained in:
hugo LAMY
2025-03-14 19:47:02 +01:00
committed by hugogogo
parent 0e87d41c08
commit b12eff7ede
4 changed files with 29 additions and 14 deletions

12
module05/ex00/timer.c Normal file
View 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
}