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

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

1,034 Views
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

Labels (1)
0 Kudos
Reply
1 Reply

1,026 Views
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 Kudos
Reply