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

IRQ + xQueueSendFromISR

Posted by Nobody/Anonymous on March 9, 2006
I'm using the HDLC IRQ of the STR710.
In this IRQ I'm putting all the data in the queue with :
HDLC_IRQHandler()
xTaskWokenByPost = pdFALSE;
while(there is data)
xTaskWokenByPost = xQueueSendFromISR( xRxQueue, &data, xTaskWokenByPost );
if( xTaskWokenByPost )
taskYIELD();

It means that we switch context and the task which is waiting for data in the queue will wake up. But how do we clear the pending HDLC bit IRQ in the EIC if this is done after the taskYIELD?
When there is a HDLC IRQ :
- IRQHandler is called
- HDLCIRQHandler is called
- HDLC_IRQHandler() is called
- ReturnAddress is called where the Clear pending bit in EIC is done but it will never be called because we switch context before.
crt0.s :
IRQ_Addr : .long IRQHandler
HDLC_Addr : .long HDLCIRQHandler

IRQHandler:
SUB lr,lr,#4
/*; Update the link register*/
SaveContext r0,r12
/*; Save the workspace plus the current*/
/* return address lr_ irq and spsr_irq.*/
LDR lr, =ReturnAddress
/*; Read the return address.*/
LDR r0, =EIC_BASE
LDR r1, =IVR_OFFSET
ADD pc,r0,r1
/*; Branch to the IRQ handler:HDLCIRQHandler*/

ReturnAddress:
/*Clear pending bit in EIC (using IPRx)*/
LDR r0, =EIC_BASE
LDR r2, [r0, #CICR_OFFSET]
/*; Get the IRQ channel number.*/
MOV r3,#1
MOV r3,r3,LSL r2
STR r3,[r0, #IPR_OFFSET]
/* ; Clear the corresponding IPR bit.*/
RestoreContext r0,r12
/*; Restore the context and return to the..
/* ; ...program execution. */

HDLCIRQHandler:
IRQ_to_SYS
BL HDLC_IRQHandler
SYS_to_IRQ



I would like to know what is really happening with the switch context in the IRQ? ReturnAddress is called? How can we clear the HDLC IRQ?

Thanks

RE: IRQ + xQueueSendFromISR

Posted by Nobody/Anonymous on March 9, 2006
It looks like you may be using interrupt entry and exit code supplied by your compiler or silicon vendor as an example. It is best (if not essential) when using FreeRTOS that the interrupt handlers are more 'raw'. FreeRTOS assumes that the stacks in the interrupt are exactly as if the processor had just entered the interrupt, with no prior software manipulation.

Your best best is to look at the USB and UART examples in the STR7 demo and just copy them exactly. The interrupts are entered automatically from the vector table. You can clear the aic just before the switch which must be at the very end of the ISR. Make sure you copy the example exactly regarding how the vector table is loaded, the syntax of the ISR function, how and when the context is saved/restored etc.

Let us know how you get on.


[ 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