mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-19 21:11:57 -04:00
Suggested context switching for dsPIC33CK. Now compiles and links. Untested on HW.
This commit is contained in:
parent
61df9abef9
commit
33ceffd1e7
|
@ -145,6 +145,41 @@ UBaseType_t uxCriticalNesting = 0xef;
|
||||||
|
|
||||||
#endif /* defined( __dsPIC30F__ ) || defined( __dsPIC33F__ ) */
|
#endif /* defined( __dsPIC30F__ ) || defined( __dsPIC33F__ ) */
|
||||||
|
|
||||||
|
#if defined( __dsPIC33C__ )
|
||||||
|
|
||||||
|
#define portRESTORE_CONTEXT() \
|
||||||
|
asm volatile( "MOV _pxCurrentTCB, W0 \n" /* Restore the stack pointer for the task. */ \
|
||||||
|
"MOV [W0], W15 \n" \
|
||||||
|
"POP W0 \n" /* Restore the critical nesting counter for the task. */ \
|
||||||
|
"MOV W0, _uxCriticalNesting \n" \
|
||||||
|
"POP DSWPAG \n" /* See https://forums.freertos.org/t/i-have-a-problem-in-using-freertosv10-1-1-the-mcu-is-iteratively-rebooting-and-not-executing-task-function/7551 */ \
|
||||||
|
"POP DSRPAG \n" \
|
||||||
|
"POP CORCON \n" \
|
||||||
|
"POP DOENDH \n" \
|
||||||
|
"POP DOENDL \n" \
|
||||||
|
"POP DOSTARTH \n" \
|
||||||
|
"POP DOSTARTL \n" \
|
||||||
|
"POP DCOUNT \n" \
|
||||||
|
"POP ACCBU \n" \
|
||||||
|
"POP ACCBH \n" \
|
||||||
|
"POP ACCBL \n" \
|
||||||
|
"POP ACCAU \n" \
|
||||||
|
"POP ACCAH \n" \
|
||||||
|
"POP ACCAL \n" \
|
||||||
|
"POP TBLPAG \n" \
|
||||||
|
"POP RCOUNT \n" /* Restore the registers from the stack. */ \
|
||||||
|
"POP W14 \n" \
|
||||||
|
"POP.D W12 \n" \
|
||||||
|
"POP.D W10 \n" \
|
||||||
|
"POP.D W8 \n" \
|
||||||
|
"POP.D W6 \n" \
|
||||||
|
"POP.D W4 \n" \
|
||||||
|
"POP.D W2 \n" \
|
||||||
|
"POP.D W0 \n" \
|
||||||
|
"POP SR " );
|
||||||
|
|
||||||
|
#endif /* defined( __dsPIC33C__ ) */
|
||||||
|
|
||||||
#ifndef portRESTORE_CONTEXT
|
#ifndef portRESTORE_CONTEXT
|
||||||
#error Unrecognised device selected
|
#error Unrecognised device selected
|
||||||
|
|
||||||
|
@ -185,7 +220,7 @@ const StackType_t xInitialStack[] =
|
||||||
0xabac, /* TBLPAG */
|
0xabac, /* TBLPAG */
|
||||||
|
|
||||||
/* dsPIC specific registers. */
|
/* dsPIC specific registers. */
|
||||||
#if defined( __dsPIC30F__ ) || defined( __dsPIC33F__ )
|
#if defined( __dsPIC30F__ ) || defined( __dsPIC33F__ ) || defined( __dsPIC33C__ )
|
||||||
0x0202, /* ACCAL */
|
0x0202, /* ACCAL */
|
||||||
0x0303, /* ACCAH */
|
0x0303, /* ACCAH */
|
||||||
0x0404, /* ACCAU */
|
0x0404, /* ACCAU */
|
||||||
|
@ -295,8 +330,13 @@ const uint32_t ulCompareMatch = ( ( configCPU_CLOCK_HZ / portTIMER_PRESCALE ) /
|
||||||
IEC0bits.T1IE = 1;
|
IEC0bits.T1IE = 1;
|
||||||
|
|
||||||
/* Setup the prescale value. */
|
/* Setup the prescale value. */
|
||||||
|
#if defined( __dsPIC33C__ )
|
||||||
|
/* Microchip's header file p33CK128MP505.h does not have separate TCKPSx */
|
||||||
|
T1CONbits.TCKPS = 1; /* Value of 1 simply copied over from old code */
|
||||||
|
#else
|
||||||
T1CONbits.TCKPS0 = 1;
|
T1CONbits.TCKPS0 = 1;
|
||||||
T1CONbits.TCKPS1 = 0;
|
T1CONbits.TCKPS1 = 0;
|
||||||
|
#endif /* if defined( __dsPIC33C__ ) */
|
||||||
|
|
||||||
/* Start the timer. */
|
/* Start the timer. */
|
||||||
T1CONbits.TON = 1;
|
T1CONbits.TON = 1;
|
||||||
|
|
|
@ -104,3 +104,84 @@ _vPortYield:
|
||||||
.end
|
.end
|
||||||
|
|
||||||
#endif /* defined( __dsPIC30F__ ) || defined( __dsPIC33F__ ) */
|
#endif /* defined( __dsPIC30F__ ) || defined( __dsPIC33F__ ) */
|
||||||
|
|
||||||
|
#if defined( __dsPIC33C__ )
|
||||||
|
|
||||||
|
.global _vPortYield
|
||||||
|
.extern _vTaskSwitchContext
|
||||||
|
.extern uxCriticalNesting
|
||||||
|
|
||||||
|
_vPortYield:
|
||||||
|
|
||||||
|
PUSH SR /* Save the SR used by the task.... */
|
||||||
|
PUSH W0 /* ....then disable interrupts. */
|
||||||
|
MOV #32, W0
|
||||||
|
MOV W0, SR
|
||||||
|
PUSH W1 /* Save registers to the stack. */
|
||||||
|
PUSH.D W2
|
||||||
|
PUSH.D W4
|
||||||
|
PUSH.D W6
|
||||||
|
PUSH.D W8
|
||||||
|
PUSH.D W10
|
||||||
|
PUSH.D W12
|
||||||
|
PUSH W14
|
||||||
|
PUSH RCOUNT
|
||||||
|
PUSH TBLPAG
|
||||||
|
PUSH ACCAL
|
||||||
|
PUSH ACCAH
|
||||||
|
PUSH ACCAU
|
||||||
|
PUSH ACCBL
|
||||||
|
PUSH ACCBH
|
||||||
|
PUSH ACCBU
|
||||||
|
PUSH DCOUNT
|
||||||
|
PUSH DOSTARTL
|
||||||
|
PUSH DOSTARTH
|
||||||
|
PUSH DOENDL
|
||||||
|
PUSH DOENDH
|
||||||
|
|
||||||
|
|
||||||
|
PUSH CORCON
|
||||||
|
PUSH DSRPAG /* See https://forums.freertos.org/t/i-have-a-problem-in-using-freertosv10-1-1-the-mcu-is-iteratively-rebooting-and-not-executing-task-function/7551 */
|
||||||
|
PUSH DSWPAG
|
||||||
|
MOV _uxCriticalNesting, W0 /* Save the critical nesting counter for the task. */
|
||||||
|
PUSH W0
|
||||||
|
MOV _pxCurrentTCB, W0 /* Save the new top of stack into the TCB. */
|
||||||
|
MOV W15, [W0]
|
||||||
|
|
||||||
|
call _vTaskSwitchContext
|
||||||
|
|
||||||
|
MOV _pxCurrentTCB, W0 /* Restore the stack pointer for the task. */
|
||||||
|
MOV [W0], W15
|
||||||
|
POP W0 /* Restore the critical nesting counter for the task. */
|
||||||
|
MOV W0, _uxCriticalNesting
|
||||||
|
POP DSWPAG
|
||||||
|
POP DSRPAG /* See https://forums.freertos.org/t/i-have-a-problem-in-using-freertosv10-1-1-the-mcu-is-iteratively-rebooting-and-not-executing-task-function/7551 */
|
||||||
|
POP CORCON
|
||||||
|
POP DOENDH
|
||||||
|
POP DOENDL
|
||||||
|
POP DOSTARTH
|
||||||
|
POP DOSTARTL
|
||||||
|
POP DCOUNT
|
||||||
|
POP ACCBU
|
||||||
|
POP ACCBH
|
||||||
|
POP ACCBL
|
||||||
|
POP ACCAU
|
||||||
|
POP ACCAH
|
||||||
|
POP ACCAL
|
||||||
|
POP TBLPAG
|
||||||
|
POP RCOUNT /* Restore the registers from the stack. */
|
||||||
|
POP W14
|
||||||
|
POP.D W12
|
||||||
|
POP.D W10
|
||||||
|
POP.D W8
|
||||||
|
POP.D W6
|
||||||
|
POP.D W4
|
||||||
|
POP.D W2
|
||||||
|
POP.D W0
|
||||||
|
POP SR
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
.end
|
||||||
|
|
||||||
|
#endif /* defined( __dsPIC33C__ ) */
|
||||||
|
|
|
@ -54,8 +54,8 @@
|
||||||
#define portSTACK_TYPE uint16_t
|
#define portSTACK_TYPE uint16_t
|
||||||
#define portBASE_TYPE short
|
#define portBASE_TYPE short
|
||||||
#define portPOINTER_SIZE_TYPE size_t
|
#define portPOINTER_SIZE_TYPE size_t
|
||||||
/* Microchip xc16 compilers already define SIZE_MAX in stdint.h */
|
|
||||||
#ifndef SIZE_MAX
|
#ifndef SIZE_MAX
|
||||||
|
/* Microchip xc16 and xc-dsc compilers already define SIZE_MAX in stdint.h */
|
||||||
#define SIZE_MAX ( ( size_t ) -1 )
|
#define SIZE_MAX ( ( size_t ) -1 )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue