Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


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 ]    [ Privacy ]    [ Sitemap ]    [ ]


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner