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

SWINTR v. trap in RX600 GCC port

Posted by https://www.google.com/accounts on September 26, 2011
The definition for portYIELD() for the RX600 port in V7.0.2, (FreeRTOS/Source/portable/GCC/RX600/portmacro.h) looks like this:
/* The location of the software interrupt register.  Software interrupts use
vector 27. */
#define portITU_SWINTR ( ( unsigned char * ) 0x000872E0 )
#define portYIELD() *portITU_SWINTR = 0x01; portNOP(); portNOP(); portNOP(); portNOP(); portNOP()

This raises several questions:

  • First, why not use a trap instruction (e.g: "INT #27") for portYIELD() (as was done for the H8S port for example)?

  • Second, what bug or (apparently undocumented) feature requires the use of no less than 5 NOPs after setting the SWINTR register?

  • Lastly, shouldn't it be enclosed in a do{}while(0) block? Or better yet, shouldn't it be a static inline function? As is, an otherwise perfectly reasonable code snipit such as
    if (foo) portYIELD(); else bar();
    will not even compile.


thanks in advance,
brad

RE: SWINTR v. trap in RX600 GCC port

Posted by Richard on September 26, 2011
First, why not use a trap instruction (e.g:  "INT #27") for portYIELD() (as was done for the H8S port for example)?


The asynchronous software interrupt is a far more powerful method, and included in the core for this purpose (as it is in the Cortex-M). I believe it was an addition that came to the architecture after the RX610 devices.

Using a synchronous trap has two disadvantages in this case. First, supporting interrupt nesting is much more complex and requires much more code. Second, as a result of the first, interrupt response times are adversely effected.


“Second, what bug or (apparently undocumented) feature requires the use of no less than 5 NOPs after setting the SWINTR register?”


I would have to check the data sheets to answer that one. It might be preventing execution of instructions in branch delay slots, or pipelines. I use a *lot* of different cores and cannot recall offhand. It might be that the NOPs are no longer needed even.


“Lastly, shouldn't it be enclosed in a do{}while(0) block?”


I take the point about the hanging else. My coding standard will not permit an if without an explicit {} block, but granted the code provided should allow for use in everybody's applications. The while(0) solution is a non starter for this proect. First, it breaches nearly all formal coding standards. Second it will cause "condition is always false" warnings from the compiler in a lot of cases (depending on the warning level - I tend to compile with very pedantic warnings).

Regards.


[ 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