From c6fe9462a0ff03e3702eaee2ddd9c8bef553f39d Mon Sep 17 00:00:00 2001 From: hugogogo Date: Wed, 5 Mar 2025 16:55:40 +0100 Subject: [PATCH] update prescale set --- module01/ex00/main.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/module01/ex00/main.c b/module01/ex00/main.c index 75d17b0..3809963 100644 --- a/module01/ex00/main.c +++ b/module01/ex00/main.c @@ -34,13 +34,24 @@ #define SW2 4 #define PRESCALE_VALUE 1024 +#if (PRESCALE_VALUE == 1) + #define PRESCALE_SET (1 << CS10) +#elif (PRESCALE_VALUE == 8) + #define PRESCALE_SET (1 << CS11) +#elif (PRESCALE_VALUE == 64) + #define PRESCALE_SET (1 << CS10) | (1 << CS11) +#elif (PRESCALE_VALUE == 256) + #define PRESCALE_SET (1 << CS12) +#elif (PRESCALE_VALUE == 1024) + #define PRESCALE_SET (1 << CS10) | (1 << CS12) +#endif #define TIME_MS(ms) (((F_CPU / PRESCALE_VALUE) * ms) / 1000) int main() { MODE_OUTPUT(B, D2); TURN_OFF_LED(D2); - TCCR1B |= ((1 << CS10 ) | (1 << CS12 ) ); // set timer with prescale + TCCR1B |= (PRESCALE_SET); // set timer with prescale while(1) { if ( TCNT1 >= TIME_MS(500)) {