1 /* (CC-BY-NC-SA) ROBIN KRENS - ROBIN @ ROBINKRENS.NL
4 * 2019/8/14 - ROBIN KRENS
8 * SysTick of Cortex M* MCUs. Have a look at the more complex RTC
9 * in case more accurate timing is needed.
18 #include <sys/robsys.h>
21 #include <lib/regfunc.h>
22 #include <lib/tinyprintf.h>
24 struct interrupt_frame {
36 //__attribute__ ((interrupt))
37 void * systick_handler(/* struct interrupt_frame * frame */) {
39 printf("Ticking...\n");
45 /* Every time the counter counts down to zero
46 * a systick exception is invoked. Systick has
47 * exception number 15. in the vector table */
48 ivt_set_gate(15, systick_handler, 0);
50 /* Get calibration and set this to 1 sec
51 * !Most boards have a 1 ms or 10 ms
52 * calibration value */
53 int calib = (*STK_CALIB << 0) * 500;
55 /* The counter reload registers counts down to zero
56 * and then it is restores the value */
57 rwrite(STK_RELOAD, calib);
59 /* Enable the counter and enable the interrupt
60 * associated with it */