I want to generate a 10ms timer using ATMEGA32. The crystal used is 8MHz. Is this calculation correct TCNT0 value is correct.The prescaler value i used is 1024.
is the calculation and the value 78 for TCNT0 is correct?
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It only takes a minute to sign up.Sign up to join this community
If you want to get periodic timer, you shall use CTC mode.
Check the datasheet page 99:
The formula is: F = F_CPU / (2 * N * (1 + OCR0))
OCR0 = (F_CPU / (F * 2 * N)) - 1 = (8000000 /(100 * 2 * 1024)) - 1 = 38.06 = 38
Timer 0 CTC mode (page 106): WGM02=0 WGM01=1 WGM00=0
To use TIMER0_COMP_vect interrupt, OCF0 & OCIE0 flags must be set.