Quality RTOS & Embedded Software

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




Loading

PIC32MZ EF with FPU AddressErrorException in isr

Posted by poweruli on March 28, 2017

Hello,

the xISRStack needs to be 8 Byte aligned for PIC32 MZ EF with FPU and it is not 8 byte aligned.

Error occurs only when the hardware floating point option is released in the compiler.

The MIPS® Architecture For Programmers manual is written: Restrictions: An AddressErrorException occurs if EffectiveAddress2..0 ≠ 0 (not doubleword-aligned).

Original FreeRTOS V9.00 Source: File port.c Line 192:

StackTypet xISRStack[ configISRSTACKSIZE ] = { 0 }; const StackTypet * const xISRStackTop = &( xISRStack[ configISRSTACKSIZE - 7 ] );

My suggestion to improve is :

StackTypet attribute ((aligned (8))) xISRStack[ (configISRSTACK_SIZE & 0xFFFFFFFE) ] = { 0 }

const StackTypet * const xISRStackTop = &( xISRStack[ (configISRSTACK_SIZE & 0xFFFFFFFE) - 8 ] );

Best regards,

Uli


PIC32MZ EF with FPU AddressErrorException in isr

Posted by rtel on March 28, 2017

Hi Uli - thanks for taking the time.

This problem was already noted, although the fix in not publicly available yet. The relevant part of the updated code is below. I would be grateful if you could try it and confirm it fixes your issue. The original code is commented out, and the replacement code following immediately after:

/* The stack used by interrupt service routines that cause a context 
switch.  8
byte alignment is required to allow double word floating point stack pushes
generated by the compiler. */
//StackType_t xISRStack[ configISR_STACK_SIZE ] = { 0 };
StackType_t xISRStack[ configISR_STACK_SIZE ] __attribute__ ( ( aligned( 
8 ) ) ) = { 0 };

/* The top of stack value ensures there is enough space to store 6 
registers on
the callers stack, as some functions seem to want to do this. */
//const StackType_t * const xISRStackTop = &( xISRStack[ 
configISR_STACK_SIZE - 7 ] );
const StackType_t * const xISRStackTop = &( xISRStack[ 
configISR_STACK_SIZE - 8 ] );

PIC32MZ EF with FPU AddressErrorException in isr

Posted by poweruli on March 29, 2017

Hi Real Time Engineers,

this code fixed the issue and it's semilar to my suggestion, excecpt the optional mask (configISRSTACKSIZE & 0xFFFFFFFE). I have made this to ensure that any defenition of configISRSTACKSIZE size will work. Default is 400 and it's ok, but odd sizes may result in 4 Byte aligned top of stack. An additional information text in the FreeRTOSConfig.h would also be useful.

Thank you also for your quick response!


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




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

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

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