Quality RTOS & Embedded Software

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


Loading

Saving CRC Register on context switch

Posted by Hari on June 20, 2012
I am using MSP430F5418 with FreeRTOS 7 in medium data model.

I want to save the MSP CRC registers on FreeRTOS context switch. I edited the portext.s43 like this.

In save context macro, after pushing 15 registers to stack, I push the CRC registers. (CRCDI is the MSP register to save)

mov.w CRCD1, r15
pushx.a r15
In restore context macro, I poped the CRC just before poping the 15 registers.

popx.a r15
mov.w r15, CRCDI
It is supposed to be working , but it is not. The program control is going to unknow location.

Anybody have any Idea?

RE: Saving CRC Register on context switch

Posted by Richard on June 20, 2012
You will also have to set up the initial stack given to the task when it is created to include the additional register - otherwise, when the task first starts, the restore context macro will try and pop a register that does not exist resulting in junk in the register and a stack underflow.

Look at the function pxPortInitialiseStack() in whichever port.c file you are using.

Regards.

RE: Saving CRC Register on context switch

Posted by Hari on June 20, 2012
Thank you Richard for your reply.
In that function what should I change?

RE: Saving CRC Register on context switch

Posted by Richard on June 20, 2012
I don't know which port you are looking at, but if you look at FreeRTOS/Source/Portable/IAR/MSP430X/port.c, then assume PRELOAD_REGISTER_VALUES is set, you will see that the function writes a value for each register that is to be popped from the stack when the context is loaded. If your new register is the last thing popped from the stack, add it to the start of the list, if it is the first thing popped from the stack, add it to the end of the list.

Regards.

RE: Saving CRC Register on context switch

Posted by Hari on June 21, 2012
But PRELOAD_REGISTER_VALUES is not set in my port.c, what should I do?

RE: Saving CRC Register on context switch

Posted by Hari on June 21, 2012
I added the following at the top. before #ifdef PRELOAD_REGISTER_VALUES

*pxTopOfStack = (portSTACK_TYPE) 0xffff;
pxTopOfStack--;

#ifdef PRELOAD_REGISTER_VALUES follows

Now it is working but while restoring context, incorrect value is loaded

RE: Saving CRC Register on context switch

Posted by Hari on June 21, 2012
Ya Now it is working.

I want to save CRCRESR register also to do that.

So I need one more

*pxTopOfStack = (portSTACK_TYPE) 0xffff;
pxTopOfStack--;


for that, right?

RE: Saving CRC Register on context switch

Posted by Richard on June 21, 2012
“But PRELOAD_REGISTER_VALUES is not set in my port.c, what should I do?”


Which port are you using then?

Regards.

RE: Saving CRC Register on context switch

Posted by Hari on June 21, 2012
I'm Sorry,
I found it

RE: Saving CRC Register on context switch

Posted by Hari on June 21, 2012
I am sorry, I couldn't found the PRELOAD_REGISTER_VALUES, anywhere in the free RTOS 7.0 files.

Could you please tell me how can I delete a post from this forum?


[ 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