*/\r
portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters )\r
{\r
-unsigned short usNibble;\r
-unsigned long ulSP_PC_Combined;\r
unsigned short *pusTopOfStack;\r
\r
/*\r
pxTopOfStack--;\r
*/\r
\r
- /* The msp430x automatically pushes the PC then SR onto the stack before\r
- executing an ISR. We want the stack to look just as if this has happened\r
- so place a pointer to the start of the task on the stack first - followed\r
- by the flags we want the task to use when it starts up. */\r
- \r
- /* When placed on the stack, the top four bits of the status register\r
- contain bits 19:16 of the 20 bit return address (pxCode). */\r
-#ifdef GENERATE_ISR_STACK_FRAME\r
- usNibble = ( unsigned short ) ( ( ( unsigned long ) pxCode >> 15UL ) & 0x0fUL );\r
-\r
- ulSP_PC_Combined = ( unsigned long ) pxCode;\r
- ulSP_PC_Combined <<= 16;\r
- ulSP_PC_Combined |= ( usNibble << 12 );\r
- ulSP_PC_Combined |= portFLAGS_INT_ENABLED;\r
- *pxTopOfStack = ulSP_PC_Combined;\r
- pxTopOfStack--;\r
-#else\r
*pxTopOfStack = ( portSTACK_TYPE ) pxCode;\r
pusTopOfStack = ( unsigned short * ) pxTopOfStack;\r
pusTopOfStack--;\r
*pusTopOfStack = portFLAGS_INT_ENABLED;\r
pusTopOfStack -= 2;\r
pxTopOfStack = ( portSTACK_TYPE * ) pusTopOfStack;\r
-#endif\r
+\r
/* Next the general purpose registers. */\r
*pxTopOfStack = ( portSTACK_TYPE ) 0xffffff;\r
pxTopOfStack--;\r
pxTopOfStack--;\r
*pxTopOfStack = ( portSTACK_TYPE ) 0x888888;\r
pxTopOfStack--; \r
- \r
- /* When the task starts is will expect to find the function parameter in\r
- R15. */\r
*pxTopOfStack = ( portSTACK_TYPE ) 0x555555;\r
pxTopOfStack--;\r
- \r
*pxTopOfStack = ( portSTACK_TYPE ) 0x666666;\r
pxTopOfStack--;\r
*pxTopOfStack = ( portSTACK_TYPE ) 0x555555;\r
*\r
* If the preemptive scheduler is in use a context switch can also occur.\r
*/\r
+ \r
RSEG ISR_CODE\r
+ \r
vTickISR:\r
+ \r
+ /* The sr is not saved in portSAVE_CONTEXT() because vPortYield() needs\r
+ to save it manually before it gets modified (interrupts get disabled). */\r
push.w sr\r
portSAVE_CONTEXT\r
\r
*/\r
vPortYield:\r
\r
- /* Mimic an interrupt by combining the SR and the PC, the latter having\r
- already been pushed onto the stack. R14 is a scratch registers. */\r
-// popx.a r14 /* r14 will hold the 20 bit PC. */\r
-// push.w r14 /* Push just 16 bits of the 20bit PC back onto the stack. */\r
-// rram.a #4, r14 /* Move the top 4 bits of the PC down ready to be combined with the SP. */\r
-// and.w #0xf000, r14/* Ensure other bits are clear. */\r
-// add.w sr, r14 /* Combine the top 4 bits of the PC with the SR. */\r
-// push.w r14 /* Push the generated combined value onto the stack. */\r
+ /* The sr needs saving before it is modified. */\r
push.w sr\r
+ \r
/* Now the SR is stacked we can disable interrupts. */\r
dint \r
nop\r
portRESTORE_CONTEXT\r
/*-----------------------------------------------------------*/\r
\r
-\r
- /* Install vTickISR as the interrupt on the vector specified by the\r
- application code. */\r
- /*COMMON INTVEC *./\r
- /*ORG 0xFF80 + configTICK_INTERRUPT_VECTOR\r
- ORG 0xFFEC\r
- \r
- __vTickISR__: DC16 0xabcd*/\r
- \r
-\r
END\r
\r