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

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