HWA
Bare metal programming with style
Class _stka: SysTick timer (STK)

Relatives

According to PM0056, the _stka class SysTick timer has a tenms logical register that holds the factory calibration value for a 10 ms period.

In fact, for the STM32F103, the value of tenms is 9000. Then, the calibration value minus 1 gives a 1 ms period (yes, ONE ms) when the SysTick is clocked at 9 MHz (72 MHz / 8).

For that reason, HWA also provides a onems logical register that is the same as tenms but maybe less confusing.

// 1 ms period when AHB is clocked at 9 MHz
//
hw( configure, systick,
clock, ahb,
reload, (hw(read, (systick,onems)) - 1) & 0xFFFFFF,
run, yes );

Interface

hw|hwa( configure, systick,
[ clock, ahb // Clock source
| ahb/8 ],
[ reload, x, ] // Any value in 0..0xFFFFFF
[ run, yes | no ] );
hw|hwa( turn, systick, on | off );
uint32_t v = hw( read, systick ); // Returns the current value of the timer
hwa
#define hwa(...)
hwa( action, object [,...] ) stores an action for an object into a HWA context.
Definition: hwa_macros.h:552
hw
#define hw(...)
hw( action, object [,...] ) executes an action immediately on an object.
Definition: hwa_macros.h:523