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

AT91SAM7X256 port interrupt problem

Posted by Adam Turowski on February 17, 2009
Hi all !!!
I am in the middle of getting myself familiar with AT91SAM7X256 port of FreeRTOS. I have found one thing that in my opinion prevents kernel from running (or possibly I don't understand something). When FreeRTOS is configured with
#define configUSE_PREEMPTION1
AIC vector is set to point to vPreemptiveTick function when PIT interrupt event occurs (line 227 in port.c file) The problem is that there is no IRQ interrupt handler which gets AIC interrupt vector by means of reading AT91C_AIC_IVR register.

When FreeRTOS is configured to DO NOT use preemption, PIT interrupt is correctly tied to IRQ (line 136 of portISR.c file), but IRQ handler still is not reading AT91C_AIC_IVR register.

Am I missing something?

Best regards,
Adam

RE: AT91SAM7X256 port interrupt problem

Posted by Dave on February 17, 2009
The IVR is read directly by the IRQ interrupt so when an interrupt fires the processor jumps directly to the handler. Look in the startup/boot .s file at where the IRQ interrupt is set up.

RE: AT91SAM7X256 port interrupt problem

Posted by Adam Turowski on February 17, 2009
Yes, you are right. Thank you for the answer.

But this leads to next question :-)
Acording to ARM7TDMI documentation at the end of ISR handler SPSR is copied to CPSR(and processor mode is changed) when something is written to PC (R15) - for example use of SUB PC,LR, #4 is suggested. If you call a function in ISR, the return address is placed in LR (R14) - BL instruction. If you want to return from this function to "main" ISR, you have to write return address to PC (R15) which will also copy SPSR to CPSR. This copy can cause change processor mode to one before interrupt event, but all of these will happend at the return from function NOT the end of ISR.

How ISR in FreeRTOS deals with such situation when there is a need to call some functions during ISR?

Best regards,
Adam

RE: AT91SAM7X256 port interrupt problem

Posted by Adam Turowski on February 17, 2009
Yes, you are right. Thank you for the answer.

But this leads to next question :-)
Acording to ARM7TDMI documentation at the end of ISR handler SPSR is copied to CPSR(and processor mode is changed) when something is written to PC (R15) - for example use of SUB PC,LR, #4 is suggested. If you call a function in ISR, the return address is placed in LR (R14) - BL instruction. If you want to return from this function to "main" ISR, you have to write return address to PC (R15) which will also copy SPSR to CPSR. This copy can cause change processor mode to one before interrupt event, but all of these will happend at the return from function NOT the end of ISR.

How ISR in FreeRTOS deals with such situation when there is a need to call some functions during ISR?

Best regards,
Adam

RE: AT91SAM7X256 port interrupt problem

Posted by Adam Turowski on February 17, 2009
Maybe my question is not clear enough... Let me put it this way:

In order to correctly end ISR, SPSR_irq register should be copied to CPSR. I can not see this happening when I look through disassembly code for ISR. When does it happen?

RE: AT91SAM7X256 port interrupt problem

Posted by Adam Turowski on February 17, 2009
I found the answer: the problem was in disassembler mnemonic representation, which doesn't show that the S bit in instruction was set.

The final conclusion is when you define the function attribute as interrupt, compiler will take care about setting bit S during return from interrupt. Normal function return always uses instruction with S bit cleared which prevents SPSR->CPSR copy.


[ 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