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

FreeRTOS & PIC24EP & Interrupt Handling

Posted by damieneti on January 3, 2014

Hello Community,

I've been using FreeRTOS for a while now on my project and I have to say I love it.

Tough i'm facing a bug which is killing me.

My code contains a large amount of code, about 80 files and use several microchip stack and run about 10 tasks.

The problem is that about 2-3 times a day, the chip will go into an address error interrupt and I haven't really been able to find out what was the source of the problem.

I believe that this error occur at the moment of an interrupt because I've been able to reduce the occurrence of the crash be using DMA transfer in one UART which reduce the interruptoin by a factor of 80.

I've been reading a lot of example and and forum thread about it, but it seem to always have different approach about how to handle interrupt, whether use or not the taskYield, specifically on the PIC24EP.

An other point is the interrupt nesting. It is currently enabled and I haven't tested disabled. I've seen some thread about it without really an answer whether it should be kept enable or not.

This is the way I'm currently handling my DMA interrupt. I use a queue instead of a semaphore for previous code compatibility bot it does the same job.

c

void attribute((interrupt, autopsv)) _DMA1Interrupt(void) { char val = 55; IFS0bits.DMA1IF = 0; // Clear the DMA1 Interrupt Flag xQueueSendFromISR( RS485Queue, &val, NULL ); }

Some example from the RTOS library shows no task yield after the interrupt. - Shall I add the yield into each interrupt ?

c

void attribute((interrupt, autopsv)) _DMA1Interrupt(void) { char val = 55; portBASETYPE xTaskWoken; IFS0bits.DMA1IF = 0; // Clear the DMA1 Interrupt Flag xQueueSendFromISR( RS485_Queue, &val, &xTaskWoken); if( xTaskWoken ) taskYIELD(); }

  • Shall I disable Nested interrupt ?

  • Shall I add more stack space in my tasks ? I'm not a specialist of processor stack and the way RTOS works at the stack level. If two interrupt happens at the same time then the current running task would need bigger stack size ? Might my problem be related of having two interrupt (or more) at the same time and having nested interrupt use more task space than it is actually defined ?

Thanks for your help


FreeRTOS & PIC24EP & Interrupt Handling

Posted by rtel on January 3, 2014

Some example from the RTOS library shows no task yield after the interrupt. - Shall I add the yield into each interrupt ?

If you have the yield then, if writing to the queue caused a task to unblock and the unblocked task has a priority equal to or above the priority of the current task, then the interrupt will return directly to the unblocked task. If the unblocked task has urgent processing to perform, including if the unblocked task is completing the actual interrupt processing, then that is what you should do. If that is not the case then you can leave out the yield and the task will get selected at the very latest in the next tick interrupt.

Shall I disable Nested interrupt ?

As I recall the PIC24 only has a partial interrupt nesting model that does not allow interrupts that use the RTOS API to nest anyway. Is you DMA interrupt running with a priority equal to the priority of the tick interrupt? As it is using the RTOS API you must ensure this is the case. Double check the information in the "RTOS port specific configuration" section of the PIC24 documentation page.

Shall I add more stack space in my tasks ?

At least during development ensure you have the stack overflow hook defined. You can also check the free stack space manually in the debugger (because the stack is filled with 0xa5 when it is created) or using the uxTaskGetStackHighWaterMark() function.


[ 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