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


LPC21xx:Tick sharing ISR with other sources

Posted by Angelo De Pascale on December 29, 2007
On LPC21xx ( I use LPC2138 with GCC), the timers functions, 4xCAP and 4xMAT share a unique ISR. In my application I use all CAP and MAT functions generating ints. Using Preemptive scheduler is ok, I implemented my ISR as recommended by the documentation:

void timer0_isr_Wrapper( void ) __attribute__ ((naked));
void timer0_isr_Wrapper( void )

timer0_isr(); /* contain tick, CAP and MAT handling */


Now the part I not really understand how to implement. To use the non preemptive scheduler, no call to portSAVE_CONTEXT and portRESTORE_CONTEXT must be done in ISR. At that point, how can I implement the ISR if I need both non preemptive scheduler on MAT (periodic timer) and calls to kernel functions in others part of ISR, thus saving and restoring context.

Demo codes are not helpfull as ISR only handle Tick.

Thank you for any suggestions.


RE: LPC21xx:Tick sharing ISR with other sources

Posted by Richard on December 30, 2007
If I understand your question correctly, you are wanting to share the interrupt for all the interrupt sources, and cause a context switch from some sources but not others.

I think you can keep the interrupt entry point exactly as it is now. Saving and restoring the context does not cause a context switch in itself - a context switch will only occur if vTaskSwitchContext() is called between the save and restore macros.

To convert to use the cooperative scheduler simply call vTaskIncrementTick() for the tick interrupt - without a call to vTaskSwitchContext().


RE: LPC21xx:Tick sharing ISR with other sources

Posted by Angelo De Pascale on December 30, 2007
On LPC21xx, timers have multiple functions, Input capture, output compare and PWM. Each function can generate several interrupts but there is only one ISR per timer. So the ISR must first check wich function generate the int.

The LPC2106 confused me with the different declaration about "IRQ" or "NAKED" ISR, with or without SAVE/RESTORE context.

In my timer0_isr routine, in the part wich take care of the tick, I wrote the following code

#if configUSE_PREEMPTION == 1

My application doesn't need cooperative, as there is only one process per priority. But it is running well in both cases. I have to make more tests.



[ 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