This program blinks a LED using the SysTick timer exception.
- main.c
#include BOARD_H
#define SYSHZ 36e6 // Desired frequency for the SYSCLK signal
#define AHBHZ 9e6 // Desired frequency for the core (and systick)
#define PERIOD 0.5 // Blinking period
int main ( )
{
input, hsi/2,
hwa( connect, sysclk, pll );
while ( !
hw(stat,pll).ready ) {}
hwa( clock, ahb, sysclk / (SYSHZ/AHBHZ) );
mode, digital_output,
frequency, lowest );
uint32_t onems =
hw(read, (systick,onems));
clock, ahb,
reload, ((uint32_t)(PERIOD/2 / 0.001)*onems - 1) & 0xFFFFFF );
hwa( turn, systick, on );
hwa( enable, (systick,irq) );
for(;;) {
}
}