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

high priorized isr in arm 7

Posted by i_stolze on July 24, 2009
I'm using FreeRTOS 5.3 on a TMS470 (ARM7). I want to use FIQ (high piorized interrupt) which can interrupt normal IRQs using portSAVE_CONTEXT() and portRESTORE_CONTEXT() and can interrupt the OS-ISR vPortYieldProcessor(). In the FIQ is no context switch. possible or desired.
I have used __attribute__ ((interrupt ("FIQ"))) of the arm-elf-gcc (GCC) 4.1.2 (WinARM 4/2007)for the fiq, but i have some trouble on starting the application. After some (10 to 50) reboots the application runs fine. I'm not able to determine the reason for reboots exactly, but I gues the reason is the register saving and restoring of the fiq.
The gcc generates following code for the FIQ:

sublr, lr, #4
stmfdsp!, {r0, r1, r2, r3, lr}
blRtiTimer2Isr
ldmfdsp!, {r0, r1, r2, r3, pc}^

What's wrong?

RE: high priorized isr in arm 7

Posted by Richard on July 25, 2009
The FIQ mode has some registers all to itself, the compiler should know which to save and restore but the __attribtute__ features of GCC are notoriously problematic.

As an aside, check the definitions of portENABLE_INTERRUPTS and portDISABLE_INTERRUPTS (or what ever is used to disable and enable interrupts in critical sections) to ensure it only manipulates the IRQ bit and not the FIQ bit.

Regards.

RE: high priorized isr in arm 7

Posted by incrediball on July 26, 2009
I didn't trust the interrupt attributes when I did this after reading about all the problems that others had with them so I coded the entry and exit code myself. This is what I did and it seems to work well:

Firstly use __attribute__((naked)) to ensure there is no automatic entry & exit code.

Entry code:

// Save context for FIQ interrupt. Left in FIQ mode with F & I bits set (all interrupts disabled)
asm volatile (
"stmfdsp!, {r0-r7,lr}"// store unbanked registers and lr
);

Exit code:
asm volatile (
"ldmiasp!, {r0-r7,lr}\n\t"// restore unbanked registers and lr
"subspc, lr, #4"// Restore the Program Counter using the LR_fiq directly into the PC
);

The whole function is expected to run in ARM mode.

Make sure you have defined a stack and a vector for the FIQ interrupt in your startup code. Richard's tip about disabling/enabling interrupts and critical sections is important since you probably don't want high latencies. The FIQ should be able to interrupt critical sections but make sure the FIQ does not interact with FreeRTOS or anything else that the critical sections are supposed to protect.


[ 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