FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [April 2010 Threads] How to save addditional contextPosted by Yuriy Kulikov on April 16, 2010 Hello! I am using FreeRTOS on Atmega1280. portSAVE_CONTEXT() on this port pushes 32 processor registers to task stack and loads stack pointer to TCB. I have to save one additional variable from SRAM (it is RAMPZ). I have tried to add additional variable to TCB strucure to save it, but RTOS freezes after that. Also I have tried to push it on task stack. It doesn't work also (it seems that stack size is limited somehow and can only save 32 registers). Do you have any suggestions how to save this variable? Many thanks, Yurij
RE: How to save addditional contextPosted by Dave on April 16, 2010 You will need to updated portSAVE_CONTEXT() and portRESTORE_CONTEXT() to push and pop the extra registers respectively, AND update pxPortInitialiseStack() to reflect the same changes.
If you want to save the RAMPZ then I would guess you are using a part that has a three byte program counter, so you will also need to update pxPortInitialiseStack() for the extra program counter byte. I think there are ports around where this has been done. You might try avrfreaks.net.
RE: How to save addditional contextPosted by Yuriy Kulikov on April 16, 2010 Thanks davedoors! I guess it is simple to modify portSAVE_CONTEXT() and portRESTORE_CONTEXT(). But I have no idea how to modify pxPortInitialiseStack(). Should I add something like this portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters ) { //-----ORIGINAL CODE--------- ..................... *pxTopOfStack = ( portSTACK_TYPE ) 0x031;/* R31 */ pxTopOfStack--; //additional code *pxTopOfStack = ( portSTACK_TYPE ) 0x032;/* one byte more for RAMPZ */ pxTopOfStack--; return pxTopOfStack; } RAMPZ saving is requried to perform access to FLASH memory from several tasks (strings, bitmaps and tunes are stored there).
RE: How to save addditional contextPosted by Dave on April 16, 2010 That looks to be correct if RAMPZ is then the first thing to be popped from the stack in portRESTORE_CONTEXT() and the last thing to be pushed to the stack in portSAVE_CONTEXT().
You can check by placing a break point at the start of a task function (on the function name or on the opening bracket of the function) then looking at RAMPZ in the debugger to check it contains 0x32.
RE: How to save addditional contextPosted by Richard on April 16, 2010 If you have a port that is running on one of the extended AVR devices then I would like to encourage you to upload it to the FreeRTOS interactive site - see http://interactive.freertos.org
Regards.
RE: How to save addditional contextPosted by Yuriy Kulikov on April 16, 2010 richardbarry Do you mean AVR controllers with extended I/O space from $60 - $1FF in SRAM (only the ST/STS/STD and LD/LDS/LDD instructions can be used in this space)? My port is running on Atmega1280. I have used port for Atmega323 and made only some minor changes related to tick counter. Port works fine, but I want to add saving of RAMPZ and EIND during context switch. Maybe after that it will be worth uploading.
RE: How to save addditional contextPosted by Yuriy Kulikov on April 16, 2010 Thanks to everybody! Looks like it works fine now. After some testing I will upload it.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|