From c037b5184d00bbb7b6961cc2c2f96105ea0e59da Mon Sep 17 00:00:00 2001 From: hugo LAMY Date: Fri, 7 Mar 2025 08:03:17 +0100 Subject: [PATCH] update mod01 ex01 main comment --- module01/ex01/main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/module01/ex01/main.c b/module01/ex01/main.c index 2fb2a4a..0f52965 100644 --- a/module01/ex01/main.c +++ b/module01/ex01/main.c @@ -62,9 +62,11 @@ #define PRESCALE_SET (1 << CS10) | (1 << CS12) #endif #define TIME_MS(ms) (((F_CPU / PRESCALE_VALUE) * ms) / 1000) +#define PERIOD 500 // END MACROS +// led turns on and off every PERIOD ms int main() { MODE_OUTPUT(LED2); @@ -72,13 +74,11 @@ int main() { TCCR1A |= (1 << COM1A0); // 14.3.1 : set Compare Output with COM1A0, it toggles OC1A on compare match (Table 16-1), OC1A is alternate function for PORTB1 (Table 14-3) - OCR1A = TIME_MS(500); // Table 16-4 : set CTC compare value, the counter is cleared to zero when the counter value (TCNT1) matches the OCR1A register + OCR1A = TIME_MS(PERIOD); // Table 16-4 : set CTC compare value, the counter is cleared to zero when the counter value (TCNT1) matches the OCR1A register TCCR1B |= (PRESCALE_SET); - while(1) { - continue; - } + while(1); }