我现在想要一个1s的定时器中断,在cc1310中并且在RTOS系统中怎么产生
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
HI,请参考:
// Convenience macro to make the code more readable
// Set Clock.tickPeriod in the .cfg file
#define Clock_convertSecondsToTicks(seconds) \
(((seconds) * 1000000) / (Clock_tickPeriod))
// Solution 1
// ----------
// Reserve memory for the clock object
Clock_Struct clock;
uint32_t timeoutTicks = Clock_convertSecondsToTicks(30);
// Create a one-shot timer
Clock_construct(&clock, &Serial_TimerCallback, timeoutTicks, NULL);
// Start the timer
Clock_start(Clock_handle(&clock));
// Solution 2
// ----------
uint32_t timeoutTicks = Clock_convertSecondsToTicks(30);
// Create a one-shot timer somewhere on the heap
Clock_Handle clock = Clock_create(&Serial_TimerCallback, timeoutTicks, NULL, NULL);
// Start the timer
Clock_start(clock);
// Solution 3
// ----------
// Create a static clock object in the .cfg file
// The init code is automatically generated by xdctools
var clock0Params = new Clock.Params();
clock0Params.instance.name = "clock";
Program.global.clock = Clock.create("&Serial_TimerCallback", 30, clock0Params);
// Start the clock somewhere in your program
extern const Clock_Handle clock;
Clock_start(clock);