Please ensure to read the configuration and relevant port sections of the\r
online documentation.\r
\r
- http://www.FreeRTOS.org - Documentation, latest information, license and \r
+ http://www.FreeRTOS.org - Documentation, latest information, license and\r
contact details.\r
\r
- http://www.SafeRTOS.com - A version that is certified for use in safety \r
+ http://www.SafeRTOS.com - A version that is certified for use in safety\r
critical systems.\r
\r
- http://www.OpenRTOS.com - Commercial support, development, porting, \r
+ http://www.OpenRTOS.com - Commercial support, development, porting,\r
licensing and training services.\r
*/\r
\r
* |--------------------- Zero Flag set\r
* ---------------------- Global Interrupt Flag set (enabled)\r
*/\r
-#define portPSW (( portSTACK_TYPE ) 0xC600)\r
+#define portPSW (0xc6000000UL)\r
\r
/* We require the address of the pxCurrentTCB variable, but don't want to know\r
any details of its type. */\r
__interrupt void MD_INTTM05( void );\r
\r
/*\r
- * Sets up the periodic ISR used for the RTOS tick. \r
+ * Sets up the periodic ISR used for the RTOS tick.\r
*/\r
static void prvSetupTimerInterrupt( void );\r
/*-----------------------------------------------------------*/\r
\r
-/* \r
- * Initialise the stack of a task to look exactly as if a call to \r
+/*\r
+ * Initialise the stack of a task to look exactly as if a call to\r
* portSAVE_CONTEXT had been called.\r
- * \r
+ *\r
* See the header file portable.h.\r
*/\r
portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters )\r
-{ \r
+{\r
unsigned long *pulLocal;\r
\r
#if configMEMORY_MODE == 1\r
pxTopOfStack--;\r
pulLocal = ( unsigned long * ) pxTopOfStack;\r
*pulLocal = ( unsigned long ) pvParameters;\r
- pxTopOfStack--; \r
+ pxTopOfStack--;\r
\r
- /* Dummy values on the stack because there normaly the return address \r
- of the funtion is written. */ \r
+ /* Dummy values on the stack because there normaly the return address\r
+ of the funtion is written. */\r
*pxTopOfStack = ( portSTACK_TYPE ) 0xcdcd;\r
pxTopOfStack--;\r
*pxTopOfStack = ( portSTACK_TYPE ) 0xcdcd;\r
- pxTopOfStack--; \r
pxTopOfStack--;\r
\r
- /* Task function start address. */\r
- pulLocal = ( unsigned long * ) pxTopOfStack;\r
- *pulLocal = ( unsigned long ) pxCode;\r
+ /* Initial PSW value. */\r
+// *pxTopOfStack = portPSW;\r
+ \r
pxTopOfStack--;\r
\r
- /* Initial PSW value. */\r
- *pxTopOfStack = portPSW;\r
+ \r
+ /* Task function start address. */\r
+ pulLocal = ( unsigned long * ) pxTopOfStack;\r
+ *pulLocal = ( ( ( unsigned long ) pxCode ) | portPSW );\r
pxTopOfStack--;\r
\r
/* Next general purpose register AX. */\r
- *pxTopOfStack = ( portSTACK_TYPE ) 0x1111; \r
+ *pxTopOfStack = ( portSTACK_TYPE ) 0x1111;\r
pxTopOfStack--;\r
}\r
- #else \r
+ #else\r
{\r
pxTopOfStack--;\r
\r
*pxTopOfStack = ( portSTACK_TYPE ) pvParameters;\r
pxTopOfStack--;\r
}\r
- #endif \r
+ #endif\r
\r
/* HL. */\r
*pxTopOfStack = ( portSTACK_TYPE ) 0x2222;\r
pxTopOfStack--;\r
*pxTopOfStack = ( portSTACK_TYPE ) portNO_CRITICAL_SECTION_NESTING; \r
\r
- /* \r
+ /*\r
* Return a pointer to the top of the stack we have generated so this can\r
* be stored in the task control block for the task.\r
*/\r
/*-----------------------------------------------------------*/\r
\r
/*\r
- * Hardware initialisation to generate the RTOS tick. This uses Channel 5 of \r
- * the Timer Array Unit (TAU). Any other Channel could also be used. \r
+ * Hardware initialisation to generate the RTOS tick. This uses Channel 5 of\r
+ * the Timer Array Unit (TAU). Any other Channel could also be used.\r
*/\r
static void prvSetupTimerInterrupt( void )\r
{\r
/* To configure the Timer Array Unit all Channels have to first be stopped. */\r
TT0 = 0xff;\r
\r
- /* Interrupt of Timer Array Unit Channel 5 is disabled to set the interrupt \r
+ /* Interrupt of Timer Array Unit Channel 5 is disabled to set the interrupt\r
priority. */\r
TMMK05 = 1;\r
\r
; ***************************************************************************\r
;\r
;------------------------------------------------------------------------------\r
-; Note: Select the correct include files for the device used by the application. \r
+; Note: Select the correct include files for the device used by the application.\r
#include "FreeRTOSConfig.h"\r
;------------------------------------------------------------------------------\r
\r
PUBLIC vPortStart\r
\r
; Functions used by scheduler\r
-;------------------------------------------------------------------------------ \r
+;------------------------------------------------------------------------------\r
EXTERN vTaskSwitchContext\r
EXTERN vTaskIncrementTick\r
\r
; Variables used by scheduler\r
-;------------------------------------------------------------------------------ \r
+;------------------------------------------------------------------------------\r
EXTERN pxCurrentTCB\r
EXTERN usCriticalNesting\r
- \r
- \r
+\r
+\r
; Tick ISR Prototype\r
;------------------------------------------------------------------------------\r
- EXTERN ?CL78K0R_V2_L00 \r
+ EXTERN ?CL78K0R_V2_L00\r
\r
PUBWEAK `??MD_INTTM05??INTVEC 68`\r
PUBLIC MD_INTTM05\r
; portSAVE_CONTEXT MACRO\r
; Saves the context of the remaining general purpose registers, CS and ES\r
; (only in far memory mode) registers\r
-; the usCriticalNesting Value and the Stack Pointer \r
+; the usCriticalNesting Value and the Stack Pointer\r
; of the active Task onto the task stack\r
;------------------------------------------------------------------------------\r
-portSAVE_CONTEXT MACRO \r
+portSAVE_CONTEXT MACRO\r
\r
+ PUSH AX ; save AX Register to stack\r
PUSH HL\r
-#if configMEMORY_MODE == 1 \r
+#if configMEMORY_MODE == 1\r
MOV A, CS ; save CS register\r
XCH A, X\r
MOV A, ES ; save ES register\r
PUSH AX\r
-#else \r
+#else\r
MOV A, CS ; save CS register\r
PUSH AX\r
-#endif \r
+#endif\r
PUSH DE ; save the remaining general purpose registers\r
PUSH BC\r
MOVW AX, usCriticalNesting ; save the usCriticalNesting value \r
; portRESTORE_CONTEXT MACRO\r
; Restores the context of the Stack Pointer, usCriticalNesting\r
; value, general purpose registers and the CS and ES (only in far memory mode)\r
-; of the selected task from the task stack \r
+; of the selected task from the task stack\r
;------------------------------------------------------------------------------\r
\r
portRESTORE_CONTEXT MACRO\r
MOVW usCriticalNesting, AX\r
POP BC ; restore the necessary general purpose registers\r
POP DE\r
-#if configMEMORY_MODE == 1 \r
+#if configMEMORY_MODE == 1\r
POP AX ; restore the ES register\r
- MOV ES, A \r
+ MOV ES, A\r
XCH A, X ; restore the CS register\r
MOV CS, A\r
-#else \r
+#else\r
POP AX\r
MOV CS, A ; restore CS register\r
-#endif \r
+#endif\r
POP HL ; restore general purpose register HL\r
+ POP AX ; restore AX \r
ENDM\r
;------------------------------------------------------------------------------\r
\r
;------------------------------------------------------------------------------\r
RSEG CODE:CODE\r
vPortYield:\r
- PUSH PSW ; save Task PSW (Program Status Word)\r
- DI ; global disable interrupt\r
- PUSH AX\r
portSAVE_CONTEXT ; Save the context of the current task.\r
- CALL vTaskSwitchContext ; Call the scheduler.\r
+ call vTaskSwitchContext ; Call the scheduler.\r
portRESTORE_CONTEXT ; Restore the context of whichever task the ...\r
- POP AX\r
- EI ; (re-)enable global interrupts\r
- POP PSW ; restore active task PSW \r
- RET ; ... scheduler decided should run.\r
+ RETB\r
\r
\r
;------------------------------------------------------------------------------\r
RSEG CODE:CODE\r
vPortStart:\r
portRESTORE_CONTEXT ; Restore the context of whichever task the ...\r
- POP AX\r
- EI ; enable global interrupts \r
- POP PSW ; restore active task PSW\r
- ret ; ... scheduler decided should run.\r
+; POP PSW ; restore active task PSW\r
+ reti ; ... scheduler decided should run.\r
\r
;------------------------------------------------------------------------------\r
; Perform the necessary steps of the Tick Count Increment and Task Switch\r
-; depending on the chosen kernel configuration \r
+; depending on the chosen kernel configuration\r
;\r
; Input: NONE\r
;\r
-; Call: ISR \r
+; Call: ISR\r
;\r
; Output: NONE\r
;\r
#if configUSE_PREEMPTION == 1\r
\r
MD_INTTM05:\r
- PUSH AX ; create temporary dummy area on stack\r
- PUSH AX ; save AX Register to stack\r
- MOVW AX, [SP+6] ; get PSW \r
- MOVW [SP+2], AX ; write PSW into dummy area on the stack\r
\r
portSAVE_CONTEXT ; Save the context of the current task.\r
call vTaskIncrementTick ; Call the timer tick function.\r
call vTaskSwitchContext ; Call the scheduler.\r
portRESTORE_CONTEXT ; Restore the context of whichever task the ...\r
- ; ... scheduler decided should run.\r
-\r
- MOVW AX, [SP+2] ; get PSW from stack\r
- MOVW [SP+6], AX ; write PSW to expected location for reti\r
- POP AX ; restore AX\r
- MOVW [SP+0], AX ; rewrite dummy stack area to expected value\r
- POP AX \r
- RETI \r
+ RETI\r
#else\r
\r
MD_INTTM05:\r
- PUSH AX ; save necessary general purpose register... \r
+ PUSH AX ; save necessary general purpose register...\r
PUSH HL ; ...used by the ISR\r
MOVW AX, CS ; save CS register\r
PUSH AX\r
MOVW CS, AX ; restore CS register\r
POP HL ; restore used general purpose registers\r
POP AX\r
- RETI \r
+ RETI\r
#endif\r
\r
REQUIRE ?CL78K0R_V2_L00\r
ORG 68\r
`??MD_INTTM05??INTVEC 68`:\r
DW MD_INTTM05\r
- ; set value for the usCriticalNesting\r
+\r
+ COMMON INTVEC:CODE:ROOT(1) ; set ISR location to the Interrupt vector table\r
+ ORG 126\r
+`??vPortYield??INTVEC 126`:\r
+ DW vPortYield\r
+\r
+ ; set value for the usCriticalNesting\r
RSEG NEAR_ID:CONST:SORT:NOROOT(1)\r
`?<Initializer for usCriticalNesting>`:\r
DW 10\r
- \r
+\r
;#endif\r
\r
END
\ No newline at end of file