modm API documentation
|
Enums | |
enum | Peripheral { BitBang, Ac, Adc, Clock, Eeprom, Tc0, Tc1, Usi, Wdt } |
lbuild module: modm:platform:core
Implements the interfaces defined in the modm:architecture
modules. Adds the -mmcu={target}
compile flag and the F_CPU={core frequency}
define.
You can define the fuse values in your source code via the FUSES
struct ELF section mechanism, they are automatically used by avrdude. For fuse values see the AVR Fuse Calculator.
The delay functions as defined by modm:architecture:delay
and called with a constant value** are implemented directly via GCC's __builtin_avr_delay_cycles(ns / (1e9 / F_CPU))
. Constant delays are therefore fairly accurate.
For delays with a dynamic time, the following limitations apply for nanoseconds:
_delay_loop_2(loops)
is used and the number of loops should be calculated by dividing the input value by ns_per_loop = 4e9/F_CPU
. However, division is prohibitively slow and thus very coarsly approximated by shifting the input: ns >> ceil(log_2(ns_per_loop))
. This is only accurate for 4e9/2^8
= 15.6MHz, 7.8MHz, 3.9MHz, etc. For all other clock speeds the error is bound by a factor of 2, so the delay is at most twice as long as expected.For micro- and milliseconds delays with dynamic time:
Generated with: 16000000 in [1 ... 32M]