Changing interrupt priorities for CAN on LPCXpresso54S018

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

Changing interrupt priorities for CAN on LPCXpresso54S018

跳至解决方案
1,722 次查看
brian_ungar
Contributor III

I have a LPCXpresso54S018 card. I have code that use the MCAN driver that comes with the SDK. I am also using FreeRTOS.

When the driver gets an interrupt, it invokes a callback function that calls xSemaphoreGiveFromISR. Within this function there is a check that ensures that the priority of the interrupt is greater than or equal to configMAX_SYSCALL_INTERRUPT_PRIORITY. I am failing this check and crashing the program.

I see documentation in various locations that indicate that the priority of an interrupt has to be changed when using FreeRTOS on the LPCXpresso54S018 card. However, I see no documentation telling you how. In particular, how can I change the priority of the CAN0 and CAN1 interrupts on my board? Is there an SDK function call or something in the MCAN driver?

0 项奖励
回复
1 解答
1,704 次查看
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello,

 

 

 

/**
\brief Set Interrupt Priority
\details Sets the priority of a device specific interrupt or a processor exception.
The interrupt number can be positive to specify a device specific interrupt,
or negative to specify a processor exception.
\param [in] IRQn Interrupt number.
\param [in] priority Priority to set.
\note The priority cannot be set for every processor exception.
*/
__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
{
if ((int32_t)(IRQn) >= 0)
{
NVIC->IP[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL);
}
else
{
SCB->SHP[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL);
}
}

 

 

BR

Alice

在原帖中查看解决方案

0 项奖励
回复
4 回复数
1,718 次查看
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello,

You can config CAN0 and CAN priority through Interrupt priority register 10 and 11:

Alice_Yang_0-1661916530108.png

 

BR

Alice

 

0 项奖励
回复
1,712 次查看
brian_ungar
Contributor III

Is there a function somewhere that provides the capability to change these registers?

0 项奖励
回复
1,705 次查看
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello,

 

 

 

/**
\brief Set Interrupt Priority
\details Sets the priority of a device specific interrupt or a processor exception.
The interrupt number can be positive to specify a device specific interrupt,
or negative to specify a processor exception.
\param [in] IRQn Interrupt number.
\param [in] priority Priority to set.
\note The priority cannot be set for every processor exception.
*/
__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
{
if ((int32_t)(IRQn) >= 0)
{
NVIC->IP[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL);
}
else
{
SCB->SHP[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL);
}
}

 

 

BR

Alice

0 项奖励
回复
1,700 次查看
brian_ungar
Contributor III
Thank you.
0 项奖励
回复