skv19 wrote on Tuesday, July 03, 2012:
Hi Richard,
I have a similar problem with CAN interrupt and couldn’t figure out what is wrong.
Here is my code design:
///////CAN Receive interrupt////////////////////
{
CAN_Receive(CAN1, CAN_FIFO0, &RxMsg);
/***Do some processing on received message***/
portBASE_TYPE xHigherPriorityTaskWoken = 0;
xSemaphoreGiveFromISR(SEM_DEVICE_COMP_TASK_ID, &xHigherPriorityTaskWoken);
}
//////Task waiting on semaphore////// - Task created using “xTaskCreate()” & priority set as “3”, Stack size as 128 bytes
{
Wakes up this task and process received data & do a CAN Tx message which causes other node to send back another CAN message
}
/////////////////CAN interrupt is set as follows///////////////
{
NVIC_InitTypeDef NVIC_InitStructure;
NVIC_InitStructure.NVIC_IRQChannel = USB_LP_CAN1_RX0_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = configLIBRARY_KERNEL_INTERRUPT_PRIORITY;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
Also used NVIC_PriorityGroupConfig( NVIC_PriorityGroup_4 );
Used defaults settings for Freertos as below:
/* This is the raw value as per the Cortex-M3 NVIC. Values can be 255
(lowest) to 0 (1?) (highest). */
#define configKERNEL_INTERRUPT_PRIORITY 255
#define configMAX_SYSCALL_INTERRUPT_PRIORITY 191 /* equivalent to 0xb0, or priority 11. */
/* This is the value being used as per the ST library which permits 16
priority values, 0 to 15. This must correspond to the
configKERNEL_INTERRUPT_PRIORITY setting. Here 15 corresponds to the lowest
NVIC value of 255. */
#define configLIBRARY_KERNEL_INTERRUPT_PRIORITY 15
In a slower message communication it works, but if I send lots of messages to STM32 it fails. It doesn’t receive all & CAN receive interrupt doesn’t work anymore.
Ideally I want ISR to be completed & then run the task. Don’t want to interrupt ISR.
Any help would be appreciated.
Thanks,
SKV