Quality RTOS & Embedded Software

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




Loading

PIC port explanation

Posted by Richard on February 1, 2005
I have moved this message from the bug tracker list. Please do not submit bug trackers until it has been shown that a bug exists. Original message follows:

I'm not very much into pic-assembler (yet), but I believe
there is an error in the pic-port.

From port.c:

<snippet from PortSAVECONTEXT macro>
/* Save the new top of the software stack in
the TCB. */
_asm
MOVFF pxCurrentTCB, FSR0L
MOVFF pxCurrentTCB + 1, FSR0H
MOVFF FSR1L, POSTINC0
MOVFF FSR1H, POSTINC0
_endasm
}
</snippet from PortSAVECONTEXT macro>

<snippet from PortRESTORECONTEXT macro>
/* Set FSR0 to point to pxCurrentTCB-
>pxTopOfStack. */
MOVFF pxCurrentTCB, FSR0L
MOVFF pxCurrentTCB + 1, FSR0H
</snippet from PortRESTORECONTEXT macro>

I cannot believe that the code in the PortSAVECONTEXT-
macro saves something in the TCB...


RE: PIC port explanation

Posted by Richard on February 1, 2005
Here is the save context snippet with an explanation:

; Obtain the low byte of the pointer to the current
; TCB and place it in the low byte of the FSR0
; register.
MOVFF pxCurrentTCB, FSR0L

; Obtain the high byte of the pointer to the current
; TCB and place it in the high byte of the FSR0
; register.
MOVFF pxCurrentTCB + 1, FSR0H

; The FSR1 register is being used as the stack
; pointer. FSR0 now points to the current TCB
; structure - the first member of which is the top
; of stack. Store the top of stack being used into
; the TCB top of stack member.

; Move the low byte of the stack pointer into the
; TCB, then increment the pointer to the high
; byte.
MOVFF FSR1L, POSTINC0

; Move the high byte of the stack pointer into the
; TCB. The FSR0 register is pointing to the high
; byte already due to the post increment in
; the statement above.
MOVFF FSR1H, POSTINC0


RE: PIC port explanation

Posted by Marcel van Lieshout on February 3, 2005
Thanks, it starts making sense now I'm getting more and more into pic asm...


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

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