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

PIC18 task context is 2 bytes too long

Posted 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 long

Posted 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 long

Posted by Richard on August 7, 2008
Sorry for the delay ... I will get around to looking at it.

Regards.


[ 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