Priorities of the channels of the LPC82x MRT timer

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

Priorities of the channels of the LPC82x MRT timer

跳至解决方案
761 次查看
topspin
Contributor II

Hi all,

I am using two channels of the MRT timer with the "Repeat interrupt mode" to run two different part of my code at different rates. My question is: how is the priority handled between two channels of the MRT timer? for instance I have MRTch1 running at 1kHz (with 2us of execution time) and MRTch2 running at 10kHz (with 40us of execution time), how can I make MRTch1 at higher priority than MRTch2?

 

 

0 项奖励
回复
1 解答
749 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

As you know that the all MRT channels share the same interrupt vector for LPC82x, in other words, all MRT channels enter the same ISR, there is not priority concept for different MRT channels.

In the ISR, you have to check the MRT->IRQ_FLAG register to know the interrupt source and take action for different flag.

Assume two interrupt events of MRT module happen, the LPC82x will enter ISR, both flags in the MRT->IRQ_FLAG will be set, you can take action in the ISR for the two interrupt events

Hope it can help you

BR

XiangJun Rong

 

在原帖中查看解决方案

0 项奖励
回复
7 回复数
750 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

As you know that the all MRT channels share the same interrupt vector for LPC82x, in other words, all MRT channels enter the same ISR, there is not priority concept for different MRT channels.

In the ISR, you have to check the MRT->IRQ_FLAG register to know the interrupt source and take action for different flag.

Assume two interrupt events of MRT module happen, the LPC82x will enter ISR, both flags in the MRT->IRQ_FLAG will be set, you can take action in the ISR for the two interrupt events

Hope it can help you

BR

XiangJun Rong

 

0 项奖励
回复
736 次查看
topspin
Contributor II

Hi @xiangjun_rong 

Ok I see now.

Is there the possibility to have the sct timer generating a pwm on a given pin with a given duty cycle and to have an interrupt triggered on the rising and falling edges of that pwm?

 

Best regarda

0 项奖励
回复
709 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

Of course, only events can trigger interrupt for the SCT module.

You can set the corresponding bits in SCT->EVEN register to enable a specific event generate interrupt.

xiangjun_rong_0-1708695639910.png

Hope it can help you

BR

XiangJun Rong

0 项奖励
回复
673 次查看
topspin
Contributor II

Hi @xiangjun_rong 

Sorry for this follow up

so I will try to have the SCT timer creating a pwm and triggering an interrupt at each rising and falling edges of the pwm. Does the SCT timer have an interrput priority higher than the MRT timer? can I modify the priority order?

 

Best regards

0 项奖励
回复
665 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

I suggest you generate PWM with  edge-alignment mode, so the rising edge and falling edge are controlled by different events for SCTimer module. Each event can fire an interrupt.

As you know that the SCTimer is interrupt source, the MRT is another interrupt source, each interrupt source has an independent 8 bits interrupt priority register, so you can program each interrupt source priority by programming the 8 bits interrupt priority register.

You can program IPR2 to configure the SCT and MRT interrupt priority.

I copy from UM10800.pdf

xiangjun_rong_0-1709011199927.png

Hope it can help you

BR

XiangJun Rong

 

0 项奖励
回复
650 次查看
topspin
Contributor II

hi @xiangjun_rong 

This sounds a good way forward!

How can I evaluate the jitter of the SCT timer?  let's say that I would like to generate a 100Hz pwm with 30Mhz system clock. I set the ctrl and matchrel registers to get the 100Hz period

SCT0->CTRL|=(199<<5); // to get a 150kHz clock to SCT

SCT0->MATCHREL[0]=1500; // to get about 100Hz period

 

Which is the expected accurcay on the 100Hz frequency using the Internal IRC oscillator?

It seems that increasing the values of MATCHREL register increase the jitter of the PWM

 

Thanks 

Best regards

 

0 项奖励
回复
647 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

The PWM signal clock frequency accuracy is solely dependent on the IRC clock frequency accuracy, which is used to drive SCT module via PLL or not.

 

This is IRC clock frequency accuracy 12MHz+/-0.15% for LPC82x.

If the output PWM is 100Hz, the jitter will be 100Hz*(+/-1.5%), in other words, ranging from 98.5Hz to 101.5Hz.

Hope it can help you

BR

XiangJun Rong

xiangjun_rong_0-1709087998604.png