Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

Pending Interrupt Causes Crash

Posted by mkrug on August 24, 2007
Hello,

I did a small port to the HC12 (that has only minor differences to the existing HCS12 Port).
My application communicates on the CAN Bus. As long as the CAN load can be handled everything works fine. If I increase the CAN load so that I got an overrun interrupt pending while I am still processing the receive interrupt the application crashes. If I just disable the overrun interrupt everything is fine again. However I like to get notice if an overrun occurs by increasing an counter within the overrun ISR. I copied fragments of the two ISR to make it more clear what I programmed.
Does anyone has an idea what I did wrong ?

Best Regards
Markus

/* receive ISR */
ISR(CAN0_recv_ISR)
{
static unsigned char xYieldRequired = pdFALSE;
C0RFLG = C0RFLG | 0x01; /* Reset receive flags */
switch (IDHIT)
{
case 0x00:
{
/* CAN ID 0x100 was received */
xYieldRequired = xTaskResumeFromISR(CAN_ID100_TASK_handle);
break;
}
default:
break;
}
if( xYieldRequired == pdTRUE )
portTASK_SWITCH_FROM_ISR();
}

/* overrun ISR */
ISR(CAN0_error_ISR)
{
static int counter = 0;
C0RFLG = C0RFLG | 0x02; /* reset overun flags*/
counter ++
}


RE: Pending Interrupt Causes Crash

Posted by Dave on August 26, 2007
Don't know about the HC12, but you CAN0_recv_ISR could probably benefit from using a binary semaphore in place of the xTaskResumeFromISR() call. Here is an extract from the xTaskResumeFromISR() documentation.

"vTaskResumeFromISR() should not be used to synchronise a task with an interrupt if there is a chance that the interrupt could arrive prior to the task being suspended - as this can lead to interrupts being missed. Use of a semaphore as a synchronisation mechanism would avoid this eventuality"

Look at the example on http://www.freertos.org/a00124.html and notice that the semaphore is only taken in the task and only given in the interrupt. This is the recommended method.

RE: Pending Interrupt Causes Crash

Posted by mkrug on August 27, 2007
I changed the mechanism to semaphore (as you described). My proplem disappeared !!! Does anyone know what will happen if a running task gets interrupted by an interrupt service routine that starts exactly this task again. Do I then have two instances of the same task ? Or is the interrupted task just canceled and thrown away ?
Best Regards
Markus


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists