2 FreeRTOS V8.2.0 - Copyright (C) 2015 Real Time Engineers Ltd.
\r
5 VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
\r
7 This file is part of the FreeRTOS distribution.
\r
9 FreeRTOS is free software; you can redistribute it and/or modify it under
\r
10 the terms of the GNU General Public License (version 2) as published by the
\r
11 Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.
\r
13 ***************************************************************************
\r
14 >>! NOTE: The modification to the GPL is included to allow you to !<<
\r
15 >>! distribute a combined work that includes FreeRTOS without being !<<
\r
16 >>! obliged to provide the source code for proprietary components !<<
\r
17 >>! outside of the FreeRTOS kernel. !<<
\r
18 ***************************************************************************
\r
20 FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
\r
21 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
\r
22 FOR A PARTICULAR PURPOSE. Full license text is available on the following
\r
23 link: http://www.freertos.org/a00114.html
\r
25 ***************************************************************************
\r
27 * FreeRTOS provides completely free yet professionally developed, *
\r
28 * robust, strictly quality controlled, supported, and cross *
\r
29 * platform software that is more than just the market leader, it *
\r
30 * is the industry's de facto standard. *
\r
32 * Help yourself get started quickly while simultaneously helping *
\r
33 * to support the FreeRTOS project by purchasing a FreeRTOS *
\r
34 * tutorial book, reference manual, or both: *
\r
35 * http://www.FreeRTOS.org/Documentation *
\r
37 ***************************************************************************
\r
39 http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
\r
40 the FAQ page "My application does not run, what could be wrong?". Have you
\r
41 defined configASSERT()?
\r
43 http://www.FreeRTOS.org/support - In return for receiving this top quality
\r
44 embedded software for free we request you assist our global community by
\r
45 participating in the support forum.
\r
47 http://www.FreeRTOS.org/training - Investing in training allows your team to
\r
48 be as productive as possible as early as possible. Now you can receive
\r
49 FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
\r
50 Ltd, and the world's leading authority on the world's leading RTOS.
\r
52 http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
\r
53 including FreeRTOS+Trace - an indispensable productivity tool, a DOS
\r
54 compatible FAT file system, and our tiny thread aware UDP/IP stack.
\r
56 http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
\r
57 Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
\r
59 http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
\r
60 Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
\r
61 licenses offer ticketed support, indemnification and commercial middleware.
\r
63 http://www.SafeRTOS.com - High Integrity Systems also provide a safety
\r
64 engineered and independently SIL3 certified version for use in safety and
\r
65 mission critical applications that require provable dependability.
\r
70 /* ****************************************************************************
\r
71 * This project includes a lot of tasks and tests and is therefore complex.
\r
72 * If you would prefer a much simpler project to get started with then select
\r
73 * the 'Blinky' build configuration within the HEW IDE.
\r
74 * ****************************************************************************
\r
76 * Creates all the demo application tasks, then starts the scheduler. The web
\r
77 * documentation provides more details of the standard demo application tasks,
\r
78 * which provide no particular functionality but do provide a good example of
\r
79 * how to use the FreeRTOS API. The tasks defined in flop.c are included in the
\r
80 * set of standard demo tasks to ensure the floating point unit gets some
\r
83 * In addition to the standard demo tasks, the following tasks and tests are
\r
84 * defined and/or created within this file:
\r
86 * Webserver ("uIP") task - This serves a number of dynamically generated WEB
\r
87 * pages to a standard WEB browser. The IP and MAC addresses are configured by
\r
88 * constants defined at the bottom of FreeRTOSConfig.h. Use either a standard
\r
89 * Ethernet cable to connect through a hug, or a cross over (point to point)
\r
90 * cable to connect directly. Ensure the IP address used is compatible with the
\r
91 * IP address of the machine running the browser - the easiest way to achieve
\r
92 * this is to ensure the first three octets of the IP addresses are the same.
\r
94 * "Reg test" tasks - These fill the registers with known values, then check
\r
95 * that each register still contains its expected value. Each task uses
\r
96 * different values. The tasks run with very low priority so get preempted
\r
97 * very frequently. A check variable is incremented on each iteration of the
\r
98 * test loop. A register containing an unexpected value is indicative of an
\r
99 * error in the context switching mechanism and will result in a branch to a
\r
100 * null loop - which in turn will prevent the check variable from incrementing
\r
101 * any further and allow the check task (described below) to determine that an
\r
102 * error has occurred. The nature of the reg test tasks necessitates that they
\r
103 * are written in assembly code.
\r
105 * "Check" task - This only executes every five seconds but has a high priority
\r
106 * to ensure it gets processor time. Its main function is to check that all the
\r
107 * standard demo tasks are still operational. While no errors have been
\r
108 * discovered the check task will toggle LED 5 every 5 seconds - the toggle
\r
109 * rate increasing to 200ms being a visual indication that at least one task has
\r
110 * reported unexpected behaviour.
\r
112 * "High frequency timer test" - A high frequency periodic interrupt is
\r
113 * generated using a timer - the interrupt is assigned a priority above
\r
114 * configMAX_SYSCALL_INTERRUPT_PRIORITY so should not be effected by anything
\r
115 * the kernel is doing. The frequency and priority of the interrupt, in
\r
116 * combination with other standard tests executed in this demo, should result
\r
117 * in interrupts nesting at least 3 and probably 4 deep. This test is only
\r
118 * included in build configurations that have the optimiser switched on. In
\r
119 * optimised builds the count of high frequency ticks is used as the time base
\r
120 * for the run time stats.
\r
122 * *NOTE 1* If LED5 is toggling every 5 seconds then all the demo application
\r
123 * tasks are executing as expected and no errors have been reported in any
\r
124 * tasks. The toggle rate increasing to 200ms indicates that at least one task
\r
125 * has reported unexpected behaviour.
\r
127 * *NOTE 2* vApplicationSetupTimerInterrupt() is called by the kernel to let
\r
128 * the application set up a timer to generate the tick interrupt. In this
\r
129 * example a compare match timer is used for this purpose.
\r
131 * *NOTE 3* The CPU must be in Supervisor mode when the scheduler is started.
\r
132 * The PowerON_Reset_PC() supplied in resetprg.c with this demo has
\r
133 * Change_PSW_PM_to_UserMode() commented out to ensure this is the case.
\r
135 * *NOTE 4* The IntQueue common demo tasks test interrupt nesting and make use
\r
136 * of all the 8bit timers (as two cascaded 16bit units).
\r
139 /* Hardware specific includes. */
\r
140 #include "iodefine.h"
\r
142 /* Kernel includes. */
\r
143 #include "FreeRTOS.h"
\r
146 /* Standard demo includes. */
\r
147 #include "partest.h"
\r
149 #include "IntQueue.h"
\r
150 #include "BlockQ.h"
\r
152 #include "integer.h"
\r
153 #include "blocktim.h"
\r
154 #include "semtest.h"
\r
156 #include "GenQTest.h"
\r
158 #include "recmutex.h"
\r
161 /* Values that are passed into the reg test tasks using the task parameter. The
\r
162 tasks check that the values are passed in correctly. */
\r
163 #define mainREG_TEST_1_PARAMETER ( 0x12121212UL )
\r
164 #define mainREG_TEST_2_PARAMETER ( 0x12345678UL )
\r
166 /* Priorities at which the tasks are created. */
\r
167 #define mainCHECK_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
\r
168 #define mainQUEUE_POLL_PRIORITY ( tskIDLE_PRIORITY + 1 )
\r
169 #define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1 )
\r
170 #define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
171 #define mainCREATOR_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
\r
172 #define mainFLASH_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
\r
173 #define mainuIP_TASK_PRIORITY ( tskIDLE_PRIORITY + 2 )
\r
174 #define mainINTEGER_TASK_PRIORITY ( tskIDLE_PRIORITY )
\r
175 #define mainGEN_QUEUE_TASK_PRIORITY ( tskIDLE_PRIORITY )
\r
176 #define mainFLOP_TASK_PRIORITY ( tskIDLE_PRIORITY )
\r
178 /* The WEB server uses string handling functions, which in turn use a bit more
\r
179 stack than most of the other tasks. */
\r
180 #define mainuIP_STACK_SIZE ( configMINIMAL_STACK_SIZE * 3 )
\r
182 /* The LED toggled by the check task. */
\r
183 #define mainCHECK_LED ( 5 )
\r
185 /* The rate at which mainCHECK_LED will toggle when all the tasks are running
\r
186 without error. Controlled by the check task as described at the top of this
\r
188 #define mainNO_ERROR_CYCLE_TIME ( 5000 / portTICK_PERIOD_MS )
\r
190 /* The rate at which mainCHECK_LED will toggle when an error has been reported
\r
191 by at least one task. Controlled by the check task as described at the top of
\r
193 #define mainERROR_CYCLE_TIME ( 200 / portTICK_PERIOD_MS )
\r
197 * vApplicationMallocFailedHook() will only be called if
\r
198 * configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h. It is a hook
\r
199 * function that will execute if a call to pvPortMalloc() fails.
\r
200 * pvPortMalloc() is called internally by the kernel whenever a task, queue or
\r
201 * semaphore is created. It is also called by various parts of the demo
\r
204 void vApplicationMallocFailedHook( void );
\r
207 * vApplicationIdleHook() will only be called if configUSE_IDLE_HOOK is set to 1
\r
208 * in FreeRTOSConfig.h. It is a hook function that is called on each iteration
\r
209 * of the idle task. It is essential that code added to this hook function
\r
210 * never attempts to block in any way (for example, call xQueueReceive() with
\r
211 * a block time specified). If the application makes use of the vTaskDelete()
\r
212 * API function (as this demo application does) then it is also important that
\r
213 * vApplicationIdleHook() is permitted to return to its calling function because
\r
214 * it is the responsibility of the idle task to clean up memory allocated by the
\r
215 * kernel to any task that has since been deleted.
\r
217 void vApplicationIdleHook( void );
\r
220 * vApplicationStackOverflowHook() will only be called if
\r
221 * configCHECK_FOR_STACK_OVERFLOW is set to a non-zero value. The handle and
\r
222 * name of the offending task should be passed in the function parameters, but
\r
223 * it is possible that the stack overflow will have corrupted these - in which
\r
224 * case pxCurrentTCB can be inspected to find the same information.
\r
226 void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName );
\r
229 * The reg test tasks as described at the top of this file.
\r
231 static void prvRegTest1Task( void *pvParameters );
\r
232 static void prvRegTest2Task( void *pvParameters );
\r
235 * The actual implementation of the reg test functionality, which, because of
\r
236 * the direct register access, have to be in assembly.
\r
238 static void prvRegTest1Implementation( void ) __attribute__((naked));
\r
239 static void prvRegTest2Implementation( void ) __attribute__((naked));
\r
243 * The check task as described at the top of this file.
\r
245 static void prvCheckTask( void *pvParameters );
\r
248 * Contains the implementation of the WEB server.
\r
250 extern void vuIP_Task( void *pvParameters );
\r
252 /*-----------------------------------------------------------*/
\r
254 /* Variables that are incremented on each iteration of the reg test tasks -
\r
255 provided the tasks have not reported any errors. The check task inspects these
\r
256 variables to ensure they are still incrementing as expected. If a variable
\r
257 stops incrementing then it is likely that its associate task has stalled. */
\r
258 unsigned long ulRegTest1CycleCount = 0UL, ulRegTest2CycleCount = 0UL;
\r
260 /* The status message that is displayed at the bottom of the "task stats" web
\r
261 page, which is served by the uIP task. This will report any errors picked up
\r
262 by the reg test task. */
\r
263 static const char *pcStatusMessage = NULL;
\r
265 /*-----------------------------------------------------------*/
\r
269 extern void HardwareSetup( void );
\r
271 /* Renesas provided CPU configuration routine. The clocks are configured in
\r
275 /* Turn all LEDs off. */
\r
276 vParTestInitialise();
\r
278 /* Start the reg test tasks which test the context switching mechanism. */
\r
279 xTaskCreate( prvRegTest1Task, "RegTst1", configMINIMAL_STACK_SIZE, ( void * ) mainREG_TEST_1_PARAMETER, tskIDLE_PRIORITY, NULL );
\r
280 xTaskCreate( prvRegTest2Task, "RegTst2", configMINIMAL_STACK_SIZE, ( void * ) mainREG_TEST_2_PARAMETER, tskIDLE_PRIORITY, NULL );
\r
282 /* The web server task. */
\r
283 xTaskCreate( vuIP_Task, "uIP", mainuIP_STACK_SIZE, NULL, mainuIP_TASK_PRIORITY, NULL );
\r
285 /* Start the check task as described at the top of this file. */
\r
286 xTaskCreate( prvCheckTask, "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
\r
288 /* Create the standard demo tasks. */
\r
289 vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
\r
290 vCreateBlockTimeTasks();
\r
291 vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
\r
292 vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
\r
293 vStartIntegerMathTasks( mainINTEGER_TASK_PRIORITY );
\r
294 vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY );
\r
295 vStartLEDFlashTasks( mainFLASH_TASK_PRIORITY );
\r
296 vStartQueuePeekTasks();
\r
297 vStartRecursiveMutexTasks();
\r
298 vStartInterruptQueueTasks();
\r
299 vStartMathTasks( mainFLOP_TASK_PRIORITY );
\r
301 /* The suicide tasks must be created last as they need to know how many
\r
302 tasks were running prior to their creation in order to ascertain whether
\r
303 or not the correct/expected number of tasks are running at any given time. */
\r
304 vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );
\r
306 /* Start the tasks running. */
\r
307 vTaskStartScheduler();
\r
309 /* If all is well we will never reach here as the scheduler will now be
\r
310 running. If we do reach here then it is likely that there was insufficient
\r
311 heap available for the idle task to be created. */
\r
316 /*-----------------------------------------------------------*/
\r
318 static void prvCheckTask( void *pvParameters )
\r
320 static volatile unsigned long ulLastRegTest1CycleCount = 0UL, ulLastRegTest2CycleCount = 0UL;
\r
321 TickType_t xNextWakeTime, xCycleFrequency = mainNO_ERROR_CYCLE_TIME;
\r
322 extern void vSetupHighFrequencyTimer( void );
\r
324 /* If this is being executed then the kernel has been started. Start the high
\r
325 frequency timer test as described at the top of this file. This is only
\r
326 included in the optimised build configuration - otherwise it takes up too much
\r
328 #ifdef INCLUDE_HIGH_FREQUENCY_TIMER_TEST
\r
329 vSetupHighFrequencyTimer();
\r
332 /* Initialise xNextWakeTime - this only needs to be done once. */
\r
333 xNextWakeTime = xTaskGetTickCount();
\r
337 /* Place this task in the blocked state until it is time to run again. */
\r
338 vTaskDelayUntil( &xNextWakeTime, xCycleFrequency );
\r
340 /* Check the standard demo tasks are running without error. */
\r
341 if( xAreGenericQueueTasksStillRunning() != pdTRUE )
\r
343 pcStatusMessage = "Error: GenQueue";
\r
345 else if( xAreQueuePeekTasksStillRunning() != pdTRUE )
\r
347 pcStatusMessage = "Error: QueuePeek\r\n";
\r
349 else if( xAreBlockingQueuesStillRunning() != pdTRUE )
\r
351 pcStatusMessage = "Error: BlockQueue\r\n";
\r
353 else if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )
\r
355 pcStatusMessage = "Error: BlockTime\r\n";
\r
357 else if( xAreSemaphoreTasksStillRunning() != pdTRUE )
\r
359 pcStatusMessage = "Error: SemTest\r\n";
\r
361 else if( xArePollingQueuesStillRunning() != pdTRUE )
\r
363 pcStatusMessage = "Error: PollQueue\r\n";
\r
365 else if( xIsCreateTaskStillRunning() != pdTRUE )
\r
367 pcStatusMessage = "Error: Death\r\n";
\r
369 else if( xAreIntegerMathsTaskStillRunning() != pdTRUE )
\r
371 pcStatusMessage = "Error: IntMath\r\n";
\r
373 else if( xAreRecursiveMutexTasksStillRunning() != pdTRUE )
\r
375 pcStatusMessage = "Error: RecMutex\r\n";
\r
377 else if( xAreIntQueueTasksStillRunning() != pdPASS )
\r
379 pcStatusMessage = "Error: IntQueue\r\n";
\r
381 else if( xAreMathsTaskStillRunning() != pdPASS )
\r
383 pcStatusMessage = "Error: Flop\r\n";
\r
386 /* Check the reg test tasks are still cycling. They will stop incrementing
\r
387 their loop counters if they encounter an error. */
\r
388 if( ulRegTest1CycleCount == ulLastRegTest1CycleCount )
\r
390 pcStatusMessage = "Error: RegTest1\r\n";
\r
393 if( ulRegTest2CycleCount == ulLastRegTest2CycleCount )
\r
395 pcStatusMessage = "Error: RegTest2\r\n";
\r
398 ulLastRegTest1CycleCount = ulRegTest1CycleCount;
\r
399 ulLastRegTest2CycleCount = ulRegTest2CycleCount;
\r
401 /* Toggle the check LED to give an indication of the system status. If
\r
402 the LED toggles every 5 seconds then everything is ok. A faster toggle
\r
403 indicates an error. */
\r
404 vParTestToggleLED( mainCHECK_LED );
\r
406 /* Ensure the LED toggles at a faster rate if an error has occurred. */
\r
407 if( pcStatusMessage != NULL )
\r
409 /* Increase the rate at which this task cycles, which will increase the
\r
410 rate at which mainCHECK_LED flashes to give visual feedback that an error
\r
412 xCycleFrequency = mainERROR_CYCLE_TIME;
\r
416 /*-----------------------------------------------------------*/
\r
418 /* The RX port uses this callback function to configure its tick interrupt.
\r
419 This allows the application to choose the tick interrupt source. */
\r
420 void vApplicationSetupTimerInterrupt( void )
\r
422 /* Enable compare match timer 0. */
\r
425 /* Interrupt on compare match. */
\r
426 CMT0.CMCR.BIT.CMIE = 1;
\r
428 /* Set the compare match value. */
\r
429 CMT0.CMCOR = ( unsigned short ) ( ( ( configPERIPHERAL_CLOCK_HZ / configTICK_RATE_HZ ) -1 ) / 8 );
\r
431 /* Divide the PCLK by 8. */
\r
432 CMT0.CMCR.BIT.CKS = 0;
\r
434 /* Enable the interrupt... */
\r
435 _IEN( _CMT0_CMI0 ) = 1;
\r
437 /* ...and set its priority to the application defined kernel priority. */
\r
438 _IPR( _CMT0_CMI0 ) = configKERNEL_INTERRUPT_PRIORITY;
\r
440 /* Start the timer. */
\r
441 CMT.CMSTR0.BIT.STR0 = 1;
\r
443 /*-----------------------------------------------------------*/
\r
445 /* This function is explained by the comments above its prototype at the top
\r
447 void vApplicationMallocFailedHook( void )
\r
451 /*-----------------------------------------------------------*/
\r
453 /* This function is explained by the comments above its prototype at the top
\r
455 void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName )
\r
459 /*-----------------------------------------------------------*/
\r
461 /* This function is explained by the comments above its prototype at the top
\r
463 void vApplicationIdleHook( void )
\r
466 /*-----------------------------------------------------------*/
\r
468 /* This function is explained in the comments at the top of this file. */
\r
469 static void prvRegTest1Task( void *pvParameters )
\r
471 if( ( ( unsigned long ) pvParameters ) != mainREG_TEST_1_PARAMETER )
\r
473 /* The parameter did not contain the expected value. */
\r
476 /* Stop the tick interrupt so its obvious something has gone wrong. */
\r
477 taskDISABLE_INTERRUPTS();
\r
481 /* This is an asm function that never returns. */
\r
482 prvRegTest1Implementation();
\r
484 /*-----------------------------------------------------------*/
\r
486 /* This function is explained in the comments at the top of this file. */
\r
487 static void prvRegTest2Task( void *pvParameters )
\r
489 if( ( ( unsigned long ) pvParameters ) != mainREG_TEST_2_PARAMETER )
\r
491 /* The parameter did not contain the expected value. */
\r
494 /* Stop the tick interrupt so its obvious something has gone wrong. */
\r
495 taskDISABLE_INTERRUPTS();
\r
499 /* This is an asm function that never returns. */
\r
500 prvRegTest2Implementation();
\r
502 /*-----------------------------------------------------------*/
\r
504 char *pcGetTaskStatusMessage( void )
\r
506 /* Not bothered about a critical section here although technically because of
\r
507 the task priorities the pointer could change it will be atomic if not near
\r
508 atomic and its not critical. */
\r
509 if( pcStatusMessage == NULL )
\r
511 return "All tasks running without error";
\r
515 return ( char * ) pcStatusMessage;
\r
518 /*-----------------------------------------------------------*/
\r
520 /* This function is explained in the comments at the top of this file. */
\r
521 static void prvRegTest1Implementation( void )
\r
525 /* Put a known value in each register. */
\r
535 "MOV #10, R10 \n" \
\r
536 "MOV #11, R11 \n" \
\r
537 "MOV #12, R12 \n" \
\r
538 "MOV #13, R13 \n" \
\r
539 "MOV #14, R14 \n" \
\r
540 "MOV #15, R15 \n" \
\r
542 /* Loop, checking each itteration that each register still contains the
\r
546 /* Push the registers that are going to get clobbered. */
\r
547 "PUSHM R14-R15 \n" \
\r
549 /* Increment the loop counter to show this task is still getting CPU time. */
\r
550 "MOV #_ulRegTest1CycleCount, R14 \n" \
\r
551 "MOV [ R14 ], R15 \n" \
\r
553 "MOV R15, [ R14 ] \n" \
\r
555 /* Yield to extend the test coverage. Set the bit in the ITU SWINTR register. */
\r
557 "MOV #0872E0H, R15 \n" \
\r
558 "MOV.B R14, [R15] \n" \
\r
562 /* Restore the clobbered registers. */
\r
563 "POPM R14-R15 \n" \
\r
565 /* Now compare each register to ensure it still contains the value that was
\r
566 set before this loop was entered. */
\r
568 "BNE RegTest1Error \n" \
\r
570 "BNE RegTest1Error \n" \
\r
572 "BNE RegTest1Error \n" \
\r
574 "BNE RegTest1Error \n" \
\r
576 "BNE RegTest1Error \n" \
\r
578 "BNE RegTest1Error \n" \
\r
580 "BNE RegTest1Error \n" \
\r
582 "BNE RegTest1Error \n" \
\r
584 "BNE RegTest1Error \n" \
\r
585 "CMP #10, R10 \n" \
\r
586 "BNE RegTest1Error \n" \
\r
587 "CMP #11, R11 \n" \
\r
588 "BNE RegTest1Error \n" \
\r
589 "CMP #12, R12 \n" \
\r
590 "BNE RegTest1Error \n" \
\r
591 "CMP #13, R13 \n" \
\r
592 "BNE RegTest1Error \n" \
\r
593 "CMP #14, R14 \n" \
\r
594 "BNE RegTest1Error \n" \
\r
595 "CMP #15, R15 \n" \
\r
596 "BNE RegTest1Error \n" \
\r
598 /* All comparisons passed, start a new itteratio of this loop. */
\r
599 "BRA TestLoop1 \n" \
\r
601 "RegTest1Error: \n" \
\r
602 /* A compare failed, just loop here so the loop counter stops incrementing
\r
603 - causing the check task to indicate the error. */
\r
604 "BRA RegTest1Error "
\r
607 /*-----------------------------------------------------------*/
\r
609 /* This function is explained in the comments at the top of this file. */
\r
610 static void prvRegTest2Implementation( void )
\r
614 /* Put a known value in each register. */
\r
615 "MOV #10H, R1 \n" \
\r
616 "MOV #20H, R2 \n" \
\r
617 "MOV #30H, R3 \n" \
\r
618 "MOV #40H, R4 \n" \
\r
619 "MOV #50H, R5 \n" \
\r
620 "MOV #60H, R6 \n" \
\r
621 "MOV #70H, R7 \n" \
\r
622 "MOV #80H, R8 \n" \
\r
623 "MOV #90H, R9 \n" \
\r
624 "MOV #100H, R10 \n" \
\r
625 "MOV #110H, R11 \n" \
\r
626 "MOV #120H, R12 \n" \
\r
627 "MOV #130H, R13 \n" \
\r
628 "MOV #140H, R14 \n" \
\r
629 "MOV #150H, R15 \n" \
\r
631 /* Loop, checking each itteration that each register still contains the
\r
635 /* Push the registers that are going to get clobbered. */
\r
636 "PUSHM R14-R15 \n" \
\r
638 /* Increment the loop counter to show this task is still getting CPU time. */
\r
639 "MOV #_ulRegTest2CycleCount, R14 \n" \
\r
640 "MOV [ R14 ], R15 \n" \
\r
642 "MOV R15, [ R14 ] \n" \
\r
644 /* Restore the clobbered registers. */
\r
645 "POPM R14-R15 \n" \
\r
647 /* Now compare each register to ensure it still contains the value that was
\r
648 set before this loop was entered. */
\r
649 "CMP #10H, R1 \n" \
\r
650 "BNE RegTest2Error \n" \
\r
651 "CMP #20H, R2 \n" \
\r
652 "BNE RegTest2Error \n" \
\r
653 "CMP #30H, R3 \n" \
\r
654 "BNE RegTest2Error \n" \
\r
655 "CMP #40H, R4 \n" \
\r
656 "BNE RegTest2Error \n" \
\r
657 "CMP #50H, R5 \n" \
\r
658 "BNE RegTest2Error \n" \
\r
659 "CMP #60H, R6 \n" \
\r
660 "BNE RegTest2Error \n" \
\r
661 "CMP #70H, R7 \n" \
\r
662 "BNE RegTest2Error \n" \
\r
663 "CMP #80H, R8 \n" \
\r
664 "BNE RegTest2Error \n" \
\r
665 "CMP #90H, R9 \n" \
\r
666 "BNE RegTest2Error \n" \
\r
667 "CMP #100H, R10 \n" \
\r
668 "BNE RegTest2Error \n" \
\r
669 "CMP #110H, R11 \n" \
\r
670 "BNE RegTest2Error \n" \
\r
671 "CMP #120H, R12 \n" \
\r
672 "BNE RegTest2Error \n" \
\r
673 "CMP #130H, R13 \n" \
\r
674 "BNE RegTest2Error \n" \
\r
675 "CMP #140H, R14 \n" \
\r
676 "BNE RegTest2Error \n" \
\r
677 "CMP #150H, R15 \n" \
\r
678 "BNE RegTest2Error \n" \
\r
680 /* All comparisons passed, start a new itteratio of this loop. */
\r
681 "BRA TestLoop2 \n" \
\r
683 "RegTest2Error: \n" \
\r
684 /* A compare failed, just loop here so the loop counter stops incrementing
\r
685 - causing the check task to indicate the error. */
\r
686 "BRA RegTest2Error "
\r