]> begriffs open source - cmsis-freertos/blob - Demo/RX200_RX210-RSK_Renesas/RTOSDemo/main-full.c
Update README.md - branch main is now the base branch
[cmsis-freertos] / Demo / RX200_RX210-RSK_Renesas / RTOSDemo / main-full.c
1 /*
2  * FreeRTOS V202111.00
3  * Copyright (C) 2020 Amazon.com, Inc. or its affiliates.  All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of
6  * this software and associated documentation files (the "Software"), to deal in
7  * the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9  * the Software, and to permit persons to whom the Software is furnished to do so,
10  * subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in all
13  * copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  *
22  * http://www.FreeRTOS.org
23  * http://aws.amazon.com/freertos
24  *
25  * 1 tab == 4 spaces!
26  */
27
28 /* ****************************************************************************
29  * This project includes a lot of tasks and tests and is therefore complex.
30  * If you would prefer a much simpler project to get started with then select
31  * the 'Blinky' build configuration within the HEW IDE.  The Blinky build
32  * configuration uses main-blinky.c instead of main-full.c.
33  * ****************************************************************************
34  *
35  * Creates all the demo application tasks, then starts the scheduler.  The web
36  * documentation provides more details of the standard demo application tasks,
37  * which provide no particular functionality but do provide a good example of
38  * how to use the FreeRTOS API.
39  *
40  * In addition to the standard demo tasks, the following tasks and tests are
41  * defined and/or created within this file:
42  *
43  * "Reg test" tasks - These fill the registers with known values, then 
44  * repeatedly check that each register still contains its expected value for 
45  * the lifetime of the tasks.  Each task uses different values.  The tasks run 
46  * with very low priority so get preempted very frequently.  A check variable 
47  * is incremented on each iteration of the test loop.  A register containing an 
48  * unexpected value is indicative of an error in the context switching 
49  * mechanism and will result in a branch to a null loop - which in turn will 
50  * prevent the check variable from incrementing any further and allow the check 
51  * timer (described below) to determine that an error has occurred.  The nature 
52  * of the reg test tasks necessitates that they are written in assembly code.
53  *
54  * "Check Timer" and Callback Function - The check timer period is initially 
55  * set to five seconds.  The check timer callback function checks that all the 
56  * standard demo tasks are not only still executing, but are executing without 
57  * reporting any errors.  If the check timer discovers that a task has either 
58  * stalled, or reported an error, then it changes its own period from the 
59  * initial five seconds, to just 200ms.  The check timer callback function 
60  * also toggles LED 3 each time it is called.  This provides a visual 
61  * indication of the system status:  If the LED toggles every five seconds, 
62  * then no issues have been discovered.  If the LED toggles every 200ms, then 
63  * an issue has been discovered with at least one task.
64  *
65  * "High frequency timer test" - A high frequency periodic interrupt is
66  * generated using a timer - the interrupt is assigned a priority above
67  * configMAX_SYSCALL_INTERRUPT_PRIORITY, so will not be effected by anything
68  * the kernel is doing.  The frequency and priority of the interrupt, in
69  * combination with other standard tests executed in this demo, will result
70  * in interrupts nesting at least 3 and probably 4 deep.  This test is only
71  * included in build configurations that have the optimiser switched on.
72  *
73  * "Button and LCD test" - This creates two tasks.  The first simply scrolls
74  * a message back and forth along the top line of the LCD display.  If no
75  * buttons are pushed, the second also scrolls a message back and forth, but
76  * along the bottom line of the display.  The automatic scrolling of the second
77  * line of the display can be started and stopped using button SW2.  Once 
78  * stopped it can then be manually nudged left using button SW3, and manually
79  * nudged right using button SW1.  Button pushes generate an interrupt, and the
80  * interrupt communicates with the task using a queue.
81  *
82  * *NOTE 1* vApplicationSetupTimerInterrupt() is called by the kernel to let
83  * the application set up a timer to generate the tick interrupt.  In this
84  * example a compare match timer is used for this purpose.
85  *
86  * *NOTE 2* The CPU must be in Supervisor mode when the scheduler is started.
87  * The PowerON_Reset_PC() supplied in resetprg.c with this demo has
88  * Change_PSW_PM_to_UserMode() commented out to ensure this is the case.
89  *
90  * *NOTE 3* The IntQueue common demo tasks test interrupt nesting and make use
91  * of all the 8bit timers (as two cascaded 16bit units).
92 */
93
94 /* Standard includes. */
95 #include <string.h>
96
97 /* Hardware specific includes. */
98 #include "iodefine.h"
99
100 /* Kernel includes. */
101 #include "FreeRTOS.h"
102 #include "task.h"
103 #include "timers.h"
104 #include "semphr.h"
105
106 /* Standard demo includes. */
107 #include "partest.h"
108 #include "flash.h"
109 #include "IntQueue.h"
110 #include "BlockQ.h"
111 #include "death.h"
112 #include "integer.h"
113 #include "blocktim.h"
114 #include "semtest.h"
115 #include "PollQ.h"
116 #include "GenQTest.h"
117 #include "QPeek.h"
118 #include "recmutex.h"
119
120 /* Demo specific tasks. */
121 #include "ButtonAndLCD.h"
122
123 /* Peripheral includes. */
124 #include "lcd.h"
125
126 /* Values that are passed into the reg test tasks using the task parameter.  
127 The tasks check that the values are passed in correctly. */
128 #define mainREG_TEST_1_PARAMETER        ( 0x12121212UL )
129 #define mainREG_TEST_2_PARAMETER        ( 0x12345678UL )
130
131 /* Priorities at which the tasks are created. */
132 #define mainQUEUE_POLL_PRIORITY         ( tskIDLE_PRIORITY + 1 )
133 #define mainSEM_TEST_PRIORITY           ( tskIDLE_PRIORITY + 1 )
134 #define mainBLOCK_Q_PRIORITY            ( tskIDLE_PRIORITY + 2 )
135 #define mainCREATOR_TASK_PRIORITY   ( tskIDLE_PRIORITY + 3 )
136 #define mainFLASH_TASK_PRIORITY         ( tskIDLE_PRIORITY + 1 )
137 #define mainINTEGER_TASK_PRIORITY   ( tskIDLE_PRIORITY )
138 #define mainGEN_QUEUE_TASK_PRIORITY     ( tskIDLE_PRIORITY )
139 #define mainFLOP_TASK_PRIORITY          ( tskIDLE_PRIORITY )
140
141 /* The LED toggled by the check timer. */
142 #define mainCHECK_LED                           ( 3 )
143
144 /* The period at which the check timer will expire, in ms, provided no errors
145 have been reported by any of the standard demo tasks.  ms are converted to the
146 equivalent in ticks using the portTICK_PERIOD_MS constant. */
147 #define mainCHECK_TIMER_PERIOD_MS                       ( 5000UL / portTICK_PERIOD_MS )
148
149 /* The period at which the check timer will expire, in ms, if an error has been
150 reported in one of the standard demo tasks.  ms are converted to the equivalent
151 in ticks using the portTICK_PERIOD_MS constant. */
152 #define mainERROR_CHECK_TIMER_PERIOD_MS         ( 200UL / portTICK_PERIOD_MS )
153
154 /* A block time of zero simple means "Don't Block". */
155 #define mainDONT_BLOCK                          ( 0UL )
156
157 /*
158  * vApplicationMallocFailedHook() will only be called if
159  * configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h.  It is a hook
160  * function that will execute if a call to pvPortMalloc() fails.
161  * pvPortMalloc() is called internally by the kernel whenever a task, queue or
162  * semaphore is created.  It is also called by various parts of the demo
163  * application.
164  */
165 void vApplicationMallocFailedHook( void );
166
167 /*
168  * vApplicationIdleHook() will only be called if configUSE_IDLE_HOOK is set to 1
169  * in FreeRTOSConfig.h.  It is a hook function that is called on each iteration
170  * of the idle task.  It is essential that code added to this hook function
171  * never attempts to block in any way (for example, call xQueueReceive() with
172  * a block time specified).  If the application makes use of the vTaskDelete()
173  * API function (as this demo application does) then it is also important that
174  * vApplicationIdleHook() is permitted to return to its calling function because
175  * it is the responsibility of the idle task to clean up memory allocated by the
176  * kernel to any task that has since been deleted.
177  */
178 void vApplicationIdleHook( void );
179
180 /*
181  * vApplicationStackOverflowHook() will only be called if
182  * configCHECK_FOR_STACK_OVERFLOW is set to a non-zero value.  The handle and
183  * name of the offending task should be passed in the function parameters, but
184  * it is possible that the stack overflow will have corrupted these - in which
185  * case pxCurrentTCB can be inspected to find the same information.
186  */
187 void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName );
188
189 /*
190  * The reg test tasks as described at the top of this file.
191  */
192 static void prvRegTest1Task( void *pvParameters );
193 static void prvRegTest2Task( void *pvParameters );
194
195 /*
196  * The actual implementation of the reg test functionality, which, because of
197  * the direct register access, have to be in assembly.
198  */
199 static void prvRegTest1Implementation( void );
200 static void prvRegTest2Implementation( void );
201
202 /*
203  * The check timer callback function, as described at the top of this file.
204  */
205 static void prvCheckTimerCallback( TimerHandle_t xTimer );
206
207
208 /*-----------------------------------------------------------*/
209
210 /* Variables that are incremented on each iteration of the reg test tasks -
211 provided the tasks have not reported any errors.  The check timer inspects these
212 variables to ensure they are still incrementing as expected.  If a variable
213 stops incrementing then it is likely that its associate task has stalled. */
214 unsigned long ulRegTest1CycleCount = 0UL, ulRegTest2CycleCount = 0UL;
215
216 /* The check timer.  This uses prvCheckTimerCallback() as its callback
217 function. */
218 static TimerHandle_t xCheckTimer = NULL;
219
220 /*-----------------------------------------------------------*/
221
222 void main(void)
223 {
224 extern void HardwareSetup( void );
225
226         /* Renesas provided CPU configuration routine.  The clocks are configured in
227         here. */
228         HardwareSetup();        
229
230         /* Turn all LEDs off. */
231         vParTestInitialise();
232
233         /* Start the reg test tasks which test the context switching mechanism. */
234         xTaskCreate( prvRegTest1Task, "RegTst1", configMINIMAL_STACK_SIZE, ( void * ) mainREG_TEST_1_PARAMETER, tskIDLE_PRIORITY, NULL );
235         xTaskCreate( prvRegTest2Task, "RegTst2", configMINIMAL_STACK_SIZE, ( void * ) mainREG_TEST_2_PARAMETER, tskIDLE_PRIORITY, NULL );
236
237         /* The button and LCD tasks, as described at the top of this file. */
238         vStartButtonAndLCDDemo();
239
240         /* Create the standard demo tasks. */
241         vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
242         vCreateBlockTimeTasks();
243         vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
244         vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
245         vStartIntegerMathTasks( mainINTEGER_TASK_PRIORITY );
246         vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY );
247         vStartLEDFlashTasks( mainFLASH_TASK_PRIORITY );
248         vStartQueuePeekTasks();
249         vStartRecursiveMutexTasks();
250         vStartInterruptQueueTasks();
251
252         /* The suicide tasks must be created last as they need to know how many
253         tasks were running prior to their creation in order to ascertain whether
254         or not the correct/expected number of tasks are running at any given time. */
255         vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );
256
257         /* Create the software timer that performs the 'check' functionality,
258         as described at the top of this file. */
259         xCheckTimer = xTimerCreate( "CheckTimer",/* A text name, purely to help debugging. */
260                                                                 ( mainCHECK_TIMER_PERIOD_MS ),          /* The timer period, in this case 5000ms (5s). */
261                                                                 pdTRUE,                                                         /* This is an auto-reload timer, so xAutoReload is set to pdTRUE. */
262                                                                 ( void * ) 0,                                           /* The ID is not used, so can be set to anything. */
263                                                                 prvCheckTimerCallback                           /* The callback function that inspects the status of all the other tasks. */
264                                                           );
265                                                           
266         configASSERT( xCheckTimer );
267         
268         /* Start the check timer.  It will actually start when the scheduler is
269         started. */
270         xTimerStart( xCheckTimer, mainDONT_BLOCK );
271
272         /* Start the tasks running. */
273         vTaskStartScheduler();
274
275         /* If all is well we will never reach here as the scheduler will now be
276         running.  If we do reach here then it is likely that there was insufficient
277         heap available for the idle task to be created. */
278         for( ;; );
279 }
280 /*-----------------------------------------------------------*/
281
282 static void prvCheckTimerCallback( TimerHandle_t xTimer )
283 {
284 static long lChangedTimerPeriodAlready = pdFALSE, lErrorStatus = pdPASS;
285 static volatile unsigned long ulLastRegTest1CycleCount = 0UL, ulLastRegTest2CycleCount = 0UL;
286
287         /* Check the standard demo tasks are running without error. */
288         if( xAreGenericQueueTasksStillRunning() != pdTRUE )
289         {
290                 lErrorStatus = pdFAIL;
291         }
292         else if( xAreQueuePeekTasksStillRunning() != pdTRUE )
293         {
294                 lErrorStatus = pdFAIL;
295         }
296         else if( xAreBlockingQueuesStillRunning() != pdTRUE )
297         {
298                 lErrorStatus = pdFAIL;
299         }
300         else if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )
301         {
302                 lErrorStatus = pdFAIL;
303         }
304         else if( xAreSemaphoreTasksStillRunning() != pdTRUE )
305         {
306                 lErrorStatus = pdFAIL;
307         }
308         else if( xArePollingQueuesStillRunning() != pdTRUE )
309         {
310                 lErrorStatus = pdFAIL;
311         }
312         else if( xIsCreateTaskStillRunning() != pdTRUE )
313         {
314                 lErrorStatus = pdFAIL;
315         }
316         else if( xAreIntegerMathsTaskStillRunning() != pdTRUE )
317         {
318                 lErrorStatus = pdFAIL;
319         }
320         else if( xAreRecursiveMutexTasksStillRunning() != pdTRUE )
321         {
322                 lErrorStatus = pdFAIL;
323         }
324         else if( xAreIntQueueTasksStillRunning() != pdPASS )
325         {
326                 lErrorStatus = pdFAIL;
327         }
328
329         /* Check the reg test tasks are still cycling.  They will stop incrementing
330         their loop counters if they encounter an error. */
331         if( ulRegTest1CycleCount == ulLastRegTest1CycleCount )
332         {
333                 lErrorStatus = pdFAIL;
334         }
335
336         if( ulRegTest2CycleCount == ulLastRegTest2CycleCount )
337         {
338                 lErrorStatus = pdFAIL;
339         }
340
341         ulLastRegTest1CycleCount = ulRegTest1CycleCount;
342         ulLastRegTest2CycleCount = ulRegTest2CycleCount;
343
344         /* Toggle the check LED to give an indication of the system status.  If
345         the LED toggles every 5 seconds then everything is ok.  A faster toggle
346         indicates an error. */
347         vParTestToggleLED( mainCHECK_LED );
348         
349         /* Was an error detected this time through the callback execution? */
350         if( lErrorStatus != pdPASS )
351         {
352                 if( lChangedTimerPeriodAlready == pdFALSE )
353                 {
354                         lChangedTimerPeriodAlready = pdTRUE;
355                         
356                         /* This call to xTimerChangePeriod() uses a zero block time.  
357                         Functions called from inside of a timer callback function must 
358                         *never* attempt to block. */
359                         xTimerChangePeriod( xCheckTimer, ( mainERROR_CHECK_TIMER_PERIOD_MS ), mainDONT_BLOCK );
360                 }
361         }
362 }
363 /*-----------------------------------------------------------*/
364
365 /* The RX port uses this callback function to configure its tick interrupt.
366 This allows the application to choose the tick interrupt source. */
367 void vApplicationSetupTimerInterrupt( void )
368 {
369         /* Enable compare match timer 0. */
370         MSTP( CMT0 ) = 0;
371
372         /* Interrupt on compare match. */
373         CMT0.CMCR.BIT.CMIE = 1;
374
375         /* Set the compare match value. */
376         CMT0.CMCOR = ( unsigned short ) ( ( ( configPERIPHERAL_CLOCK_HZ / configTICK_RATE_HZ ) -1 ) / 8 );
377
378         /* Divide the PCLK by 8. */
379         CMT0.CMCR.BIT.CKS = 0;
380
381         /* Enable the interrupt... */
382         _IEN( _CMT0_CMI0 ) = 1;
383
384         /* ...and set its priority to the application defined kernel priority. */
385         _IPR( _CMT0_CMI0 ) = configKERNEL_INTERRUPT_PRIORITY;
386
387         /* Start the timer. */
388         CMT.CMSTR0.BIT.STR0 = 1;
389 }
390 /*-----------------------------------------------------------*/
391
392 /* This function is explained by the comments above its prototype at the top
393 of this file. */
394 void vApplicationMallocFailedHook( void )
395 {
396         for( ;; );
397 }
398 /*-----------------------------------------------------------*/
399
400 /* This function is explained by the comments above its prototype at the top
401 of this file. */
402 void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName )
403 {
404         for( ;; );
405 }
406 /*-----------------------------------------------------------*/
407
408 /* This function is explained by the comments above its prototype at the top
409 of this file. */
410 void vApplicationIdleHook( void )
411 {
412         /* If this is being executed then the kernel has been started.  Start the high
413         frequency timer test as described at the top of this file.  This is only
414         included in the optimised build configuration - otherwise it takes up too much
415         CPU time and can disrupt other tests. */
416         #ifdef INCLUDE_HIGH_FREQUENCY_TIMER_TEST
417         static portBASE_TYPE xTimerTestStarted = pdFALSE;
418         extern void vSetupHighFrequencyTimer( void );
419                 if( xTimerTestStarted == pdFALSE )
420                 {
421                         vSetupHighFrequencyTimer();
422                         xTimerTestStarted = pdTRUE;
423                 }
424         #endif
425 }
426 /*-----------------------------------------------------------*/
427
428 /* This function is explained in the comments at the top of this file. */
429 static void prvRegTest1Task( void *pvParameters )
430 {
431         if( ( ( unsigned long ) pvParameters ) != mainREG_TEST_1_PARAMETER )
432         {
433                 /* The parameter did not contain the expected value. */
434                 for( ;; )
435                 {
436                         /* Stop the tick interrupt so its obvious something has gone wrong. */
437                         taskDISABLE_INTERRUPTS();
438                 }
439         }
440
441         /* This is an inline asm function that never returns. */
442         prvRegTest1Implementation();
443 }
444 /*-----------------------------------------------------------*/
445
446 /* This function is explained in the comments at the top of this file. */
447 static void prvRegTest2Task( void *pvParameters )
448 {
449         if( ( ( unsigned long ) pvParameters ) != mainREG_TEST_2_PARAMETER )
450         {
451                 /* The parameter did not contain the expected value. */
452                 for( ;; )
453                 {
454                         /* Stop the tick interrupt so its obvious something has gone wrong. */
455                         taskDISABLE_INTERRUPTS();
456                 }
457         }
458
459         /* This is an inline asm function that never returns. */
460         prvRegTest2Implementation();
461 }
462 /*-----------------------------------------------------------*/
463
464 /* This function is explained in the comments at the top of this file. */
465 #pragma inline_asm prvRegTest1Implementation
466 static void prvRegTest1Implementation( void )
467 {
468         ; Put a known value in each register.
469         MOV.L   #1, R1
470         MOV.L   #2, R2
471         MOV.L   #3, R3
472         MOV.L   #4, R4
473         MOV.L   #5, R5
474         MOV.L   #6, R6
475         MOV.L   #7, R7
476         MOV.L   #8, R8
477         MOV.L   #9, R9
478         MOV.L   #10, R10
479         MOV.L   #11, R11
480         MOV.L   #12, R12
481         MOV.L   #13, R13
482         MOV.L   #14, R14
483         MOV.L   #15, R15
484
485         ; Loop, checking each iteration that each register still contains the
486         ; expected value.
487 TestLoop1:
488
489         ; Push the registers that are going to get clobbered.
490         PUSHM   R14-R15
491
492         ; Increment the loop counter to show this task is still getting CPU time.
493         MOV.L   #_ulRegTest1CycleCount, R14
494         MOV.L   [ R14 ], R15
495         ADD             #1, R15
496         MOV.L   R15, [ R14 ]
497
498         ; Yield to extend the text coverage.  Set the bit in the ITU SWINTR register.
499         MOV.L   #1, R14
500         MOV.L   #0872E0H, R15
501         MOV.B   R14, [R15]
502         NOP
503         NOP
504
505         ; Restore the clobbered registers.
506         POPM    R14-R15
507
508         ; Now compare each register to ensure it still contains the value that was
509         ; set before this loop was entered.
510         CMP             #1, R1
511         BNE             RegTest1Error
512         CMP             #2, R2
513         BNE             RegTest1Error
514         CMP             #3, R3
515         BNE             RegTest1Error
516         CMP             #4, R4
517         BNE             RegTest1Error
518         CMP             #5, R5
519         BNE             RegTest1Error
520         CMP             #6, R6
521         BNE             RegTest1Error
522         CMP             #7, R7
523         BNE             RegTest1Error
524         CMP             #8, R8
525         BNE             RegTest1Error
526         CMP             #9, R9
527         BNE             RegTest1Error
528         CMP             #10, R10
529         BNE             RegTest1Error
530         CMP             #11, R11
531         BNE             RegTest1Error
532         CMP             #12, R12
533         BNE             RegTest1Error
534         CMP             #13, R13
535         BNE             RegTest1Error
536         CMP             #14, R14
537         BNE             RegTest1Error
538         CMP             #15, R15
539         BNE             RegTest1Error
540
541         ; All comparisons passed, start a new itteratio of this loop.
542         BRA             TestLoop1
543
544 RegTest1Error:
545         ; A compare failed, just loop here so the loop counter stops incrementing
546         ; causing the check timer to indicate the error.
547         BRA RegTest1Error
548 }
549 /*-----------------------------------------------------------*/
550
551 /* This function is explained in the comments at the top of this file. */
552 #pragma inline_asm prvRegTest2Implementation
553 static void prvRegTest2Implementation( void )
554 {
555         ; Put a known value in each register.
556         MOV.L   #10, R1
557         MOV.L   #20, R2
558         MOV.L   #30, R3
559         MOV.L   #40, R4
560         MOV.L   #50, R5
561         MOV.L   #60, R6
562         MOV.L   #70, R7
563         MOV.L   #80, R8
564         MOV.L   #90, R9
565         MOV.L   #100, R10
566         MOV.L   #110, R11
567         MOV.L   #120, R12
568         MOV.L   #130, R13
569         MOV.L   #140, R14
570         MOV.L   #150, R15
571
572         ; Loop, checking on each iteration that each register still contains the
573         ; expected value.
574 TestLoop2:
575
576         ; Push the registers that are going to get clobbered.
577         PUSHM   R14-R15
578
579         ; Increment the loop counter to show this task is still getting CPU time.
580         MOV.L   #_ulRegTest2CycleCount, R14
581         MOV.L   [ R14 ], R15
582         ADD             #1, R15
583         MOV.L   R15, [ R14 ]
584
585         ; Restore the clobbered registers.
586         POPM    R14-R15
587
588         CMP             #10, R1
589         BNE             RegTest2Error
590         CMP             #20, R2
591         BNE             RegTest2Error
592         CMP             #30, R3
593         BNE             RegTest2Error
594         CMP             #40, R4
595         BNE             RegTest2Error
596         CMP             #50, R5
597         BNE             RegTest2Error
598         CMP             #60, R6
599         BNE             RegTest2Error
600         CMP             #70, R7
601         BNE             RegTest2Error
602         CMP             #80, R8
603         BNE             RegTest2Error
604         CMP             #90, R9
605         BNE             RegTest2Error
606         CMP             #100, R10
607         BNE             RegTest2Error
608         CMP             #110, R11
609         BNE             RegTest2Error
610         CMP             #120, R12
611         BNE             RegTest2Error
612         CMP             #130, R13
613         BNE             RegTest2Error
614         CMP             #140, R14
615         BNE             RegTest2Error
616         CMP             #150, R15
617         BNE             RegTest2Error
618
619         ; All comparisons passed, start a new itteratio of this loop.
620         BRA             TestLoop2
621
622 RegTest2Error:
623         ; A compare failed, just loop here so the loop counter stops incrementing
624         ; - causing the check timer to indicate the error.
625         BRA RegTest2Error
626 }
627 /*-----------------------------------------------------------*/
628