Hello,
I'm using EmbOS version: 5.06.1 on an IMXRT1062 board with a ARM Cortex M7.
I'm writing my own driver for CANbus and I have defined some interrupt service routines that executes every time I send/receive a message.
This is how I initialize the CAN and the IRQHandlers :
---------------------------------------------------------------------------------------
/* Interrupt handlers. */
extern "C" void CAN1_IRQHandler(void)
{
MISRAC_DISABLE
OS_EnterInterrupt();
can1.interrupt_handler();
OS_LeaveInterrupt();
MISRAC_ENABLE
}
extern "C" void CAN2_IRQHandler(void)
{
MISRAC_DISABLE
OS_VFP_Save();
OS_EnterInterrupt();
can2.interrupt_handler();
OS_LeaveInterrupt();
OS_VFP_Restore();
MISRAC_ENABLE
}
/**
* Init method for CAN
*/
void imx1062_can_t::init(uint32_t bitrate)
{
OS_IncDI(); /*disable interrupts*/
/* Init FlexCAN module. */
FLEXCAN_GetDefaultConfig(&flexcanConfig);
FLEXCAN_Init(this->can_ptr, &flexcanConfig, 40000000U);
NVIC_SetPriority(CAN2_IRQn, 5u);
NVIC_EnableIRQ(CAN2_IRQn);
/* Setup RX message buffer to receive any ID */
setupRxMessageBuffer(kFLEXCAN_FrameFormatStandard, kFLEXCAN_FrameTypeData);
/* Set IMASK such that an interrupt is triggered on message receive in message buffer MESSAGE_OB_RX (community.nxp.com/thread/459431)*/
this->can_ptr->IMASK1 = 1 << MESSAGE_OBJ_RX;
OS_DecRI(); /*enable interrupts*/
}
------------------------------------------------------------------------------------------------------------
Since in the method interrupt_handler() I make some calls to OS functions (like OS_PutMail used for mailboxes) If I'm not mistaken I have to tell the OS that I'm within an interrupt, with the methods OS_EnterInterrupt() and OS_LeaveInterrupt().
However, when OS_EnterInterrupt() gets executed, it throws a status error. I don't know where it is thrown because I cannot debug inside these methods.
I saw some other threads in this community about my same problem, I tried to do what they tell to do:
1) set the priority to a value higher then 127
2) try to use the 'ARM' version of the methods to enable the interrupt
//OS_ARM_InstallISRHandler(CAN2_IRQn, (OS_ISR_HANDLER*) CAN2_IRQHandler);
//OS_ARM_ISRSetPrio(CAN2_IRQn, 130); // Set prio < 128
//OS_ARM_EnableISR(CAN2_IRQn);
But it didn't work.
How can I fix it?
thank you in advance,
Giacomo
I'm using EmbOS version: 5.06.1 on an IMXRT1062 board with a ARM Cortex M7.
I'm writing my own driver for CANbus and I have defined some interrupt service routines that executes every time I send/receive a message.
This is how I initialize the CAN and the IRQHandlers :
---------------------------------------------------------------------------------------
/* Interrupt handlers. */
extern "C" void CAN1_IRQHandler(void)
{
MISRAC_DISABLE
OS_EnterInterrupt();
can1.interrupt_handler();
OS_LeaveInterrupt();
MISRAC_ENABLE
}
extern "C" void CAN2_IRQHandler(void)
{
MISRAC_DISABLE
OS_VFP_Save();
OS_EnterInterrupt();
can2.interrupt_handler();
OS_LeaveInterrupt();
OS_VFP_Restore();
MISRAC_ENABLE
}
/**
* Init method for CAN
*/
void imx1062_can_t::init(uint32_t bitrate)
{
OS_IncDI(); /*disable interrupts*/
/* Init FlexCAN module. */
FLEXCAN_GetDefaultConfig(&flexcanConfig);
FLEXCAN_Init(this->can_ptr, &flexcanConfig, 40000000U);
NVIC_SetPriority(CAN2_IRQn, 5u);
NVIC_EnableIRQ(CAN2_IRQn);
/* Setup RX message buffer to receive any ID */
setupRxMessageBuffer(kFLEXCAN_FrameFormatStandard, kFLEXCAN_FrameTypeData);
/* Set IMASK such that an interrupt is triggered on message receive in message buffer MESSAGE_OB_RX (community.nxp.com/thread/459431)*/
this->can_ptr->IMASK1 = 1 << MESSAGE_OBJ_RX;
OS_DecRI(); /*enable interrupts*/
}
------------------------------------------------------------------------------------------------------------
Since in the method interrupt_handler() I make some calls to OS functions (like OS_PutMail used for mailboxes) If I'm not mistaken I have to tell the OS that I'm within an interrupt, with the methods OS_EnterInterrupt() and OS_LeaveInterrupt().
However, when OS_EnterInterrupt() gets executed, it throws a status error. I don't know where it is thrown because I cannot debug inside these methods.
I saw some other threads in this community about my same problem, I tried to do what they tell to do:
1) set the priority to a value higher then 127
2) try to use the 'ARM' version of the methods to enable the interrupt
//OS_ARM_InstallISRHandler(CAN2_IRQn, (OS_ISR_HANDLER*) CAN2_IRQHandler);
//OS_ARM_ISRSetPrio(CAN2_IRQn, 130); // Set prio < 128
//OS_ARM_EnableISR(CAN2_IRQn);
But it didn't work.
How can I fix it?
thank you in advance,
Giacomo