Skip to content

Core code causes timing issues at some alternative clock speeds #151

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
trthanhquang opened this issue Jan 13, 2016 · 0 comments
Open

Comments

@trthanhquang
Copy link

I recently tried to run my Atmega328p with a 1.8432Mhz crystal (to use a faster baud rate). I managed to recompile the bootloader by changing AVR_FREQ and FUSES in Optiboot Makefile, boards.txt

However I found out some timing issue with Arduino's implementation of delay, millis, micros....
As defined
in Arduino.h (line 96)
#define clockCyclesPerMicrosecond() ( F_CPU / 1000000L )
in wiring.c (line 103)

unsigned long micros() {
 ...
 return ((m << 8) + t) * (64 / clockCyclesPerMicrosecond());
}

This integer division really limit the choices of clock!

The baud rate is correct and avr version of delay (_delay_ms) work correctly for me. I am not sure if any other libraries are affected.

@per1234 per1234 changed the title External Clock on Atmega328p using Arduino Core code causes timing issues at some alternative clock speeds Jul 4, 2017
@sandeepmistry sandeepmistry transferred this issue from arduino/Arduino Sep 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant