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

H8S Interrupt Mode 2

Posted by Brad R on April 4, 2010
I had a problem getting the H8/S port to run on an H8S/2212 -- it kept crashing, with even the simplest of tasks (flashing an LED). Working through the FreeRTOS code, I finally discovered that as distributed, it supports only Interrupt Control Mode 0. We're using Interrupt Control Mode 2 (prioritized interrupts) in our project. Here's the fix, if anyone else needs it:

In portmacro.h, I added a new #define portINTERRUPT_MODE_2 and then changed the critical section macros as follows:

/* define the following if Interrupt Control Mode 2 is used */
#define portINTERRUPT_MODE_2

/*-----------------------------------------------------------*/
#ifdef portINTERRUPT_MODE_2

/* Critical section handling. */
#define portENABLE_INTERRUPTS()asm volatile( "ANDC#0xF8, EXR" );
#define portDISABLE_INTERRUPTS()asm volatile( "ORC #0x07, EXR" );

/* Push the EXR then disable interrupts. */
#define portENTER_CRITICAL() asm volatile( "STCEXR, @-ER7" ); \
portDISABLE_INTERRUPTS();

/* Pop the EXR to set the interrupt masking back to its previous state. */
#define portEXIT_CRITICAL() asm volatile( "LDC @ER7+, EXR" );

#else

/* Critical section handling. */
#define portENABLE_INTERRUPTS()asm volatile( "ANDC#0x7F, CCR" );
#define portDISABLE_INTERRUPTS()asm volatile( "ORC #0x80, CCR" );

/* Push the CCR then disable interrupts. */
#define portENTER_CRITICAL() asm volatile( "STCCCR, @-ER7" ); \
portDISABLE_INTERRUPTS();

/* Pop the CCR to set the interrupt masking back to its previous state. */
#define portEXIT_CRITICAL() asm volatile( "LDC @ER7+, CCR" );

#endif
/*-----------------------------------------------------------*/


In function pxPortInitialiseStack, in file port.c, I changed the CCR initialization as follows:

/* Followed by the CCR. */
pxTopOfStack--;
*pxTopOfStack = portINITIAL_CCR;

/* If H8S interrupt mode 2 is used, we also need to push EXR */
#ifdef portINTERRUPT_MODE_2
pxTopOfStack--;
*pxTopOfStack = 0;
pxTopOfStack--;
*pxTopOfStack = portINITIAL_EXR;
#endif


with this at the top of the file:

/* If interrupt control mode 2 is used, the interrupt stack is different */
#define portINITIAL_EXR ( ( portSTACK_TYPE ) 0x00 )

RE: H8S Interrupt Mode 2

Posted by Brad R on April 4, 2010
Sorry, somehow my "code" tags didn't work, and I don't see how to edit the post. I hope the code fragments are readable.


[ 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