Unconfigured Clock
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.
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.