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] [August 2008 Threads] PIC18 task context is 2 bytes too longPosted by Paul_Piak on August 1, 2008 Hello,
I think 2 bytes can be removed from the PIC18 task context save/restore macros. When saving context, the FSR0 register is initialized to 0, which is the address of the first byte of the .tmpdata+.mathdata sections These 2 sections are then saved to the stack by executing an application dependent number (portCOMPILER_MANAGED_MEMORY_SIZE) of MOVFFPOSTINC0, PREINC1 instructions. After saving .tmpdata+.mathdata, the value of FSR0 is equal to the address of the last byte in .tmpdata+.mathdata This address is equal to the constant portCOMPILER_MANAGED_MEMORY_SIZE Thus, at this point the contents of FSR0 is the same for every context switch. The value is the same every time, for each task in a single application. Effectively a constant value is saved. By definition, constants don't have to be saved on a stack, since they don't unexpectedly change.
When restoring the .tmpdata+.mathdata sections from the stack, first FSR0 is initialized to the address of the last byte in .tmpdata+.mathdata This is now done by restoring FSR0 from the task stack. But we know FSR0 will always be restored to portCOMPILER_MANAGED_MEMORY_SIZE, since that is the location of the last byte of .tmpdata+.mathdata , which will be the first byte to be restored.
Total savings: 2 bytes RAM for each task stack and 2 instructions when saving the context (restoring context will be the same number of cycles because FSR0 has to be set to the constant value that was previously on the stack, but is now portCOMPILER_MANAGED_MEMORY_SIZE)
Paul
RE: PIC18 task context is 2 bytes too longPosted by Paul_Piak on August 7, 2008 Is everybody still thinking about this? If I'm not making sense, could someone tell me? Paul
RE: PIC18 task context is 2 bytes too longPosted by Richard on August 7, 2008 Sorry for the delay ... I will get around to looking at it.
Regards.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|