User Tools

Site Tools




void startTimerEvent(u16 interval)

interval : The amount of time between each event in milliseconds (1 ~ 65,535)

Starts a timer that triggers events every interval milliseconds.

These timers can be used to trigger background processes at regular intervals, thus simulating multitasking.

Care must be taken when using these timers. The process triggered by the event, i.e. service routine, must execute in less time than the timer's interval. If the service routine cannot finish in time, the system will never be able to exit out to the main routine.

#include "moacon500.h"
void cmain(void)
 startTimerEvent(500); //Execute timerEvent() every 500ms
 while(1) //Run forever
 delay(2000); //Pause for 2 seconds
void timerEvent()
 printf("Timer Event Fired!\r\n"); //Print to the debug console

go MOACON home

moacon/starttimerevent/index.txt · Last modified: 2016/04/14 11:07 (external edit)