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