Changing interrupt priorities for CAN on LPCXpresso54S018

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

Changing interrupt priorities for CAN on LPCXpresso54S018

Jump to solution
1,032 Views
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 Kudos
Reply
1 Solution
1,014 Views
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

View solution in original post

0 Kudos
Reply
4 Replies
1,028 Views
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 Kudos
Reply
1,022 Views
brian_ungar
Contributor III

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

0 Kudos
Reply
1,015 Views
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 Kudos
Reply
1,010 Views
brian_ungar
Contributor III
Thank you.
0 Kudos
Reply