diff --git a/FreeRTOS/Demo/RL78_E2Studio_GCC/.YRDKRL78G14linker b/FreeRTOS/Demo/RL78_E2Studio_GCC/.YRDKRL78G14linker index 41d71b41d..6cce6bbca 100644 --- a/FreeRTOS/Demo/RL78_E2Studio_GCC/.YRDKRL78G14linker +++ b/FreeRTOS/Demo/RL78_E2Studio_GCC/.YRDKRL78G14linker @@ -71,7 +71,7 @@ - + @@ -79,7 +79,6 @@ - @@ -90,8 +89,9 @@ - + + diff --git a/FreeRTOS/Demo/RL78_E2Studio_GCC/.cproject b/FreeRTOS/Demo/RL78_E2Studio_GCC/.cproject index 046f15423..cfbb8dc45 100644 --- a/FreeRTOS/Demo/RL78_E2Studio_GCC/.cproject +++ b/FreeRTOS/Demo/RL78_E2Studio_GCC/.cproject @@ -3,212 +3,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -415,6 +209,212 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/FreeRTOS/Demo/RL78_E2Studio_GCC/.settings/Project_Generation_Prefrences.prefs b/FreeRTOS/Demo/RL78_E2Studio_GCC/.settings/Project_Generation_Prefrences.prefs index 173fe2f6d..d51f1b140 100644 --- a/FreeRTOS/Demo/RL78_E2Studio_GCC/.settings/Project_Generation_Prefrences.prefs +++ b/FreeRTOS/Demo/RL78_E2Studio_GCC/.settings/Project_Generation_Prefrences.prefs @@ -1,4 +1,4 @@ -#Mon Mar 04 17:13:11 GMT 2013 +#Wed Mar 06 15:45:34 GMT 2013 Library\ Generator\ Command=rl78-elf-libgen com.renesas.cdt.core.Assembler.option.includeFileDirectories="${workspace_loc\:/${ProjName}}\\src"; com.renesas.cdt.core.Compiler.option.includeFileDir.1067754383="${TCINSTALL}\\rl78-elf\\optlibinc"; @@ -14,6 +14,7 @@ com.renesas.cdt.rl78.HardwareDebug.Compiler.option.cpuType=RL78 - G1C com.renesas.cdt.rl78.HardwareDebug.Compiler.option.cpuType.1364542281=RL78 - G1C com.renesas.cdt.rl78.HardwareDebug.Compiler.option.mmul=None com.renesas.cdt.rl78.HardwareDebug.Linker.option.archiveLibraryFiles=${ProjName};gcc; +com.renesas.cdt.rl78.HardwareDebug.Linker.option.archiveSearchDirectories.1960648199="${CONFIGDIR}";"${TCINSTALL}\\lib\\gcc\\rl78-elf\\\\${GCC_VERSION}"; com.renesas.cdt.rl78.HardwareDebug.Linker.option.archiveSearchDirectories.970009502="${CONFIGDIR}";"${TCINSTALL}\\lib\\gcc\\rl78-elf\\\\${GCC_VERSION}"; com.renesas.cdt.rl78.HardwareDebug.Linker.option.archiveSearchDirectories.984802356="${CONFIGDIR}";"${TCINSTALL}\\lib\\gcc\\rl78-elf\\\\${GCC_VERSION}"; eclipse.preferences.version=1 diff --git a/FreeRTOS/Demo/RL78_E2Studio_GCC/RSKRL78G1C.launch b/FreeRTOS/Demo/RL78_E2Studio_GCC/RSKRL78G1C.launch new file mode 100644 index 000000000..a0ae46e1b --- /dev/null +++ b/FreeRTOS/Demo/RL78_E2Studio_GCC/RSKRL78G1C.launch @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/FreeRTOS/Demo/RL78_E2Studio_GCC/YRDKRL78G14.launch b/FreeRTOS/Demo/RL78_E2Studio_GCC/YRDKRL78G14.launch new file mode 100644 index 000000000..b600154e7 --- /dev/null +++ b/FreeRTOS/Demo/RL78_E2Studio_GCC/YRDKRL78G14.launch @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/FreeRTOS/Demo/RL78_E2Studio_GCC/src/Common-Demo-Tasks/dynamic.c b/FreeRTOS/Demo/RL78_E2Studio_GCC/src/Common-Demo-Tasks/dynamic.c index 81b3ef96c..5b34d8a6a 100644 --- a/FreeRTOS/Demo/RL78_E2Studio_GCC/src/Common-Demo-Tasks/dynamic.c +++ b/FreeRTOS/Demo/RL78_E2Studio_GCC/src/Common-Demo-Tasks/dynamic.c @@ -56,48 +56,48 @@ *************************************************************************** - http://www.FreeRTOS.org - Documentation, books, training, latest versions, + http://www.FreeRTOS.org - Documentation, books, training, latest versions, license and Real Time Engineers Ltd. contact details. http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, including FreeRTOS+Trace - an indispensable productivity tool, and our new fully thread aware and reentrant UDP/IP stack. - http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High - Integrity Systems, who sell the code with commercial support, + http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High + Integrity Systems, who sell the code with commercial support, indemnification and middleware, under the OpenRTOS brand. - - http://www.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and + + http://www.SafeRTOS.com - High Integrity Systems also provide a safety + engineered and independently SIL3 certified version for use in safety and mission critical applications that require provable dependability. */ /* - * The first test creates three tasks - two counter tasks (one continuous count - * and one limited count) and one controller. A "count" variable is shared - * between all three tasks. The two counter tasks should never be in a "ready" - * state at the same time. The controller task runs at the same priority as - * the continuous count task, and at a lower priority than the limited count + * The first test creates three tasks - two counter tasks (one continuous count + * and one limited count) and one controller. A "count" variable is shared + * between all three tasks. The two counter tasks should never be in a "ready" + * state at the same time. The controller task runs at the same priority as + * the continuous count task, and at a lower priority than the limited count * task. * * One counter task loops indefinitely, incrementing the shared count variable * on each iteration. To ensure it has exclusive access to the variable it - * raises it's priority above that of the controller task before each + * raises it's priority above that of the controller task before each * increment, lowering it again to it's original priority before starting the * next iteration. * * The other counter task increments the shared count variable on each * iteration of it's loop until the count has reached a limit of 0xff - at - * which point it suspends itself. It will not start a new loop until the - * controller task has made it "ready" again by calling vTaskResume (). - * This second counter task operates at a higher priority than controller - * task so does not need to worry about mutual exclusion of the counter + * which point it suspends itself. It will not start a new loop until the + * controller task has made it "ready" again by calling vTaskResume (). + * This second counter task operates at a higher priority than controller + * task so does not need to worry about mutual exclusion of the counter * variable. * * The controller task is in two sections. The first section controls and - * monitors the continuous count task. When this section is operational the - * limited count task is suspended. Likewise, the second section controls - * and monitors the limited count task. When this section is operational the + * monitors the continuous count task. When this section is operational the + * limited count task is suspended. Likewise, the second section controls + * and monitors the limited count task. When this section is operational the * continuous count task is suspended. * * In the first section the controller task first takes a copy of the shared @@ -107,11 +107,11 @@ * the continuous count task will execute and increment the shared variable. * When the controller task wakes it checks that the continuous count task * has executed by comparing the copy of the shared variable with its current - * value. This time, to ensure mutual exclusion, the scheduler itself is - * suspended with a call to vTaskSuspendAll (). This is for demonstration + * value. This time, to ensure mutual exclusion, the scheduler itself is + * suspended with a call to vTaskSuspendAll (). This is for demonstration * purposes only and is not a recommended technique due to its inefficiency. * - * After a fixed number of iterations the controller task suspends the + * After a fixed number of iterations the controller task suspends the * continuous count task, and moves on to its second section. * * At the start of the second section the shared variable is cleared to zero. @@ -123,7 +123,7 @@ * a check on the shared variable to ensure everything is as expected. * * - * The second test consists of a couple of very simple tasks that post onto a + * The second test consists of a couple of very simple tasks that post onto a * queue while the scheduler is suspended. This test was added to test parts * of the scheduler not exercised by the first test. * @@ -165,7 +165,7 @@ static portTASK_FUNCTION_PROTO( vQueueSendWhenSuspendedTask, pvParameters ); to the controller task to prevent them having to be file scope. */ static xTaskHandle xContinousIncrementHandle, xLimitedIncrementHandle; -/* The shared counter variable. This is passed in as a parameter to the two +/* The shared counter variable. This is passed in as a parameter to the two counter variables for demonstration purposes. */ static unsigned long ulCounter; @@ -178,7 +178,7 @@ static volatile portBASE_TYPE xSuspendedQueueSendError = pdFALSE; static volatile portBASE_TYPE xSuspendedQueueReceiveError = pdFALSE; /* Queue used by the second test. */ -xQueueHandle xSuspendedTestQueue; +static xQueueHandle xSuspendedTestQueue; /*-----------------------------------------------------------*/ /* @@ -190,10 +190,10 @@ void vStartDynamicPriorityTasks( void ) xSuspendedTestQueue = xQueueCreate( priSUSPENDED_QUEUE_LENGTH, sizeof( unsigned long ) ); /* vQueueAddToRegistry() adds the queue to the queue registry, if one is - in use. The queue registry is provided as a means for kernel aware + in use. The queue registry is provided as a means for kernel aware debuggers to locate queues and has no purpose if a kernel aware debugger is not being used. The call to vQueueAddToRegistry() will be removed - by the pre-processor if configQUEUE_REGISTRY_SIZE is not defined or is + by the pre-processor if configQUEUE_REGISTRY_SIZE is not defined or is defined to be less than 1. */ vQueueAddToRegistry( xSuspendedTestQueue, ( signed char * ) "Suspended_Test_Queue" ); @@ -207,7 +207,7 @@ void vStartDynamicPriorityTasks( void ) /* * Just loops around incrementing the shared variable until the limit has been - * reached. Once the limit has been reached it suspends itself. + * reached. Once the limit has been reached it suspends itself. */ static portTASK_FUNCTION( vLimitedIncrementTask, pvParameters ) { @@ -224,12 +224,12 @@ unsigned long *pulCounter; for( ;; ) { /* Just count up to a value then suspend. */ - ( *pulCounter )++; - + ( *pulCounter )++; + if( *pulCounter >= priMAX_COUNT ) { vTaskSuspend( NULL ); - } + } } } /*-----------------------------------------------------------*/ @@ -247,7 +247,7 @@ unsigned portBASE_TYPE uxOurPriority; the task. */ pulCounter = ( unsigned long * ) pvParameters; - /* Query our priority so we can raise it when exclusive access to the + /* Query our priority so we can raise it when exclusive access to the shared variable is required. */ uxOurPriority = uxTaskPriorityGet( NULL ); @@ -256,7 +256,7 @@ unsigned portBASE_TYPE uxOurPriority; /* Raise our priority above the controller task to ensure a context switch does not occur while we are accessing this variable. */ vTaskPrioritySet( NULL, uxOurPriority + 1 ); - ( *pulCounter )++; + ( *pulCounter )++; vTaskPrioritySet( NULL, uxOurPriority ); } } @@ -289,11 +289,11 @@ short sError = pdFALSE; vTaskSuspend( xContinousIncrementHandle ); ulLastCounter = ulCounter; vTaskResume( xContinousIncrementHandle ); - + /* Now delay to ensure the other task has processor time. */ vTaskDelay( priSLEEP_TIME ); - /* Check the shared variable again. This time to ensure mutual + /* Check the shared variable again. This time to ensure mutual exclusion the whole scheduler will be locked. This is just for demo purposes! */ vTaskSuspendAll(); @@ -380,7 +380,7 @@ portBASE_TYPE xGotValue; { do { - /* Suspending the scheduler here is fairly pointless and + /* Suspending the scheduler here is fairly pointless and undesirable for a normal application. It is done here purely to test the scheduler. The inner xTaskResumeAll() should never return pdTRUE as the scheduler is still locked by the @@ -419,7 +419,7 @@ portBASE_TYPE xGotValue; /* Called to check that all the created tasks are still running without error. */ portBASE_TYPE xAreDynamicPriorityTasksStillRunning( void ) { -/* Keep a history of the check variables so we know if it has been incremented +/* Keep a history of the check variables so we know if it has been incremented since the last call. */ static unsigned short usLastTaskCheck = ( unsigned short ) 0; portBASE_TYPE xReturn = pdTRUE; diff --git a/FreeRTOS/Demo/RL78_E2Studio_GCC/src/FreeRTOSConfig.h b/FreeRTOS/Demo/RL78_E2Studio_GCC/src/FreeRTOSConfig.h index 82dff1b8e..e89a91b7c 100644 --- a/FreeRTOS/Demo/RL78_E2Studio_GCC/src/FreeRTOSConfig.h +++ b/FreeRTOS/Demo/RL78_E2Studio_GCC/src/FreeRTOSConfig.h @@ -91,7 +91,7 @@ #define configTICK_RATE_HZ ( ( unsigned short ) 1000 ) #define configCPU_CLOCK_HZ ( ( unsigned long ) 32000000 ) /* Using the internal high speed clock */ #define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 4 ) -#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 100 ) +#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 90 ) #define configMAX_TASK_NAME_LEN ( 10 ) #define configUSE_TRACE_FACILITY 0 #define configUSE_16_BIT_TICKS 1 @@ -101,7 +101,7 @@ #define configUSE_MUTEXES 1 /* Hook function definitions. */ -#define configUSE_IDLE_HOOK 1 +#define configUSE_IDLE_HOOK 0 #define configUSE_TICK_HOOK 0 #define configUSE_MALLOC_FAILED_HOOK 1 @@ -129,10 +129,6 @@ to exclude the API function. */ #define configASSERT( x ) if( ( x ) == 0 ) vAssertCalled() -#define __DATA_MODEL_FAR__ 0 -#define __DATA_MODEL_NEAR__ 1 -#define __DATA_MODEL__ __DATA_MODEL_FAR__ - #endif /* FREERTOS_CONFIG_H */ diff --git a/FreeRTOS/Demo/RL78_E2Studio_GCC/src/FreeRTOS_Source/portable/GCC/RL78/isr_support.h b/FreeRTOS/Demo/RL78_E2Studio_GCC/src/FreeRTOS_Source/portable/GCC/RL78/isr_support.h index eb3c60054..39ea76797 100644 --- a/FreeRTOS/Demo/RL78_E2Studio_GCC/src/FreeRTOS_Source/portable/GCC/RL78/isr_support.h +++ b/FreeRTOS/Demo/RL78_E2Studio_GCC/src/FreeRTOS_Source/portable/GCC/RL78/isr_support.h @@ -72,8 +72,6 @@ mission critical applications that require provable dependability. */ -/*_RB_ #include "FreeRTOSConfig.h" */ - /* Variables used by scheduler */ .extern _pxCurrentTCB .extern _usCriticalNesting @@ -86,32 +84,47 @@ */ .macro portSAVE_CONTEXT + SEL RB0 + /* Save AX Register to stack. */ - PUSH AX - PUSH HL -#if __DATA_MODEL__ == __DATA_MODEL_FAR__ + PUSH AX + PUSH HL /* Save CS register. */ - MOV A, CS - XCH A, X + MOV A, CS + XCH A, X /* Save ES register. */ - MOV A, ES - PUSH AX -#else - /* Save CS register. */ - MOV A, CS - PUSH AX -#endif - /* Save the remaining general purpose registers. */ - PUSH DE - PUSH BC + MOV A, ES + PUSH AX + /* Save the remaining general purpose registers from bank 0. */ + PUSH DE + PUSH BC + /* Save the other register banks - only necessary in the GCC port. */ + SEL RB1 + PUSH AX + PUSH BC + PUSH DE + PUSH HL + SEL RB2 + PUSH AX + PUSH BC + PUSH DE + PUSH HL + SEL RB3 + PUSH AX + PUSH BC + PUSH DE + PUSH HL + SEL RB0 /* Save the usCriticalNesting value. */ - MOVW AX, !_usCriticalNesting - PUSH AX + MOVW AX, !_usCriticalNesting + PUSH AX /* Save the Stack pointer. */ - MOVW AX, !_pxCurrentTCB - MOVW HL, AX - MOVW AX, SP - MOVW [HL], AX + MOVW AX, !_pxCurrentTCB + MOVW HL, AX + MOVW AX, SP + MOVW [HL], AX + /* Switch stack pointers. */ + movw sp,#_stack /* Set stack pointer */ .endm @@ -123,33 +136,46 @@ * of the selected task from the task stack */ .macro portRESTORE_CONTEXT MACRO + SEL RB0 /* Restore the Stack pointer. */ - MOVW AX, !_pxCurrentTCB - MOVW HL, AX - MOVW AX, [HL] - MOVW SP, AX + MOVW AX, !_pxCurrentTCB + MOVW HL, AX + MOVW AX, [HL] + MOVW SP, AX /* Restore usCriticalNesting value. */ - POP AX - MOVW !_usCriticalNesting, AX + POP AX + MOVW !_usCriticalNesting, AX + /* Restore the alternative register banks - only necessary in the GCC + port. */ + SEL RB3 + POP HL + POP DE + POP BC + POP AX + SEL RB2 + POP HL + POP DE + POP BC + POP AX + SEL RB1 + POP HL + POP DE + POP BC + POP AX + SEL RB0 /* Restore the necessary general purpose registers. */ - POP BC - POP DE -#if __DATA_MODEL__ == __DATA_MODEL_FAR__ + POP BC + POP DE /* Restore the ES register. */ - POP AX - MOV ES, A + POP AX + MOV ES, A /* Restore the CS register. */ - XCH A, X - MOV CS, A -#else - POP AX - /* Restore the CS register. */ - MOV CS, A -#endif + XCH A, X + MOV CS, A /* Restore general purpose register HL. */ - POP HL + POP HL /* Restore AX. */ - POP AX + POP AX .endm diff --git a/FreeRTOS/Demo/RL78_E2Studio_GCC/src/FreeRTOS_Source/portable/GCC/RL78/port.c b/FreeRTOS/Demo/RL78_E2Studio_GCC/src/FreeRTOS_Source/portable/GCC/RL78/port.c index a5bb44ce6..41cace60c 100644 --- a/FreeRTOS/Demo/RL78_E2Studio_GCC/src/FreeRTOS_Source/portable/GCC/RL78/port.c +++ b/FreeRTOS/Demo/RL78_E2Studio_GCC/src/FreeRTOS_Source/portable/GCC/RL78/port.c @@ -85,7 +85,7 @@ interrupts don't accidentally become enabled before the scheduler is started. */ #define portINITIAL_CRITICAL_NESTING ( ( unsigned short ) 10 ) /* Initial PSW value allocated to a newly created task. - * 1100011000000000 + * 11000110 * ||||||||-------------- Fill byte * |||||||--------------- Carry Flag cleared * |||||----------------- In-service priority Flags set to low level @@ -95,7 +95,8 @@ interrupts don't accidentally become enabled before the scheduler is started. */ * |--------------------- Zero Flag set * ---------------------- Global Interrupt Flag set (enabled) */ -#define portPSW ( 0xc6UL ) +//#define portPSW ( 0xc6UL ) +#define portPSW ( 0x86UL ) /* The address of the pxCurrentTCB variable, but don't know or need to know its type. */ @@ -137,67 +138,24 @@ portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE { unsigned long *pulLocal; - #if __DATA_MODEL__ == __DATA_MODEL_FAR__ - { - /* Parameters are passed in on the stack, and written using a 32bit value - hence a space is left for the second two bytes. */ - pxTopOfStack--; - - /* Write in the parameter value. */ - pulLocal = ( unsigned long * ) pxTopOfStack; - *pulLocal = ( unsigned long ) pvParameters; - pxTopOfStack--; - - /* These values are just spacers. The return address of the function - would normally be written here. */ - *pxTopOfStack = ( portSTACK_TYPE ) 0x00; - pxTopOfStack--; - *pxTopOfStack = ( portSTACK_TYPE ) 0x00; - pxTopOfStack--; - - /* The start address / PSW value is also written in as a 32bit value, - so leave a space for the second two bytes. */ - pxTopOfStack--; - - /* Task function start address combined with the PSW. */ - pulLocal = ( unsigned long * ) pxTopOfStack; - *pulLocal = ( ( ( unsigned long ) pxCode ) | ( portPSW << 24UL ) ); - pxTopOfStack--; - - /* An initial value for the AX register. */ - *pxTopOfStack = ( portSTACK_TYPE ) 0x1111; - pxTopOfStack--; - } - #else - { - /* Task function address is written to the stack first. As it is - written as a 32bit value a space is left on the stack for the second - two bytes. */ - pxTopOfStack--; - - /* Task function start address combined with the PSW. */ - pulLocal = ( unsigned long * ) pxTopOfStack; - *pulLocal = ( ( ( unsigned long ) pxCode ) | ( portPSW << 24UL ) ); - pxTopOfStack--; - - /* The parameter is passed in AX. */ - *pxTopOfStack = ( portSTACK_TYPE ) pvParameters; - pxTopOfStack--; - } - #endif - -#ifdef This_was_an_alternative_to_the_two_above - /* Parameters are passed in on the stack. */ - *pxTopOfStack = ( portSTACK_TYPE ) pvParameters; + /* Parameters are passed in on the stack, and written using a 32bit value + hence a space is left for the second two bytes. */ pxTopOfStack--; -#warning Why is the offset necessary? Presumably because the parameter could be 20 bits. - pxTopOfStack--; + /* Write in the parameter value. */ + pulLocal = ( unsigned long * ) pxTopOfStack; + *pulLocal = ( unsigned long ) pvParameters; pxTopOfStack--; - /* Task function address is written to the stack first. As it is - written as a 32bit value a space is left on the stack for the second - two bytes. */ + /* These values are just spacers. The return address of the function + would normally be written here. */ + *pxTopOfStack = ( portSTACK_TYPE ) 0x00; + pxTopOfStack--; + *pxTopOfStack = ( portSTACK_TYPE ) 0x00; + pxTopOfStack--; + + /* The start address / PSW value is also written in as a 32bit value, + so leave a space for the second two bytes. */ pxTopOfStack--; /* Task function start address combined with the PSW. */ @@ -206,9 +164,9 @@ unsigned long *pulLocal; pxTopOfStack--; /* An initial value for the AX register. */ - *pxTopOfStack = ( portSTACK_TYPE ) 0xaaaa; + *pxTopOfStack = ( portSTACK_TYPE ) 0x1111; pxTopOfStack--; -#endif + /* An initial value for the HL register. */ *pxTopOfStack = ( portSTACK_TYPE ) 0x2222; pxTopOfStack--; @@ -217,11 +175,9 @@ unsigned long *pulLocal; *pxTopOfStack = ( portSTACK_TYPE ) 0x0F00; pxTopOfStack--; - /* Finally the remaining general purpose registers DE and BC */ - *pxTopOfStack = ( portSTACK_TYPE ) 0xDEDE; - pxTopOfStack--; - *pxTopOfStack = ( portSTACK_TYPE ) 0xBCBC; - pxTopOfStack--; + /* The remaining general purpose registers bank 0 (DE and BC) and the other + three register banks.. */ + pxTopOfStack -= 14; /* Finally the critical section nesting count is set to zero when the task first starts. */ diff --git a/FreeRTOS/Demo/RL78_E2Studio_GCC/src/FreeRTOS_Source/portable/GCC/RL78/portasm.S b/FreeRTOS/Demo/RL78_E2Studio_GCC/src/FreeRTOS_Source/portable/GCC/RL78/portasm.S index cd0914cbb..35d6e1c34 100644 --- a/FreeRTOS/Demo/RL78_E2Studio_GCC/src/FreeRTOS_Source/portable/GCC/RL78/portasm.S +++ b/FreeRTOS/Demo/RL78_E2Studio_GCC/src/FreeRTOS_Source/portable/GCC/RL78/portasm.S @@ -86,6 +86,7 @@ .extern _vTaskIncrementTick .text + .align 2 /* FreeRTOS yield handler. This is installed as the BRK software interrupt handler. */ @@ -101,6 +102,7 @@ _vPortYield: /* Starts the scheduler by restoring the context of the task that will execute first. */ + .align 2 _vPortStartFirstTask: /* Restore the context of whichever task will execute first. */ portRESTORE_CONTEXT @@ -109,6 +111,7 @@ _vPortStartFirstTask: /* FreeRTOS tick handler. This is installed as the interval timer interrupt handler. */ + .align 2 _vPortTickISR: /* Save the context of the currently executing task. */ diff --git a/FreeRTOS/Demo/RL78_E2Studio_GCC/src/FreeRTOS_Source/portable/GCC/RL78/portmacro.h b/FreeRTOS/Demo/RL78_E2Studio_GCC/src/FreeRTOS_Source/portable/GCC/RL78/portmacro.h index f3d5c2184..de757999f 100644 --- a/FreeRTOS/Demo/RL78_E2Studio_GCC/src/FreeRTOS_Source/portable/GCC/RL78/portmacro.h +++ b/FreeRTOS/Demo/RL78_E2Studio_GCC/src/FreeRTOS_Source/portable/GCC/RL78/portmacro.h @@ -156,7 +156,7 @@ extern volatile unsigned short usCriticalNesting; \ /*-----------------------------------------------------------*/ /* Task utilities. */ -#define portYIELD() __asm volatile ( "BRK" ) +#define portYIELD() __asm volatile ( "BRK" ) #define portYIELD_FROM_ISR( xHigherPriorityTaskWoken ) if( xHigherPriorityTaskWoken ) vTaskSwitchContext() #define portNOP() __asm volatile ( "NOP" ) /*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Demo/RL78_E2Studio_GCC/src/RegTest.S b/FreeRTOS/Demo/RL78_E2Studio_GCC/src/RegTest.S index 63587c62e..56821eacd 100644 --- a/FreeRTOS/Demo/RL78_E2Studio_GCC/src/RegTest.S +++ b/FreeRTOS/Demo/RL78_E2Studio_GCC/src/RegTest.S @@ -94,19 +94,27 @@ _vRegTest1Task: /* First fill the registers. */ + SEL RB0 MOVW AX, #0x1122 MOVW BC, #0x3344 MOVW DE, #0x5566 MOVW HL, #0x7788 - MOV CS, #0x01 - -#if __DATA_MODEL__ == __DATA_MODEL_FAR__ - - ; ES is not saved or restored when using the near memory model so only - ; test it when using the far model. - MOV ES, #0x02 - -#endif + SEL RB1 + MOVW AX, #0x1111 + MOVW BC, #0x2222 + MOVW DE, #0x3333 + MOVW HL, #0x4444 + SEL RB2 + MOVW AX, #0x5555 + MOVW BC, #0x6666 + MOVW DE, #0x7777 + MOVW HL, #0x8888 + SEL RB3 + MOVW AX, #0xAAAA + MOVW BC, #0xBBBB + MOVW DE, #0xCCCC + MOVW HL, #0xDDDD + SEL RB0 _loop1: @@ -136,26 +144,72 @@ _loop1: CMPW AX, #0x7788 BZ $.+5 BR !!_vRegTestError - MOV A, CS - CMP A, #0x01 + + /* Set AX back to its initial value. */ + MOVW AX, #0x1122 + + SEL RB1 + CMPW AX, #0x1111 BZ $.+5 BR !!_vRegTestError - -#if __DATA_MODEL__ == __DATA_MODEL_FAR__ - - /* ES is not saved or restored when using the near memory model so only - test it when using the far model. */ - MOV A, ES - CMP A, #0x02 + MOVW AX, BC + CMPW AX, #0x2222 BZ $.+5 BR !!_vRegTestError + MOVW AX, DE + CMPW AX, #0x3333 + BZ $.+5 + BR !!_vRegTestError + MOVW AX, HL + CMPW AX, #0x4444 + BZ $.+5 + BR !!_vRegTestError + MOVW AX, #0x1111 -#endif + + SEL RB2 + CMPW AX, #0x5555 + BZ $.+5 + BR !!_vRegTestError + MOVW AX, BC + CMPW AX, #0x6666 + BZ $.+5 + BR !!_vRegTestError + MOVW AX, DE + CMPW AX, #0x7777 + BZ $.+5 + BR !!_vRegTestError + MOVW AX, HL + CMPW AX, #0x8888 + BZ $.+5 + BR !!_vRegTestError + MOVW AX, #0x5555 + + + SEL RB3 + CMPW AX, #0xAAAA + BZ $.+5 + BR !!_vRegTestError + MOVW AX, BC + CMPW AX, #0xBBBB + BZ $.+5 + BR !!_vRegTestError + MOVW AX, DE + CMPW AX, #0xCCCC + BZ $.+5 + BR !!_vRegTestError + MOVW AX, HL + CMPW AX, #0xDDDD + BZ $.+5 + BR !!_vRegTestError + MOVW AX, #0xAAAA + + + SEL RB0 /* Indicate that this task is still cycling. */ INCW !_usRegTest1LoopCounter - MOVW AX, #0x1122 BR !!_loop1 @@ -166,17 +220,27 @@ _loop1: */ _vRegTest2Task: + SEL RB0 MOVW AX, #0x99aa MOVW BC, #0xbbcc MOVW DE, #0xddee MOVW HL, #0xff12 - MOV CS, #0x03 - -#if __DATA_MODEL__ == __DATA_MODEL_FAR__ - - MOV ES, #0x04 - -#endif + SEL RB1 + MOVW AX, #0x0110 + MOVW BC, #0x0220 + MOVW DE, #0x0330 + MOVW HL, #0x0440 + SEL RB2 + MOVW AX, #0x0550 + MOVW BC, #0x0660 + MOVW DE, #0x0770 + MOVW HL, #0x0880 + SEL RB3 + MOVW AX, #0x0AA0 + MOVW BC, #0x0BB0 + MOVW DE, #0x0CC0 + MOVW HL, #0x0DD0 + SEL RB0 _loop2: CMPW AX, #0x99aa @@ -194,24 +258,67 @@ _loop2: CMPW AX, #0xff12 BZ $.+5 BR !!_vRegTestError - MOV A, CS - CMP A, #0x03 + MOVW AX, #0x99aa + + SEL RB1 + CMPW AX, #0x0110 BZ $.+5 BR !!_vRegTestError - -#if __DATA_MODEL__ == __DATA_MODEL_FAR__ - - MOV A, ES - CMP A, #0x04 + MOVW AX, BC + CMPW AX, #0x0220 BZ $.+5 BR !!_vRegTestError + MOVW AX, DE + CMPW AX, #0x0330 + BZ $.+5 + BR !!_vRegTestError + MOVW AX, HL + CMPW AX, #0x0440 + BZ $.+5 + BR !!_vRegTestError + MOVW AX, #0x0110 -#endif + SEL RB2 + CMPW AX, #0x0550 + BZ $.+5 + BR !!_vRegTestError + MOVW AX, BC + CMPW AX, #0x0660 + BZ $.+5 + BR !!_vRegTestError + MOVW AX, DE + CMPW AX, #0x0770 + BZ $.+5 + BR !!_vRegTestError + MOVW AX, HL + CMPW AX, #0x0880 + BZ $.+5 + BR !!_vRegTestError + MOVW AX, #0x0550 + + SEL RB3 + CMPW AX, #0x0AA0 + BZ $.+5 + BR !!_vRegTestError + MOVW AX, BC + CMPW AX, #0x0BB0 + BZ $.+5 + BR !!_vRegTestError + MOVW AX, DE + CMPW AX, #0x0CC0 + BZ $.+5 + BR !!_vRegTestError + MOVW AX, HL + CMPW AX, #0x0DD0 + BZ $.+5 + BR !!_vRegTestError + MOVW AX, #0x0AA0 + + SEL RB0 /* Indicate that this task is still cycling. */ INCW !_usRegTest2LoopCounter - MOVW AX, #0x99aa BR !!_loop2 .end diff --git a/FreeRTOS/Demo/RL78_E2Studio_GCC/src/main.c b/FreeRTOS/Demo/RL78_E2Studio_GCC/src/main.c index 57c62ed73..cfea1f084 100644 --- a/FreeRTOS/Demo/RL78_E2Studio_GCC/src/main.c +++ b/FreeRTOS/Demo/RL78_E2Studio_GCC/src/main.c @@ -211,24 +211,15 @@ static xTimerHandle xDemoTimer = NULL; static volatile unsigned long ulDemoSoftwareTimerCounter = 0UL; /*-----------------------------------------------------------*/ -volatile unsigned char ucTemp; + short main( void ) { - ucTemp = RESF; - ucTemp = sizeof( char* ); - ucTemp = sizeof( pdTASK_CODE ); -#warning Take out all references to the P1 LED. - P1 &= 0xFE; PM1 &= 0xFE; - P1_bit.no0 = 1; - - /* Creates all the tasks and timers, then starts the scheduler. */ /* First create the 'standard demo' tasks. These are used to demonstrate API functions being used and also to test the kernel port. More information is provided on the FreeRTOS.org WEB site. */ vStartDynamicPriorityTasks(); -#warning Runs if the debugger is not connected and vStartDynamicPriorityTasks() is commented out. vStartPolledQueueTasks( tskIDLE_PRIORITY ); vCreateBlockTimeTasks(); @@ -262,8 +253,10 @@ short main( void ) /* Finally start the scheduler running. */ vTaskStartScheduler(); - /* If this line is reached then vTaskStartScheduler() returned because there - was insufficient heap memory remaining for the idle task to be created. */ + /* If all is well execution will never reach here as the scheduler will be + running. If this null loop is reached then it is likely there was + insufficient FreeRTOS heap available for the idle task and/or timer task to + be created. See http://www.freertos.org/a00111.html. */ for( ;; ); } /*-----------------------------------------------------------*/ @@ -353,12 +346,6 @@ static unsigned short usLastRegTest1Counter = 0, usLastRegTest2Counter = 0; /* Toggle the LED. The toggle rate will depend on whether or not an error has been found in any tasks. */ LED_BIT = !LED_BIT; - - if( xTaskGetTickCount() > ( ( portTickType ) 10000 / portTICK_RATE_MS ) ) - { - /* Turn off the LED used to visualise a reset. */ - P1_bit.no0 = 0; - } } /*-----------------------------------------------------------*/ @@ -379,7 +366,6 @@ void vApplicationMallocFailedHook( void ) timers, and semaphores. The size of the FreeRTOS heap is set by the configTOTAL_HEAP_SIZE configuration constant in FreeRTOSConfig.h. */ taskDISABLE_INTERRUPTS(); - P1_bit.no0 = 0; for( ;; ); } /*-----------------------------------------------------------*/ @@ -393,7 +379,6 @@ void vApplicationStackOverflowHook( xTaskHandle pxTask, signed char *pcTaskName configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook function is called if a stack overflow is detected. */ taskDISABLE_INTERRUPTS(); - P1_bit.no0 = 0; for( ;; ); } /*-----------------------------------------------------------*/ @@ -453,7 +438,15 @@ static void prvRegTest2Entry( void *pvParameters ) void vAssertCalled( void ) { - taskDISABLE_INTERRUPTS(); - P1_bit.no0 = 0; - for( ;; ); +volatile unsigned long ul = 0; + taskENTER_CRITICAL(); + { + /* Set ul to a non-zero value using the debugger to step out of this + function. */ + while( ul == 0 ) + { + __asm volatile( "NOP" ); + } + } + taskEXIT_CRITICAL(); }