]> git.sur5r.net Git - freertos/blob - Demo/MB91460_Softune/SRC/main.c
Prepare for FreeRTOS V7.1.1 tag.
[freertos] / Demo / MB91460_Softune / SRC / main.c
1 /*\r
2     FreeRTOS V7.1.1 - Copyright (C) 2012 Real Time Engineers Ltd.\r
3         \r
4 \r
5     ***************************************************************************\r
6      *                                                                       *\r
7      *    FreeRTOS tutorial books are available in pdf and paperback.        *\r
8      *    Complete, revised, and edited pdf reference manuals are also       *\r
9      *    available.                                                         *\r
10      *                                                                       *\r
11      *    Purchasing FreeRTOS documentation will not only help you, by       *\r
12      *    ensuring you get running as quickly as possible and with an        *\r
13      *    in-depth knowledge of how to use FreeRTOS, it will also help       *\r
14      *    the FreeRTOS project to continue with its mission of providing     *\r
15      *    professional grade, cross platform, de facto standard solutions    *\r
16      *    for microcontrollers - completely free of charge!                  *\r
17      *                                                                       *\r
18      *    >>> See http://www.FreeRTOS.org/Documentation for details. <<<     *\r
19      *                                                                       *\r
20      *    Thank you for using FreeRTOS, and thank you for your support!      *\r
21      *                                                                       *\r
22     ***************************************************************************\r
23 \r
24 \r
25     This file is part of the FreeRTOS distribution.\r
26 \r
27     FreeRTOS is free software; you can redistribute it and/or modify it under\r
28     the terms of the GNU General Public License (version 2) as published by the\r
29     Free Software Foundation AND MODIFIED BY the FreeRTOS exception.\r
30     >>>NOTE<<< The modification to the GPL is included to allow you to\r
31     distribute a combined work that includes FreeRTOS without being obliged to\r
32     provide the source code for proprietary components outside of the FreeRTOS\r
33     kernel.  FreeRTOS is distributed in the hope that it will be useful, but\r
34     WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\r
35     or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for\r
36     more details. You should have received a copy of the GNU General Public\r
37     License and the FreeRTOS license exception along with FreeRTOS; if not it\r
38     can be viewed here: http://www.freertos.org/a00114.html and also obtained\r
39     by writing to Richard Barry, contact details for whom are available on the\r
40     FreeRTOS WEB site.\r
41 \r
42     1 tab == 4 spaces!\r
43     \r
44     ***************************************************************************\r
45      *                                                                       *\r
46      *    Having a problem?  Start by reading the FAQ "My application does   *\r
47      *    not run, what could be wrong?                                      *\r
48      *                                                                       *\r
49      *    http://www.FreeRTOS.org/FAQHelp.html                               *\r
50      *                                                                       *\r
51     ***************************************************************************\r
52 \r
53     \r
54     http://www.FreeRTOS.org - Documentation, training, latest information, \r
55     license and contact details.\r
56     \r
57     http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
58     including FreeRTOS+Trace - an indispensable productivity tool.\r
59 \r
60     Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell \r
61     the code with commercial support, indemnification, and middleware, under \r
62     the OpenRTOS brand: http://www.OpenRTOS.com.  High Integrity Systems also\r
63     provide a safety engineered and independently SIL3 certified version under \r
64     the SafeRTOS brand: http://www.SafeRTOS.com.\r
65 */\r
66 \r
67 \r
68 /*\r
69  * Creates all the demo application tasks, then starts the scheduler.  The WEB\r
70  * documentation provides more details of the demo application tasks.\r
71  * \r
72  * In addition to the standard demo tasks, the follow demo specific tasks are\r
73  * create:\r
74  *\r
75  * The "Check" task.  This only executes every three seconds but has the highest \r
76  * priority so is guaranteed to get processor time.  Its main function is to \r
77  * check that all the other tasks are still operational.  Most tasks maintain \r
78  * a unique count that is incremented each time the task successfully completes \r
79  * its function.  Should any error occur within such a task the count is \r
80  * permanently halted.  The check task inspects the count of each task to ensure \r
81  * it has changed since the last time the check task executed.  If all the count \r
82  * variables have changed all the tasks are still executing error free, and the \r
83  * check task toggles the onboard LED.  Should any task contain an error at any time \r
84  * the LED toggle rate will change from 3 seconds to 500ms.\r
85  *\r
86  * The "Register Check" tasks.  These tasks fill the CPU registers with known\r
87  * values, then check that each register still contains the expected value 0 the\r
88  * discovery of an unexpected value being indicative of an error in the RTOS\r
89  * context switch mechanism.  The register check tasks operate at low priority\r
90  * so are switched in and out frequently.\r
91  *\r
92  * The "Trace Utility" task.  This can be used to obtain trace and debug \r
93  * information via UART5.\r
94  */\r
95 \r
96 \r
97 /* Hardware specific includes. */\r
98 #include "mb91467d.h"\r
99 #include "vectors.h"\r
100 #include "watchdog.h"\r
101 \r
102 /* Scheduler includes. */\r
103 #include "FreeRTOS.h"\r
104 #include "task.h"\r
105 \r
106 /* Demo app includes. */\r
107 #include "flash.h"\r
108 #include "integer.h"\r
109 #include "comtest2.h"\r
110 #include "semtest.h"\r
111 #include "BlockQ.h"\r
112 #include "dynamic.h"\r
113 #include "flop.h"\r
114 #include "GenQTest.h"\r
115 #include "QPeek.h"\r
116 #include "blocktim.h"\r
117 #include "death.h"\r
118 #include "taskutility.h"\r
119 #include "partest.h"\r
120 #include "crflash.h"\r
121         \r
122 /* Demo task priorities. */\r
123 #define mainWATCHDOG_TASK_PRIORITY              ( tskIDLE_PRIORITY + 5 )\r
124 #define mainCHECK_TASK_PRIORITY                 ( tskIDLE_PRIORITY + 4 )\r
125 #define mainUTILITY_TASK_PRIORITY               ( tskIDLE_PRIORITY )\r
126 #define mainSEM_TEST_PRIORITY                   ( tskIDLE_PRIORITY + 3 )\r
127 #define mainCOM_TEST_PRIORITY                   ( tskIDLE_PRIORITY + 2 )\r
128 #define mainQUEUE_BLOCK_PRIORITY                ( tskIDLE_PRIORITY + 2 )\r
129 #define mainDEATH_PRIORITY                              ( tskIDLE_PRIORITY + 1 )\r
130 #define mainLED_TASK_PRIORITY                   ( tskIDLE_PRIORITY + 1 )\r
131 #define mainGENERIC_QUEUE_PRIORITY              ( tskIDLE_PRIORITY )\r
132 \r
133 /* Baud rate used by the COM test tasks. */\r
134 #define mainCOM_TEST_BAUD_RATE                  ( ( unsigned portLONG ) 19200 )\r
135 \r
136 /* The frequency at which the 'Check' tasks executes.  See the comments at the \r
137 top of the page.  When the system is operating error free the 'Check' task\r
138 toggles an LED every three seconds.  If an error is discovered in any task the\r
139 rate is increased to 500 milliseconds.  [in this case the '*' characters on the \r
140 LCD represent LEDs]*/\r
141 #define mainNO_ERROR_CHECK_DELAY                ( ( portTickType ) 3000 / portTICK_RATE_MS  )\r
142 #define mainERROR_CHECK_DELAY                   ( ( portTickType ) 500 / portTICK_RATE_MS  )\r
143 \r
144 /* The total number of LEDs available. */\r
145 #define mainNO_CO_ROUTINE_LEDs  ( 8 )\r
146 \r
147 /* The first LED used by the comtest tasks. */\r
148 #define mainCOM_TEST_LED                ( 0x05 )\r
149 \r
150 /* The LED used by the check task. */\r
151 #define mainCHECK_TEST_LED              ( 0x07 )\r
152 \r
153 /* The number of interrupt levels to use. */\r
154 #define mainINTERRUPT_LEVELS    ( 31 )\r
155 \r
156 /* The number of 'flash' co-routines to create - each toggles a different LED. */\r
157 #define mainNUM_FLASH_CO_ROUTINES       ( 8 )\r
158 \r
159 /*---------------------------------------------------------------------------*/\r
160 \r
161 /* \r
162  * The function that implements the Check task.  See the comments at the head\r
163  * of the page for implementation details.\r
164  */ \r
165 static void prvErrorChecks( void *pvParameters );\r
166 \r
167 /*\r
168  * Called by the Check task.  Returns pdPASS if all the other tasks are found\r
169  * to be operating without error - otherwise returns pdFAIL.\r
170  */\r
171 static portSHORT prvCheckOtherTasksAreStillRunning( void );\r
172 \r
173 /* \r
174  * Setup the microcontroller as used by this demo. \r
175  */\r
176 static void prvSetupHardware( void );\r
177 \r
178 /*\r
179  * Tasks that test the context switch mechanism by filling the CPU registers\r
180  * with known values then checking that each register contains the value\r
181  * expected.  Each of the two tasks use different values, and as low priority\r
182  * tasks, get swapped in and out regularly.\r
183  */\r
184 static void vFirstRegisterTestTask( void *pvParameters );\r
185 static void vSecondRegisterTestTask( void *pvParameters );\r
186 \r
187 /*---------------------------------------------------------------------------*/\r
188 \r
189 /* The variable that is set to true should an error be found in one of the \r
190 register test tasks. */\r
191 unsigned portLONG ulRegTestError = pdFALSE;\r
192 \r
193 /*---------------------------------------------------------------------------*/\r
194 \r
195 /* Start all the demo application tasks, then start the scheduler. */\r
196 void main(void)\r
197 {\r
198         /* Initialise the hardware ready for the demo. */       \r
199         prvSetupHardware();\r
200 \r
201         /* Start the standard demo application tasks. */\r
202         vStartLEDFlashTasks( mainLED_TASK_PRIORITY );   \r
203         vStartIntegerMathTasks( tskIDLE_PRIORITY );\r
204         vAltStartComTestTasks( mainCOM_TEST_PRIORITY, mainCOM_TEST_BAUD_RATE, mainCOM_TEST_LED - 1 );\r
205         vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );\r
206         vStartBlockingQueueTasks ( mainQUEUE_BLOCK_PRIORITY );  \r
207         vStartDynamicPriorityTasks();   \r
208         vStartMathTasks( tskIDLE_PRIORITY );    \r
209         vStartGenericQueueTasks( mainGENERIC_QUEUE_PRIORITY );\r
210         vStartQueuePeekTasks();\r
211         vCreateBlockTimeTasks();\r
212         vStartFlashCoRoutines( mainNUM_FLASH_CO_ROUTINES );\r
213 \r
214         /* Start the 'Check' task which is defined in this file. */\r
215         xTaskCreate( prvErrorChecks, ( signed portCHAR * ) "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );    \r
216 \r
217         /* Start the 'Register Test' tasks as described at the top of this file. */\r
218         xTaskCreate( vFirstRegisterTestTask, ( signed portCHAR * ) "Reg1", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );\r
219         xTaskCreate( vSecondRegisterTestTask, ( signed portCHAR * ) "Reg2", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );\r
220 \r
221         /* Start the task that write trace information to the UART. */  \r
222         vUtilityStartTraceTask( mainUTILITY_TASK_PRIORITY );\r
223 \r
224         /* If we are going to service the watchdog from within a task, then create\r
225         the task here. */       \r
226         #if WATCHDOG == WTC_IN_TASK     \r
227                 vStartWatchdogTask( mainWATCHDOG_TASK_PRIORITY );\r
228         #endif          \r
229         \r
230         /* The suicide tasks must be started last as they record the number of other\r
231         tasks that exist within the system.  The value is then used to ensure at run\r
232         time the number of tasks that exists is within expected bounds. */\r
233         vCreateSuicidalTasks( mainDEATH_PRIORITY );\r
234 \r
235         /* Now start the scheduler.  Following this call the created tasks should\r
236         be executing. */        \r
237         vTaskStartScheduler( );\r
238         \r
239         /* vTaskStartScheduler() will only return if an error occurs while the \r
240         idle task is being created. */\r
241         for( ;; );\r
242 }\r
243 /*-----------------------------------------------------------*/\r
244 \r
245 static void prvErrorChecks( void *pvParameters )\r
246 {\r
247 portTickType xDelayPeriod = mainNO_ERROR_CHECK_DELAY, xLastExecutionTime;\r
248 \r
249         /* Initialise xLastExecutionTime so the first call to vTaskDelayUntil()\r
250         works correctly. */\r
251         xLastExecutionTime = xTaskGetTickCount();\r
252 \r
253         /* Cycle for ever, delaying then checking all the other tasks are still\r
254         operating without error. */\r
255         for( ;; )\r
256         {\r
257                 /* Wait until it is time to check again.  The time we wait here depends\r
258                 on whether an error has been detected or not.  When an error is \r
259                 detected the time is shortened resulting in a faster LED flash rate. */\r
260                 /* Perform this check every mainCHECK_DELAY milliseconds. */\r
261                 vTaskDelayUntil( &xLastExecutionTime, xDelayPeriod );\r
262 \r
263                 /* See if the other tasks are all ok. */\r
264                 if( prvCheckOtherTasksAreStillRunning() != pdPASS )\r
265                 {\r
266                         /* An error occurred in one of the tasks so shorten the delay \r
267                         period - which has the effect of increasing the frequency of the\r
268                         LED toggle. */\r
269                         xDelayPeriod = mainERROR_CHECK_DELAY;\r
270                 }\r
271 \r
272                 /* Flash! */\r
273                 vParTestToggleLED( mainCHECK_TEST_LED );\r
274         }\r
275 }\r
276 /*-----------------------------------------------------------*/\r
277 \r
278 static portSHORT prvCheckOtherTasksAreStillRunning( void )\r
279 {\r
280 portBASE_TYPE lReturn = pdPASS;\r
281 \r
282         /* The demo tasks maintain a count that increments every cycle of the task\r
283         provided that the task has never encountered an error.  This function \r
284         checks the counts maintained by the tasks to ensure they are still being\r
285         incremented.  A count remaining at the same value between calls therefore\r
286         indicates that an error has been detected. */\r
287 \r
288         if( xAreIntegerMathsTaskStillRunning() != pdTRUE )\r
289         {\r
290                 lReturn = pdFAIL;\r
291         }\r
292 \r
293         if( xAreComTestTasksStillRunning() != pdTRUE )\r
294         {\r
295                 lReturn = pdFAIL;\r
296         }\r
297         \r
298         if( xAreSemaphoreTasksStillRunning() != pdTRUE )\r
299         {\r
300                 lReturn = pdFAIL;\r
301         }\r
302         \r
303         if( xAreBlockingQueuesStillRunning() != pdTRUE )\r
304         {\r
305                 lReturn = pdFAIL;\r
306         }\r
307         \r
308         if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )\r
309         {\r
310                 lReturn = pdFAIL;\r
311         }\r
312         \r
313         if( xAreMathsTaskStillRunning() != pdTRUE )\r
314         {\r
315                 lReturn = pdFAIL;\r
316         }\r
317         \r
318         if( xIsCreateTaskStillRunning() != pdTRUE )\r
319         {\r
320                 lReturn = pdFAIL;\r
321         }\r
322         \r
323         if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )\r
324         {\r
325                 lReturn = pdFAIL;\r
326         }\r
327         \r
328         if ( xAreGenericQueueTasksStillRunning() != pdTRUE )\r
329         {\r
330                 lReturn = pdFAIL;\r
331         }\r
332         \r
333         if ( xAreQueuePeekTasksStillRunning() != pdTRUE )\r
334         {\r
335                 lReturn = pdFAIL;\r
336         }\r
337 \r
338         /* Have the register test tasks found any errors? */\r
339         if( ulRegTestError != pdFALSE )\r
340         {\r
341                 lReturn = pdFAIL;\r
342         }\r
343 \r
344         return lReturn;\r
345 }\r
346 /*-----------------------------------------------------------*/\r
347 \r
348 static void prvSetupHardware( void )\r
349 {\r
350         /* Allow all interrupt levels. */\r
351         __set_il( mainINTERRUPT_LEVELS );\r
352 \r
353         /* Initialise interrupts. */\r
354         InitIrqLevels();\r
355 \r
356         /* Initialise the ports used by the LEDs. */\r
357         vParTestInitialise();\r
358 \r
359         /* If we are going to use the watchdog, then initialise it now. */\r
360         #if WATCHDOG != WTC_NONE        \r
361                 InitWatchdog();\r
362         #endif\r
363 }\r
364 /*-----------------------------------------------------------*/\r
365 \r
366 /* Idle hook function. */\r
367 #if configUSE_IDLE_HOOK == 1\r
368         void vApplicationIdleHook( void )\r
369         {\r
370                 /* Are we using the idle task to kick the watchdog?  See watchdog.h\r
371                 for watchdog kicking options. Note this is for demonstration only\r
372                 and is not a suggested method of servicing the watchdog in a real\r
373                 application. */\r
374                 #if WATCHDOG == WTC_IN_IDLE\r
375                         Kick_Watchdog();\r
376                 #endif\r
377 \r
378                 vCoRoutineSchedule();\r
379         }\r
380 #else\r
381         #if WATCHDOG == WTC_IN_IDLE\r
382                 #error configUSE_IDLE_HOOK must be set to 1 in FreeRTOSConfig.h if the watchdog is being cleared in the idle task hook.\r
383         #endif\r
384 #endif\r
385 \r
386 /*-----------------------------------------------------------*/\r
387 \r
388 /* Tick hook function. */\r
389 #if configUSE_TICK_HOOK == 1\r
390         void vApplicationTickHook( void )\r
391         {\r
392                 /* Are we using the tick to kick the watchdog?  See watchdog.h\r
393                 for watchdog kicking options.  Note this is for demonstration\r
394                 only and is not a suggested method of servicing the watchdog in\r
395                 a real application. */\r
396                 #if WATCHDOG == WTC_IN_TICK\r
397                         Kick_Watchdog();\r
398                 #endif\r
399         }\r
400 #else\r
401         #if WATCHDOG == WTC_IN_TICK\r
402                 #error configUSE_TICK_HOOK must be set to 1 in FreeRTOSConfig.h if the watchdog is being cleared in the tick hook.\r
403         #endif\r
404 #endif\r
405 /*-----------------------------------------------------------*/\r
406 \r
407 static void vFirstRegisterTestTask( void *pvParameters )\r
408 {\r
409 extern volatile unsigned portLONG ulCriticalNesting;\r
410 \r
411         /* Fills the registers with known values (different to the values\r
412         used in vSecondRegisterTestTask()), then checks that the registers still\r
413         all contain the expected value.  This is done to test the context save\r
414         and restore mechanism as this task is swapped onto and off of the CPU. */\r
415 \r
416         for( ;; )\r
417         {\r
418                 #pragma asm\r
419                         ;Load known values into each register.\r
420                         LDI     #0x11111111, R0\r
421                         LDI     #0x22222222, R1\r
422                         LDI     #0x33333333, R2\r
423                         LDI #0x44444444, R3\r
424                         LDI     #0x55555555, R4\r
425                         LDI     #0x66666666, R5\r
426                         LDI     #0x77777777, R6\r
427                         LDI     #0x88888888, R7\r
428                         LDI     #0x99999999, R8\r
429                         LDI     #0xaaaaaaaa, R9\r
430                         LDI     #0xbbbbbbbb, R10\r
431                         LDI     #0xcccccccc, R11\r
432                         LDI     #0xdddddddd, R12\r
433                         \r
434                         ;Check each register still contains the expected value.\r
435                         LDI #0x11111111, R13\r
436                         CMP R13, R0\r
437                         BNE First_Set_Error\r
438 \r
439                         LDI #0x22222222, R13\r
440                         CMP R13, R1\r
441                         BNE First_Set_Error\r
442 \r
443                         LDI #0x33333333, R13\r
444                         CMP R13, R2\r
445                         BNE First_Set_Error\r
446 \r
447                         LDI #0x44444444, R13\r
448                         CMP R13, R3\r
449                         BNE First_Set_Error\r
450 \r
451                         LDI #0x55555555, R13\r
452                         CMP R13, R4\r
453                         BNE First_Set_Error\r
454 \r
455                         LDI #0x66666666, R13\r
456                         CMP R13, R5\r
457                         BNE First_Set_Error\r
458 \r
459                         LDI #0x77777777, R13\r
460                         CMP R13, R6\r
461                         BNE First_Set_Error\r
462 \r
463                         LDI #0x88888888, R13\r
464                         CMP R13, R7\r
465                         BNE First_Set_Error\r
466 \r
467                         LDI #0x99999999, R13\r
468                         CMP R13, R8\r
469                         BNE First_Set_Error\r
470 \r
471                         LDI #0xaaaaaaaa, R13\r
472                         CMP R13, R9\r
473                         BNE First_Set_Error\r
474 \r
475                         LDI #0xbbbbbbbb, R13\r
476                         CMP R13, R10\r
477                         BNE First_Set_Error\r
478 \r
479                         LDI #0xcccccccc, R13\r
480                         CMP R13, R11\r
481                         BNE First_Set_Error\r
482 \r
483                         LDI #0xdddddddd, R13\r
484                         CMP R13, R12\r
485                         BNE First_Set_Error\r
486 \r
487                         BRA First_Start_Next_Loop\r
488 \r
489                 First_Set_Error:\r
490 \r
491                         ; Latch that an error has occurred.\r
492                         LDI #_ulRegTestError, R0                        \r
493                         LDI #0x00000001, R1\r
494                         ST R1, @R0\r
495 \r
496 \r
497                 First_Start_Next_Loop:\r
498 \r
499 \r
500                 #pragma endasm\r
501         }\r
502 }\r
503 /*-----------------------------------------------------------*/\r
504 \r
505 static void vSecondRegisterTestTask( void *pvParameters )\r
506 {\r
507 extern volatile unsigned portLONG ulCriticalNesting;\r
508 \r
509         /* Fills the registers with known values (different to the values\r
510         used in vFirstRegisterTestTask()), then checks that the registers still\r
511         all contain the expected value.  This is done to test the context save\r
512         and restore mechanism as this task is swapped onto and off of the CPU. */\r
513 \r
514         for( ;; )\r
515         {\r
516                 #pragma asm\r
517                         ;Load known values into each register.\r
518                         LDI     #0x11111111, R1\r
519                         LDI     #0x22222222, R2\r
520                         INT #40H\r
521                         LDI     #0x33333333, R3\r
522                         LDI #0x44444444, R4\r
523                         LDI     #0x55555555, R5\r
524                         LDI     #0x66666666, R6\r
525                         LDI     #0x77777777, R7\r
526                         LDI     #0x88888888, R8\r
527                         LDI     #0x99999999, R9\r
528                         INT #40H\r
529                         LDI     #0xaaaaaaaa, R10\r
530                         LDI     #0xbbbbbbbb, R11\r
531                         LDI     #0xcccccccc, R12\r
532                         LDI     #0xdddddddd, R0\r
533                         \r
534                         ;Check each register still contains the expected value.\r
535                         LDI #0x11111111, R13\r
536                         CMP R13, R1\r
537                         BNE Second_Set_Error\r
538 \r
539                         LDI #0x22222222, R13\r
540                         CMP R13, R2\r
541                         BNE Second_Set_Error\r
542 \r
543                         LDI #0x33333333, R13\r
544                         CMP R13, R3\r
545                         BNE Second_Set_Error\r
546 \r
547                         LDI #0x44444444, R13\r
548                         CMP R13, R4\r
549                         BNE Second_Set_Error\r
550 \r
551                         LDI #0x55555555, R13\r
552                         CMP R13, R5\r
553                         BNE Second_Set_Error\r
554 \r
555                         INT #40H\r
556 \r
557                         LDI #0x66666666, R13\r
558                         CMP R13, R6\r
559                         BNE Second_Set_Error\r
560 \r
561                         LDI #0x77777777, R13\r
562                         CMP R13, R7\r
563                         BNE Second_Set_Error\r
564 \r
565                         LDI #0x88888888, R13\r
566                         CMP R13, R8\r
567                         BNE Second_Set_Error\r
568 \r
569                         LDI #0x99999999, R13\r
570                         CMP R13, R9\r
571                         BNE Second_Set_Error\r
572 \r
573                         INT #40H\r
574 \r
575                         LDI #0xaaaaaaaa, R13\r
576                         CMP R13, R10\r
577                         BNE Second_Set_Error\r
578 \r
579                         LDI #0xbbbbbbbb, R13\r
580                         CMP R13, R11\r
581                         BNE Second_Set_Error\r
582 \r
583                         LDI #0xcccccccc, R13\r
584                         CMP R13, R12\r
585                         BNE Second_Set_Error\r
586 \r
587                         LDI #0xdddddddd, R13\r
588                         CMP R13, R0\r
589                         BNE Second_Set_Error\r
590 \r
591                         BRA Second_Start_Next_Loop\r
592 \r
593                 Second_Set_Error:\r
594 \r
595                         ; Latch that an error has occurred.\r
596                         LDI #_ulRegTestError, R0                        \r
597                         LDI #0x00000001, R1\r
598                         ST R1, @R0\r
599 \r
600 \r
601                 Second_Start_Next_Loop:\r
602 \r
603 \r
604                 #pragma endasm\r
605         }\r
606 }\r
607 /*-----------------------------------------------------------*/\r
608 \r
609 \r