As the subject indicates, I am trying to set up a 1khz on Ctimer 0 using the 1MHz Free running clock.
Any advice or suggestions are more than welcome. I am trying to create a low-level muti-tasking kernel in C. Eg. time-sliced threads
Hi,
I suggest you refer to the _ctimer_match_interrupt_example, the CTimer generate programmable period interrupt, in the ISR, you can switch the task.
You can use the systick module to generate interrupt, the systick module is core module, it's interrupt is of higher priority. For the systick module, you can refer to the led_blinky_example as the following Fig.
For the CTimer clock selection, I think you can use the line for 1MHz free running clock.
CLOCK_AttachClk(kFRO1M_to_CTIMER2);
For the period, you can modify:
/* Configuration 0 */
matchConfig0.enableCounterReset = true;
matchConfig0.enableCounterStop = false;
matchConfig0.matchValue = 1000; //Rong wrote; to generate 1KHz interrupt
matchConfig0.outControl = kCTIMER_Output_Toggle;
matchConfig0.outPinInitState = false;
matchConfig0.enableInterrupt = true;
Hope it can help you
BR
XiangJun Rong