I’ve got no experience whatsoever with Leonardo boards, but, the board_build.f_cpu
doesn’t change the physical clock speed of the board, it’s there for when you have changed the hardware to a non-default CPU frequency as the F_CPU
value is passed into the code to make sure that things “flash” at the correct speed.
It’s the same with my ATtiny85 boards. The default is an 8 MHz internal clock, with a divide by 8 fuse set, so it’s running actually at 1 MHz. If I set the board build f_cpu to anything different, the timings don’t work correctly.
You need to either default the frequency, leave it out of the ini file, or set it to the actual CPU clock frequency that the board is running. Then things should be fine.
I tested the blink sketch on my Uno.
The default clock is 16 MHz and a 1 second delay is roughly that and the scope says period = 1.98 S and frequency = 0.505 Hz which is as expected as there are two delays per flash! (That always catches me out!)
In the ini file, I then added board_build.f_cpu = 1000000L
which is 16 times slower than the actual clock. Uploading blink gives me a 8 Hz flash frequency with a period of 125 mS.
The actual delay is 62.5 mS, which is exactly 1000/16.
HTH
Cheers,
Norm.