Hello,
I’am doing a project about the CAN bus using the FreeRTOS in PIC18F, but I face with a problem in the interrupt;
The PIC18 does allow two priorities of interrupt. The project is set up to use compatibility mode, so I make my own routine of interrupt for receiving the message in bus CAN, just after the routine of prvTickISR, and the problem is that if I switch the context in the routine, PIC18 will not receive the message, the program will entrer the block of vListRemove() and vListInsert() (in fonction of vTaskIncrementTick() -> prvCheckDelayedTasks();), and I see that the number of the list is so big, about 0x69, but I just have three tasks;
I don’t understand why in the routine prvTickISR, it works to switch the context, but in my own routine, il doesn’t work at all.
Thanks in advance four your attention and work.
static void prvTickISR( void )
{
/* Interrupts must have been enabled for the ISR to fire, so we have to
save the context with interrupts enabled. */
portSAVE_CONTEXT( portGLOBAL_INTERRUPT_FLAG );
PIR3bits.CCP1IF = 0;
/* Maintain the tick count. */
vTaskIncrementTick();
#if configUSE_PREEMPTION == 1
{
/* Switch to the highest priority task that is ready to run. */
vTaskSwitchContext();
}
#endif
portRESTORE_CONTEXT();
}
the routine like that doesn’t work:
static void vCANRxISR (void)
{
portSAVE
CONTEXT(portGLOBALINTERRUPT_FLAG);
PIR5bits.RXB0IF = 0;
xSemaphoreGiveFromISR(xBinarySemaphoreCANRecv,&xHigherPriorityTaskWoken);
vTaskSwitchContext();
portRESTORE_CONTEXT();
}
static void vCANRxISR (void)
{
PIR5bits.RXB0IF = 0;
xSemaphoreGiveFromISR(xBinarySemaphoreCANRecv,&xHigherPriorityTaskWoken);
taskYield();
}
the routine like that work fine:
static void vCANRxISR (void)
{
PIR5bits.RXB0IF = 0;
xSemaphoreGiveFromISR(xBinarySemaphoreCANRecv,&xHigherPriorityTaskWoken);
}