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

need some basic help about interrupts

Posted by umux on October 1, 2007
hello everyone

I've read the online documentation and also browsed this forum for info about freeRTOS + interrupts but I still miss some things. I'm working with the LPC2368 at the moment.
So here are my questions:

- to "install" an interrupt, you register it in the VIC. Do I also have to do something for the RTOS to "know" this interrupt?
- what do I have to look at when giving the ISR priorities? whats the impact for ISR's that have higher/lower priority than the OS tick?
- when I use a semaphore for synchronizing a task with an ISR (and do the actual data processing within the task. as it was suggested in the API doc), should I always call portTaskYield() or how can I ensure that the task which is related to the interrupt is being scheduled as soon as possible? or does the scheduler do that by default?

would be nice if someone could help me!
thanks

RE: need some basic help about interrupts

Posted by Richard on October 2, 2007
> - to "install" an interrupt, you register it in the VIC. Do I
> also have to do
> something for the RTOS to "know" this interrupt?

No - registering it with the VIC will cause the interrupt to fire (presuming it is configured correctly :o) - if this interrupt is not going to cause a context switch then you can just write the interrupt as per any other (refer to the compiler documentation). If this interrupt is potentially going to cause a context switch then you have to construct the interrupt as per the documentation page for the port you are using. Different compilers require slightly different syntax. You will also be able to refer to the demo application for your port for an example of how to switch context from within an interrupt.


> - what do I have to look at when giving the ISR priorities?
> whats the impact
> for ISR's that have higher/lower priority than the OS tick?

Unless you implement a nesting scheme then there the only effect the priorities have is when the kernel chooses which of a number of pending interrupts should be serviced first. If you are implementing a nesting scheme then interrupts that use the API must run at the same priority as the kernel tick.


> - when I use a semaphore for synchronizing a task with an ISR
> (and do the actual
> data processing within the task. as it was suggested in the
> API doc), should
> I always call portTaskYield() or how can I ensure that the
> task which is related
> to the interrupt is being scheduled as soon as possible? or
> does the scheduler
> do that by default?


As per question one above - you can cause a context switch within an interrupt by following the example given in the demo application. When you do this the interrupt will automatically return to the highest priority task in the system that is able to run. The interrupt can interrupt a low priority task, then return directly to a higher priority task if one is readied from within the interrupt. This occurs automatically when following the examples - so you don't have to worry about anything other than the priorities you assign to your tasks.

Regards.

RE: need some basic help about interrupts

Posted by biker126 on October 2, 2007
thanks already for the info!

do you have any specific file/function(isr) in mind which is a good example (in the demo)?

I'll check the emac ISR and the OS timer tick ISR (if I find it...) but maybe there are some better ones?

RE: need some basic help about interrupts

Posted by Borut on October 3, 2007
You can check the LPC2148 demo for eg. Rowley (i'm using this one) and there is a mainISR that set a semaphore when a button is presses (this button is on external interrupt). Hope this helps.

Best regards,

Borut

RE: need some basic help about interrupts

Posted by umux on October 4, 2007
I checked the various ISR examples and if I get it right I need to call "portENTER_SWITCHING_ISR()" at start and "portEXIT_SWITCHING_ISR( true/false)" at the end? for ARM7 LPC2368 with GCC that is.

I made a timer1 ISR (or rather: copied it from a working non-freeRTOS project) but the system crashes.

the only difference I notice is that my ISR is defined as " __attribute__ ((interrupt("IRQ"))) whereas the ISR in the freeRTOS demos are all defined as __attribute__ ((naked)).

I googled those 2 attributes and if I get it right the "IRQ" tells the compiler to produce enter/exit code (i.e. save the current register content onto stack, save PC etc) whereas "naked" tells the compiler that this function doesnt have/need ANY entry stuff - since its provided from the programmer.

so am I right to guess that those 2 atrributes are exactly the opposite and thas portENTER/EXIT_SWITCHING_ISR() provides the enter exit code? (sound logic :-)). so maybe with portENTER_SWITCHING_ISR() AND __attribute__"IRQ" I get a conflict and thus the system crashes?

RE: need some basic help about interrupts

Posted by Richard on October 4, 2007
You are correct. This is explained in the "Interrupt Service Routine" section of the page: http://www.freertos.org/portlpc2106.html

Regards.

RE: need some basic help about interrupts

Posted by umux on October 4, 2007
I've never checked that site so far because I thought "it's a wrong LPC, so it's not usefull for me" - seems I was wrong :-)


[ 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