8051 Microcontrollers DISCUSSION

Why does a classic 8051 delay run at the wrong speed on an EFM8?

Started by heliks 8051 timingEFM8timer clocksinstruction cyclesfirmware migration
3 replies 248 views 4 participants
Latest activity · 27 Sep 2026

Why does a classic 8051 delay run at the wrong speed on an EFM8?

heliks 8051 Microcontrollers Forum
#1

Community replies 3

Re: Why does a classic 8051 delay run at the wrong speed on an EFM8?

#2

No. Instruction compatibility does not guarantee the same number of oscillator clocks per instruction or the same timer clock. Check the selected system clock, divider and timer source in the exact device manual. EFM8 timer sources can be configurable, so applying a blanket divide-by-12 assumption can be wrong.

Re: Why does a classic 8051 delay run at the wrong speed on an EFM8?

#3

Replace a timing-critical busy loop with a hardware timer where appropriate and calculate from the timer's actual input frequency. For a 1 MHz timer tick, a 1 ms interval is 1,000 counts, giving a nominal 16-bit overflow preload of 64,536. That example applies only when the configured timer clock is really 1 MHz.

Re: Why does a classic 8051 delay run at the wrong speed on an EFM8?

#4

Measure a diagnostic output after initialization and again under normal interrupt load. Compiler optimization can change a software delay loop, while interrupt execution adds further variation. Keep clock configuration and timing calculations together in the project notes so a later oscillator change does not silently invalidate them.

TEP COMMUNITY