summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbdoulaye Walsimou Gaye <walsimou@walsimou.com>2009-04-19 19:49:45 +0200
committerAbdoulaye Walsimou Gaye <walsimou@walsimou.com>2009-04-19 19:49:45 +0200
commit693e891448b0ab4e2672aeba12b4425c32094ba1 (patch)
tree90eb8171572935b47e1cfc0a490010af5a3a7114
parentfe4261faf07e3a595e34676450ed7a7d7741e9a3 (diff)
downloadfreertos-693e891448b0ab4e2672aeba12b4425c32094ba1.tar.gz
freertos-693e891448b0ab4e2672aeba12b4425c32094ba1.tar.bz2
freertos-693e891448b0ab4e2672aeba12b4425c32094ba1.tar.xz
PIC18_SDCC: fix task stack corruption
This patch: * Reduce copyright characters * fix task stack corruption Signed-off-by: Abdoulaye Walsimou Gaye <walsimou@walsimou.com>
-rw-r--r--Source/portable/SDCC/PIC18/port.c44
1 files changed, 26 insertions, 18 deletions
diff --git a/Source/portable/SDCC/PIC18/port.c b/Source/portable/SDCC/PIC18/port.c
index 27914e90..332e68a9 100644
--- a/Source/portable/SDCC/PIC18/port.c
+++ b/Source/portable/SDCC/PIC18/port.c
@@ -1,7 +1,7 @@
/**
* #######################################################################################
* GAYE Abdoulaye Walsimou, <walsimou@walsimou.com>
-* Copyright(C) 2009 GAYE Abdoulaye Walsimou, <walsimou@walsimou.com>. All rights reserved.
+* Copyright (C) 2009 GAYE Abdoulaye Walsimou. All rights reserved.
*
* This program is free software; you can distribute it and/or modify it
* under the terms of the GNU General Public License
@@ -85,7 +85,6 @@ const static unsigned portSHORT TMR0ReloadValue=(65536 - configCPU_CLOCK_HZ/(con
*/
void prvLowInterrupt(void) __naked __interrupt 2;
-
/*-----------------------------------------------------------*/
/*
* See header file for description.
@@ -94,17 +93,25 @@ portSTACK_TYPE *pxPortInitialiseStack(portSTACK_TYPE *pxTopOfStack, pdTASK_CODE
{
unsigned portLONG ulAddress;
unsigned portCHAR ucBlock;
+ portSTACK_TYPE pvParameters_Upper;
+ portSTACK_TYPE pvParameters_High;
+ portSTACK_TYPE pvParameters_Low;
/*First store the function parameters. This is where the task will expect to
find them when it starts running. */
+
ulAddress = (unsigned portLONG) pvParameters;
- *pxTopOfStack = (portSTACK_TYPE) (ulAddress & (unsigned portLONG)0x00ff);
- pxTopOfStack--;
+ pvParameters_Low = (portSTACK_TYPE)(ulAddress & (unsigned portLONG)0x00ff);
ulAddress >>= 8;
- *pxTopOfStack = (portSTACK_TYPE) (ulAddress & (unsigned portLONG)0x00ff);
- pxTopOfStack--;
+ pvParameters_High = (portSTACK_TYPE)(ulAddress & (unsigned portLONG)0x00ff);
ulAddress >>= 8;
- *pxTopOfStack = (portSTACK_TYPE) (ulAddress & (unsigned portLONG)0x00ff);
+ pvParameters_Upper = (portSTACK_TYPE)(ulAddress & (unsigned portLONG)0x00ff);
+
+ *pxTopOfStack = pvParameters_Upper;
+ pxTopOfStack--;
+ *pxTopOfStack = pvParameters_High;
+ pxTopOfStack--;
+ *pxTopOfStack = pvParameters_Low;
pxTopOfStack--;
/*Now we save hardware and compiler registers*/
@@ -154,14 +161,15 @@ portSTACK_TYPE *pxPortInitialiseStack(portSTACK_TYPE *pxTopOfStack, pdTASK_CODE
*pxTopOfStack = (portSTACK_TYPE)0xee; /* TBLPTRU. */
pxTopOfStack--;
+
/* Next the .registers sections. Assuming that it is portCOMPILER_MANAGED_MEMORY_SIZE*/
- for( ucBlock = 0; ucBlock <portCOMPILER_MANAGED_MEMORY_SIZE; ucBlock++ )
+ for( ucBlock = 0; ucBlock <(unsigned char)portCOMPILER_MANAGED_MEMORY_SIZE; ucBlock++ )
{
*pxTopOfStack = (portSTACK_TYPE) ucBlock;
pxTopOfStack--;
}
- *pxTopOfStack =(portSTACK_TYPE)(portCOMPILER_MANAGED_MEMORY_SIZE);
+ *pxTopOfStack = (portSTACK_TYPE)(portCOMPILER_MANAGED_MEMORY_SIZE);
pxTopOfStack--;
*pxTopOfStack =0;
pxTopOfStack--;
@@ -237,7 +245,6 @@ void vPortYield(void) __naked
{
if(INTCONbits.TMR0IF)
{
- PORTDbits.RD0=PORTDbits.RD0^1;
/*
* Interrupt from regular tick.
* This increments the tick count and, if using the preemptive scheduler,
@@ -250,6 +257,7 @@ void vPortYield(void) __naked
portSAVE_CONTEXT(portGLOBAL_INTERRUPT_FLAG);
INTCONbits.TMR0IF=0;
+
/*set TMR0L and TMR0H value*/
TMR0H=(unsigned portCHAR)((TMR0ReloadValue&(unsigned portSHORT)0xff00)>>8);
TMR0L=(unsigned portCHAR)(TMR0ReloadValue&(unsigned portSHORT)0x00ff);
@@ -272,22 +280,22 @@ void vPortYield(void) __naked
*/
static void prvSetupTimerInterrupt(void)
{
- T0CONbits.TMR0ON=0; /*Timer0 off at the begining*/
- T0CONbits.T08BIT=0; /*Timer0 as 16 bits timer*/
- T0CONbits.T0CS=0; /*Timer0 works in timer mode*/
- T0CONbits.T0SE=0; /*Timer0 will increment positive transition*/
- T0CONbits.PSA=1; /*Timer0 prescaler is not assigned*/
+ T0CONbits.TMR0ON=0; /*Timer0 off at the begining*/
+ T0CONbits.T08BIT=0; /*Timer0 as 16 bits timer*/
+ T0CONbits.T0CS=0; /*Timer0 works in timer mode*/
+ T0CONbits.T0SE=0; /*Timer0 will increment positive transition*/
+ T0CONbits.PSA=1; /*Timer0 prescaler is not assigned*/
INTCONbits.TMR0IE=1; /*Timer0 interrupts are allowed*/
INTCONbits.TMR0IF=0; /*Timer0 interrupt flag cleared*/
/*set TMR0L and TMR0H value*/
- TMR0H=(unsigned portCHAR)((TMR0ReloadValue&(unsigned portSHORT)0xff00)>>8);
- TMR0L=(unsigned portCHAR)(TMR0ReloadValue&(unsigned portSHORT)0x00ff);
+ TMR0H=(unsigned portCHAR)((TMR0ReloadValue&(unsigned portSHORT)0xff00)>>8);
+ TMR0L=(unsigned portCHAR)(TMR0ReloadValue&(unsigned portSHORT)0x00ff);
RCONbits.IPEN=1; /* Interrupt priority feature enabled. FIXME: this is
* something like hardware interrupt controller configu-
* ration, so needs to be done somewhere else I think
*/
- T0CONbits.TMR0ON=1; /*Now enable timer0*/
+ T0CONbits.TMR0ON=1; /*Now enable timer0*/
}
void *pvPortMalloc(size_t xSize)