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,053件の閲覧回数
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,045件の閲覧回数
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 件の賞賛
返信