FreeRTOS on SAM7x: Task only run once

Hi all, i am currently working on a project, where i have one task and one ISR. without the ISR, the task is run continously. But if the interrupt is enabled the task is only run once. here is my ISR: void vCANISR( void ) __attribute__((naked)); void vCANISR( void ) {     portENTER_SWITCHING_ISR();     static volatile unsigned long ulIntStatus, ulIntMask, msgstatus;     static volatile unsigned char TEC, REC;     //portBASE_TYPE xSwitchRequired = pdFALSE;     ulIntStatus = AT91C_BASE_CAN->CAN_SR;     ulIntMask= AT91C_BASE_CAN->CAN_IMR;     ulIntStatus &= ulIntMask;         // For debug only:     TEC = (unsigned char)((AT91C_BASE_CAN->CAN_ECR & 0x00FF0000) >> 16);     REC = (unsigned char)(AT91C_BASE_CAN->CAN_ECR & 0x000000FF);         // BUS_OFF     if (ulIntStatus & AT91C_CAN_BOFF)     {         SAM7_CAN_SetCommStatus(AT91C_CAN_BOFF);     }         // ERROR_PASSIVE     if (ulIntStatus & AT91C_CAN_ERRP)     {         SAM7_CAN_SetCommStatus(AT91C_CAN_ERRP);     }         // ERROR_ACTIVE     if (ulIntStatus & AT91C_CAN_ERRA)     {         SAM7_CAN_SetCommStatus(AT91C_CAN_ERRA);     }         if (ulIntStatus & AT91C_CAN_MB0)    //TX mailbox     {          msgstatus= AT91C_BASE_CAN->CAN_MB0.CAN_MB_MSR;         if (msgstatus & AT91C_CAN_MRDY)         {             if (SAM7_CAN_IsrTxMsg(&AT91C_BASE_CAN->CAN_MB0))             {                 //queue empty                 AT91C_BASE_CAN->CAN_IDR = AT91C_CAN_MB0; //Disable Mailbox 0 IRQ             }             else             {                 //send next msg                 //AT91C_BASE_CAN->CAN_TCR= AT91C_CAN_MB0; // Transfer request                 AT91C_BASE_CAN->CAN_MB0.CAN_MB_MCR = AT91C_CAN_MTCR;    // Transfer request             }         }                 //xSwitchRequired = xSemaphoreGiveFromISR( xSemaphore, pdFALSE );     }         if (ulIntStatus & AT91C_CAN_MB1)    //RX mailbox     {        msgstatus= AT91C_BASE_CAN->CAN_MB1.CAN_MB_MSR;        if (msgstatus & AT91C_CAN_MRDY)        {            SAM7_CAN_IsrRxMsg(&AT91C_BASE_CAN->CAN_MB1);            AT91C_BASE_CAN->CAN_MB1.CAN_MB_MCR = AT91C_CAN_MTCR;    // Transfer request        }         //xSwitchRequired = xSemaphoreGiveFromISR( xSemaphore, pdFALSE );     }         if (ulIntStatus & AT91C_CAN_MB2)    //RX mailbox     {        msgstatus= AT91C_BASE_CAN->CAN_MB2.CAN_MB_MSR;        if (msgstatus & AT91C_CAN_MRDY)        {            SAM7_CAN_IsrRxMsg(&AT91C_BASE_CAN->CAN_MB2);            AT91C_BASE_CAN->CAN_MB2.CAN_MB_MCR = AT91C_CAN_MTCR;    // Transfer request        }         //xSwitchRequired = xSemaphoreGiveFromISR( xSemaphore, pdFALSE );     }     // Clear the interrupt.     AT91C_BASE_AIC->AIC_EOICR = 0;     portEXIT_SWITCHING_ISR( 0 );     //portEXIT_SWITCHING_ISR( xSwitchRequired ); } NOTE: It is not necessary for the ISR to switch context. This is only done because of earlier experience with the lwip demo for the sam7x where i had a timerISR which would halt program execution if the above syntax weren’t implemented (portEXIT_SWITCHING_ISR() and portEXIT_SWITCHING_ISR( 0 )). is there another way to do this differently ?

FreeRTOS on SAM7x: Task only run once

If you do not need a context switch then you can defined the ISR just as a normal ISR – without the naked attribute, and without the ENTER_SWITCHING_ISR() EXIT_SWITCHING_ISR() macros.  You use a different attribute which I think is just "IRQ".  From memory the documentation page on the FreeRTOS site shows you the syntax.  Look at one of the other ARM7 GCC ports documentation to see this.

FreeRTOS on SAM7x: Task only run once

Hi, i have tried that, but it didn’t work. I found that i had to disable the AT91C_CAN_ERRP interrupt. Because it kept the interrupt firing. But the interrupt is still continually run, eventhough CAN Status register is 0. And that i cant understand. Because no interrupts on the CAN bus is pending, and still the interrupt handler is executed. any help would be greatfully apprieciated. thx

FreeRTOS on SAM7x: Task only run once

Presumably you have to clear the interrupt in the CAN peripheral and in the interrupt controller.  I suspect one of these is not being done. I would suggest writing program of hello world simplicity without FreeRTOS to get the CAN interrupt working as you want.  Then once its working incorporate your ISR code into your FreeRTOS project.

FreeRTOS on SAM7x: Task only run once

>Presumably you have to clear the interrupt in the CAN peripheral and in the interrupt controller. I suspect one of >these is not being done. You were right about that. Because of my init of the CAN mail boxes an interrupt was triggered because of MRDY was set. here is the corrected code for the receive mailbox which shutsoff the mailbox0 interrupt if we are done sending messages: if (ulIntStatus & AT91C_CAN_MB0) //TX mailbox  { msgstatus= AT91C_BASE_CAN->CAN_MB0.CAN_MB_MSR; if (msgstatus & AT91C_CAN_MRDY)  { if (SAM7_CAN_IsrTxMsg(&AT91C_BASE_CAN->CAN_MB0))  { //queue empty AT91C_BASE_CAN->CAN_MB0.CAN_MB_MCR = 0;        // Clears MRDY flag AT91C_BASE_CAN->CAN_IDR = AT91C_CAN_MB0; //Disable Mailbox 0 IRQ }  else  { //send next msg //AT91C_BASE_CAN->CAN_TCR= AT91C_CAN_MB0; // Transfer request AT91C_BASE_CAN->CAN_MB0.CAN_MB_MCR = AT91C_CAN_MTCR; // Transfer request } }