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?
Solved! Go to Solution.
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
Hello,
You can config CAN0 and CAN priority through Interrupt priority register 10 and 11:
BR
Alice
Is there a function somewhere that provides the capability to change these registers?
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