Dear ALL,
I am doing register level programming using LPC54606J512BD100 with peripheral MRT which is working fine, But i want to generate counter delay for 1ms, 100ms, 1 sec.
is there any calculation for this?
please tell me.
my core clock is 180 MHz.
Hi,
The MRT module driving clock is from the AHB clock(Bus clock), for example, if the core clock of LPC54606J512BD100 is 180mhz, the AHB bus clock is also 180MHz, clock cycle time is 1/180MHz=5.55555nS
for 1mS delay, the required counter value is 1mS/5.555555nS=180 000
for 100mS delay, the required counter value is 100ms/5.55555nS=18 000 000, the counter can not reach up to the value because of limited counter bits.
Because the counter is 24 bits, so that counter maximum value is 2**24=16 777 216, so the maximum delay time is 16 777 216/[(180*(10**6)]=93.206mS.
Hope it can help you
BR
XiangJun Rong
MRT 179999 FOR 2ms delay this the value please tell me is it right as per core clock 180 MHz.
because on CRO its showing 2ms delay.
just want to confirm is it right as per my value in MRT counter value.
Hi,
The delay time is 179999*(1/180M)=1mS
Hope it can help you
BR
XiangJun Rong
but on CRO its showing 2ms. with value of 179999
Is there issue in my core clock ?
Hi,
What is CRO?
I suppose you use the code like
void main()
{
.............
for(;;)
{
delay(179999); //implemented by MRT
toggle_LED();
}
You test the LED signal cycle time with oscilloscope, it is 2mS.
Pls note that the signal toggling twice to comprise a cycle, so the cycle is 2mS if MRT delay 1mS..
Pls check
BR
XiangJun Rong
thankyou so much for the clearification.
thanks for the help
> is there any calculation for this?
No.
This is a very bad idea for many reasons.
Use a timer. The best option is SystTick, which is portable amongst all Cortex M devices, and has an easy configuration interface. And there are already CMSIS functions to set it up.