Would you like to react to this message? Create an account in a few clicks or log in to continue.

You are not connected. Please login or register

AVR timer calculator

2 posters

Go down  Message [Page 1 of 1]

1AVR timer calculator Empty AVR timer calculator Fri Mar 25, 2022 4:22 pm

n3645



https://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-7810-Automotive-Microcontrollers-ATmega328P_Datasheet.pdf

If I understand correctly AVR datsheet, partiularly for ATmega328p, section 15.9.2, OCRnA value is calculated by:

OCRnA  = F_OCnA/ F_clkIO / N - 1

For instance, for 1s timer, prescaler 1024 and 16-bit timer, the value should be 15624. On the web page result is 15625.

https://www.simulide.com/p/blog-page_8.html

On various sources, calculators shows either result, but according to datasheet, only one is correct.

Perhaps also to add prescaler value and resolution for complete calculation.

2AVR timer calculator Empty Re: AVR timer calculator Fri Mar 25, 2022 5:09 pm

arcachofo

arcachofo

I will have a look to that javascript, but you are probably right, 15625 is the period in cycles and 15624 the match value.

Perhaps also to add prescaler value and resolution for complete calculation.
Good idea.

Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum