How do I set up a 1khz on Ctimer 0 using the 1MHz Free running clock on the LPC5516?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

How do I set up a 1khz on Ctimer 0 using the 1MHz Free running clock on the LPC5516?

1,031 次查看
upstate
Contributor IV

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

标签 (1)
0 项奖励
回复
1 回复

1,023 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

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;

xiangjun_rong_0-1650594540177.png

 

xiangjun_rong_1-1650594860797.png

 

Hope it can help you

BR

XiangJun Rong

 

0 项奖励
回复