Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


PIC32MX Port Interrupts question

Posted by reSpawn on January 17, 2011
I downloaded the FreeRTOS port and I made a simple interrupt driven UART. While looking through the example I noticed that the demo defines an InterruptHandler and an InterruptWrapper. The wrapper is declared as an interrupt like this void __attribute__( (interrupt(ipl2), vector(_UART1_VECTOR))) vU1InterruptWrapper( void ); and is defined in a .S file like this:

.set noreorder
.set noat
.ent vU1InterruptWrapper


jal vU1InterruptHandler

.end vU1InterruptWrapper

The InterruptHandler is a regular function ( void vU1InterruptHandler(void) ). As far as I know, the compiler generates prologue and epilogue for functions with the interrupt attribute (there is an attribute which tells him not to) and I'm worried that what I'm actually getting here, is saving the context twice, and restoring it twice.
Any thoughts?

RE: PIC32MX Port Interrupts question

Posted by Richard on January 17, 2011
I'm not quite following your question here.

The wrapper is an assembly function, so not compiled at all and will therefore not have a compiler generated prologue or epilogue sequence. The FreeRTOS provided prologue/epilogue in the portSAVE_CONTEXT() and portRESTORE_CONTEXT() macros switches the stack to an interrupt stack to save RAM (each task does not need to have a stack large enough to handle all the nested interrupts).

The function vU1InterruptHandler is just a standard function. The prologue generated for that will be much smaller than that generated for an interrupt function written in C, and will use the interrupt stack, not the task stack.

Hopefully I will have answered your question but I'm not sure. In any case, if you want to know what is being saved and restored by the compiler just look at the code it generates.


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

Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS v10.2.0 is available for immediate download. MIT licensed, and including RISC-V and ARMv8-M (Cortex-M33) demos.

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


FreeRTOS and other embedded software careers at AWS.

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Cadence Tensilica Cortes

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers





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

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

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner