4.1. MTIMER - System Timer
This demo is based on a 64-bit timer (MTIMER) that comes with the risc-v kernel. This demo can provide reference for os tick.
4.1.1. Hardware Connection
None
4.1.2. Software Implementation
See
examples/systick
for the software code
备注
The mtimer
clock defaults to 1M after frequency division, which is convenient for later use and reduces calculation time.
1void systick_isr()
2{
3 static uint32_t tick=0;
4 tick++;
5 MSG("tick:%d\r\n",tick);
6}
7
8bflb_platform_set_alarm_time(1000000,systick_isr);
Use the above code to set the mtimer timing time to 1s, and register the interrupt callback function.
4.1.3. Compile and Program
CDK compilation
Open project:systick.cdkproj
Refer to the steps of Guide to using CDK (like MDK Keil) under Windows to compile and download
Command compilation
1 $ cd <sdk_path>/bl_mcu_sdk
2 $ make BOARD=bl706_iot APP=systick
Program
4.1.4. Experimental Phenomena
The tick
value is incremented by 1 per second and printed through the serial port.