rust-embedded-community / tm4c-hal

An Embedded HAL and general chip support for the TM4C123/LM4F120. Replaces the old lm4f120 crate.
Apache License 2.0
40 stars 26 forks source link

Unconfigured Clock #47

Open spencerdento opened 3 years ago

spencerdento commented 3 years ago

The clock's default configuration results in the delay function lasting twice as long as specified.

https://gist.github.com/9names/ab435db6bdf9056cd285c2710825ae5f With configuration the led blinks the specified amount of time. Commenting out lines 14-17 makes the led blink for what seems 2x the amount of time specified.

9names commented 3 years ago

This is not limited to using unconfigured clocks. Here's a few configurations I tested

Correct delay: Using external crystal and PLL, 80/40/20 mhz work fine. While using internal oscillator with Divider::_2 and above (tested up to Divider::_4) Incorrect delay: Using internal oscillator and setting PLL to 80mhz (4x delay) While using internal oscillator with Divider::_1 (2x delay)

I'm sure there's more permutations where delay does not do what you expect.