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

portEND_SWITCHING_ISR

Posted by rrrum on March 2, 2016

Hello,

In many examples I see "portENDSWITCHINGISR( xHigherPriorityTaskWoken );" placed as a last line of interrupt routine. This is not always straightforward. In some more complex interrupt handler user may want to put

xSemaphoreGiveFromISR( xSemaphoreMODBUSprocess, &xHigherPriorityTaskWoken );

in some function, maybe after that call some other functions before exiting handler.

So the question is can I put "portENDSWITCHINGISR( xHigherPriorityTaskWoken );" after xSemaphore... but not as a last line of handler. Will it work as intended?

Thanks


portEND_SWITCHING_ISR

Posted by rtel on March 2, 2016

(or portYIELDFROMISR())

Will it work as intended?

Depends on which port you are using.


portEND_SWITCHING_ISR

Posted by rrrum on March 3, 2016

I don't understand your answer, can you elaborate more.

I am using CORTEX M4 port of XMC on GCC.

here is my function

~~~~ void syssemsignalisr(syssemt *sem) { portBASETYPE xHigherPriorityTaskWoken = pdFALSE;

xSemaphoreGiveFromISR(*sem, &xHigherPriorityTaskWoken );
portEND_SWITCHING_ISR( xHigherPriorityTaskWoken );

}

~~~~ which is used as folowing handler

~~~~ void ETH00IRQHandler(void) { uint32_t status;

status = XMCETHMACGetEventStatus(&ethmac);

if (status & XMCETHMACEVENTRECEIVE) { syssemsignalisr(&ethrx_semaphore); }

XMCETHMACClearEventStatus(&ethmac, status); }

~~~~


portEND_SWITCHING_ISR

Posted by rtel on March 3, 2016

I don't understand your answer, can you elaborate more.

I said "Depends on which port you are using." because, the answer to your question depends on which port you are using, and as you didn't say, I couldn't answer the question.

If you are using a Cortex-M4 port then you can call portENDSWITCHINGISR or portYIELDFROMISR at any time - it does not have to be at the end of the ISR.


portEND_SWITCHING_ISR

Posted by richard_damon on March 4, 2016

If I remember right, on the M4 the portYIELDFROMISR triggers a lowest priority interrupt to cause the task switch, which will be blocked by the current ISR running, so exactly when that interrupt is triggered doesn't matter.

On the other hand, in the PIC24 port, the portYIELDFROMISR actually does the task switch, and continues execution at that task, and the code that follows isn't executed until the original task gets switched back to, so it really does need to be the very last code in the ISR.

If you wanted to write you ISR so it can work on system like the latter, then any function that the ISR calls which might set the HigherPriorityTaskWasWoken flag, needs to be passed the flag so it can pass that to the API, and the ISR tests it as its last step.


[ 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