Hello
I work with S32K144 processor. I'm using Freertos. I'm using an interrupt for Can RX. When the RX interrupt occurs, I send a notify to a task. But when I send notify, I get stuck in the "portFORCE_INLINE static void vPortRaiseBASEPRI( void)" function.
CAN_Init(&can_pal1_instance, &can_pal1_Config0);
CAN_InstallEventCallback(&can_pal1_instance, CAN_TX_RX_Callback, NULL);
can_recvtask_handle = xTaskCreateStatic(CAN_RecvTask,
APP_CAN_RECV_TASK_NAME,
APP_CAN_RECV_TASK_STACK,
NULL,
APP_CAN_RECV_TASK_PRIO,
xRecvStack, /* Array to use as the task's stack. */
&xRecvTaskBuffer);
void CAN_TX_RX_Callback(uint32_t instance, can_event_t eventType, uint32_t objIdx, void *driverState)
{
/*check and handle the RX complete event*/
if (CAN_EVENT_RX_COMPLETE == eventType) {
CAN_Receive(&can_pal1_instance, objIdx, &rx_msg);
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
xTaskNotifyFromISR(can_recvtask_handle, 0, eNoAction, &xHigherPriorityTaskWoken); // The function that encounters the error.
if (xHigherPriorityTaskWoken) {
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
}
}
}
static void CAN_RecvTask(void *Params)
{
(void)Params;
while (pdTRUE) {
xTaskNotifyWait(0, 0, eNoAction, portMAX_DELAY);
J1939_Parser(rx_msg.id, &(rx_msg.data[0]));
}
}
xTaskNotifyFromISR(can_recvtask_handle, 0, eNoAction, &xHigherPriorityTaskWoken) is the function that falls into error.
I found out that this is an interrupt priority error. In another function, I was able to solve this problem by setting the interrupt priority.
http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html
The code block below works without any issues.
#define LZ_PORT_IRQN PORTD_IRQn
#define LZ_PORT_IRQN_PRI (1)
app_status_t GPIO_install_int (void)
{
/* Install LZ Button & INT interrupt handler */
INT_SYS_InstallHandler(LZ_PORT_IRQN, RF_Instance_Int_Handler, (isr_t *)NULL);
/* Enable LZ Button interrupt handler */
INT_SYS_EnableIRQ(LZ_PORT_IRQN);
INT_SYS_SetPriority(LZ_PORT_IRQN, LZ_PORT_IRQN_PRI);
if (INT_SYS_GetPriority(LZ_PORT_IRQN) != LZ_PORT_IRQN_PRI) {
return APP_STATUS_FAIL;
}
return APP_STATUS_OK;
}
void RF_Instance_Int_Handler (void)
{
uint32_t u32Flags;
u32Flags = GPIO_AML_GetInterruptFlags(SW_INT_LZ_INSTANCE);
/* Check if interrupt comes from LZ INT pin */
if (u32Flags & (1 << LZ_INT_PIN_NB)) {
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
xTaskNotifyFromISR(RF_TaskHandle, 0, eNoAction, &xHigherPriorityTaskWoken);
if (xHigherPriorityTaskWoken) {
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
}
GPIO_AML_ClearInterruptFlags(SW_INT_LZ_INSTANCE, LZ_INT_PIN_NB);
}
}
But I couldn't set this priority for Can interrupt. How can I set this priority for CAN RX, or what other solutions are there for this problem?