]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/Cygnal/main.c
***IMMINENT RELEASE NOTICE***
[freertos] / FreeRTOS / Demo / Cygnal / main.c
1 /*\r
2     FreeRTOS V8.1.0 - Copyright (C) 2014 Real Time Engineers Ltd. \r
3     All rights reserved\r
4 \r
5     VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
6 \r
7     ***************************************************************************\r
8      *                                                                       *\r
9      *    FreeRTOS provides completely free yet professionally developed,    *\r
10      *    robust, strictly quality controlled, supported, and cross          *\r
11      *    platform software that has become a de facto standard.             *\r
12      *                                                                       *\r
13      *    Help yourself get started quickly and support the FreeRTOS         *\r
14      *    project by purchasing a FreeRTOS tutorial book, reference          *\r
15      *    manual, or both from: http://www.FreeRTOS.org/Documentation        *\r
16      *                                                                       *\r
17      *    Thank you!                                                         *\r
18      *                                                                       *\r
19     ***************************************************************************\r
20 \r
21     This file is part of the FreeRTOS distribution.\r
22 \r
23     FreeRTOS is free software; you can redistribute it and/or modify it under\r
24     the terms of the GNU General Public License (version 2) as published by the\r
25     Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
26 \r
27     >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
28     >>!   distribute a combined work that includes FreeRTOS without being   !<<\r
29     >>!   obliged to provide the source code for proprietary components     !<<\r
30     >>!   outside of the FreeRTOS kernel.                                   !<<\r
31 \r
32     FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
33     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
34     FOR A PARTICULAR PURPOSE.  Full license text is available from the following\r
35     link: http://www.freertos.org/a00114.html\r
36 \r
37     1 tab == 4 spaces!\r
38 \r
39     ***************************************************************************\r
40      *                                                                       *\r
41      *    Having a problem?  Start by reading the FAQ "My application does   *\r
42      *    not run, what could be wrong?"                                     *\r
43      *                                                                       *\r
44      *    http://www.FreeRTOS.org/FAQHelp.html                               *\r
45      *                                                                       *\r
46     ***************************************************************************\r
47 \r
48     http://www.FreeRTOS.org - Documentation, books, training, latest versions,\r
49     license and Real Time Engineers Ltd. contact details.\r
50 \r
51     http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
52     including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
53     compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
54 \r
55     http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High\r
56     Integrity Systems to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
57     licenses offer ticketed support, indemnification and middleware.\r
58 \r
59     http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
60     engineered and independently SIL3 certified version for use in safety and\r
61     mission critical applications that require provable dependability.\r
62 \r
63     1 tab == 4 spaces!\r
64 */\r
65 \r
66 /*\r
67  * Creates the demo application tasks, then starts the scheduler.  The WEB\r
68  * documentation provides more details of the demo application tasks.\r
69  * \r
70  * Main. c also creates four other tasks:\r
71  * \r
72  * 1) vErrorChecks()\r
73  * This only executes every few seconds but has the highest priority so is \r
74  * guaranteed to get processor time.  Its main function is to check that all \r
75  * the standard demo application tasks are still operational and have not\r
76  * experienced any errors.  vErrorChecks() will toggle the on board LED\r
77  * every mainNO_ERROR_FLASH_PERIOD milliseconds if none of the demo application\r
78  * tasks have reported an error.  Should any task report an error at any time\r
79  * the rate at which the on board LED is toggled is increased to \r
80  * mainERROR_FLASH_PERIOD - providing visual feedback that something has gone\r
81  * wrong.\r
82  *\r
83  * 2) vRegisterCheck()\r
84  * This is a very simple task that checks that all the registers are always\r
85  * in their expected state.  The task only makes use of the A register, so\r
86  * all the other registers should always contain their initial values.\r
87  * An incorrect value indicates an error in the context switch mechanism.\r
88  * The task operates at the idle priority so will be preempted regularly.\r
89  * Any error will cause the toggle rate of the on board LED to increase to\r
90  * mainERROR_FLASH_PERIOD milliseconds.\r
91  *\r
92  * 3 and 4) vFLOPCheck1() and vFLOPCheck2()\r
93  * These are very basic versions of the standard FLOP tasks.  They are good\r
94  * at detecting errors in the context switch mechanism, and also check that\r
95  * the floating point libraries are correctly built to be re-enterant.  The\r
96  * stack restrictions of the 8051 prevent the use of the standard FLOP demo\r
97  * tasks.\r
98  */\r
99 \r
100 /* Standard includes. */\r
101 #include <stdlib.h>\r
102 \r
103 /* Scheduler includes. */\r
104 #include "FreeRTOS.h"\r
105 #include "task.h"\r
106 \r
107 /* Demo application includes. */\r
108 #include "partest.h"\r
109 #include "flash.h"\r
110 #include "integer.h"\r
111 #include "PollQ.h"\r
112 #include "comtest2.h"\r
113 #include "semtest.h"\r
114 \r
115 /* Demo task priorities. */\r
116 #define mainLED_TASK_PRIORITY           ( tskIDLE_PRIORITY + 1 )\r
117 #define mainQUEUE_POLL_PRIORITY         ( tskIDLE_PRIORITY + 2 )\r
118 #define mainCOM_TEST_PRIORITY           ( tskIDLE_PRIORITY + 2 )\r
119 #define mainCHECK_TASK_PRIORITY         ( tskIDLE_PRIORITY + 3 )\r
120 #define mainSEM_TEST_PRIORITY           ( tskIDLE_PRIORITY + 2 )\r
121 #define mainINTEGER_PRIORITY            tskIDLE_PRIORITY\r
122 \r
123 /* Constants required to disable the watchdog. */\r
124 #define mainDISABLE_BYTE_1                      ( ( unsigned char ) 0xde )\r
125 #define mainDISABLE_BYTE_2                      ( ( unsigned char ) 0xad )\r
126 \r
127 /* Constants to setup and use the on board LED. */\r
128 #define ucLED_BIT                                       ( ( unsigned char ) 0x40 )\r
129 #define mainPORT_1_BIT_6                        ( ( unsigned char ) 0x40 )\r
130 #define mainENABLE_CROSS_BAR            ( ( unsigned char ) 0x40 )\r
131 \r
132 /* Constants to set the clock frequency. */\r
133 #define mainSELECT_INTERNAL_OSC         ( ( unsigned char ) 0x80 )\r
134 #define mainDIVIDE_CLOCK_BY_1           ( ( unsigned char ) 0x03 )\r
135 #define mainPLL_USES_INTERNAL_OSC       ( ( unsigned char ) 0x04 )\r
136 #define mainFLASH_READ_TIMING           ( ( unsigned char ) 0x30 )\r
137 #define mainPLL_POWER_ON                        ( ( unsigned char ) 0x01 )\r
138 #define mainPLL_NO_PREDIVIDE            ( ( unsigned char ) 0x01 )\r
139 #define mainPLL_FILTER                          ( ( unsigned char ) 0x01 )\r
140 #define mainPLL_MULTIPLICATION          ( ( unsigned char ) 0x04 )\r
141 #define mainENABLE_PLL                          ( ( unsigned char ) 0x02 )\r
142 #define mainPLL_LOCKED                          ( ( unsigned char ) 0x10 )\r
143 #define mainSELECT_PLL_AS_SOURCE        ( ( unsigned char ) 0x02 )\r
144 \r
145 /* Toggle rate for the on board LED - which is dependent on whether or not\r
146 an error has been detected. */\r
147 #define mainNO_ERROR_FLASH_PERIOD       ( ( TickType_t ) 5000 )\r
148 #define mainERROR_FLASH_PERIOD          ( ( TickType_t ) 250 )\r
149 \r
150 /* Baud rate used by the serial port tasks. */\r
151 #define mainCOM_TEST_BAUD_RATE          ( ( unsigned long ) 115200 )\r
152 \r
153 /* Pass an invalid LED number to the COM test task as we don't want it to flash\r
154 an LED.  There are only 8 LEDs (excluding the on board LED) wired in and these\r
155 are all used by the flash tasks. */\r
156 #define mainCOM_TEST_LED                        ( 200 )\r
157 \r
158 /* We want the Cygnal to act as much as possible as a standard 8052. */\r
159 #define mainAUTO_SFR_OFF                        ( ( unsigned char ) 0 )\r
160 \r
161 /* Constants required to setup the IO pins for serial comms. */\r
162 #define mainENABLE_COMS                         ( ( unsigned char ) 0x04 )\r
163 #define mainCOMS_LINES_TO_PUSH_PULL ( ( unsigned char ) 0x03 )\r
164 \r
165 /* Pointer passed as a parameter to vRegisterCheck() just so it has some know\r
166 values to check for in the DPH, DPL and B registers. */\r
167 #define mainDUMMY_POINTER               ( ( xdata void * ) 0xabcd )\r
168 \r
169 /* Macro that lets vErrorChecks() know that one of the tasks defined in\r
170 main. c has detected an error.  A critical region is used around xLatchError\r
171 as it is accessed from vErrorChecks(), which has a higher priority. */ \r
172 #define mainLATCH_ERROR()                       \\r
173 {                                                                       \\r
174         portENTER_CRITICAL();                   \\r
175                 xLatchedError = pdTRUE;         \\r
176         portEXIT_CRITICAL();                    \\r
177 }\r
178 \r
179 /*\r
180  * Setup the Cygnal microcontroller for its fastest operation. \r
181  */\r
182 static void prvSetupSystemClock( void );\r
183 \r
184 /*\r
185  * Setup the peripherals, including the on board LED. \r
186  */\r
187 static void prvSetupHardware( void );\r
188 \r
189 /*\r
190  * Toggle the state of the on board LED. \r
191  */\r
192 static void prvToggleOnBoardLED( void );\r
193 \r
194 /*\r
195  * See comments at the top of the file for details. \r
196  */\r
197 static void vErrorChecks( void *pvParameters );\r
198 \r
199 /*\r
200  * See comments at the top of the file for details. \r
201  */\r
202 static void vRegisterCheck( void *pvParameters );\r
203 \r
204 /*\r
205  * See comments at the top of the file for details. \r
206  */\r
207 static void vFLOPCheck1( void *pvParameters );\r
208 \r
209 /*\r
210  * See comments at the top of the file for details. \r
211  */\r
212 static void vFLOPCheck2( void *pvParameters );\r
213 \r
214 /* File scope variable used to communicate the occurrence of an error between\r
215 tasks. */\r
216 static portBASE_TYPE xLatchedError = pdFALSE;\r
217 \r
218 /*-----------------------------------------------------------*/\r
219 \r
220 /*\r
221  * Starts all the other tasks, then starts the scheduler. \r
222  */\r
223 void main( void )\r
224 {\r
225         /* Initialise the hardware including the system clock and on board\r
226         LED. */\r
227         prvSetupHardware();\r
228 \r
229         /* Initialise the port that controls the external LED's utilized by the\r
230         flash tasks. */\r
231         vParTestInitialise();\r
232 \r
233         /* Start the used standard demo tasks. */\r
234         vStartLEDFlashTasks( mainLED_TASK_PRIORITY );\r
235         vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );\r
236         vStartIntegerMathTasks( mainINTEGER_PRIORITY );\r
237         vAltStartComTestTasks( mainCOM_TEST_PRIORITY, mainCOM_TEST_BAUD_RATE, mainCOM_TEST_LED );\r
238         vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );\r
239 \r
240         /* Start the tasks defined in this file.  The first three never block so\r
241         must not be used with the co-operative scheduler. */\r
242         #if configUSE_PREEMPTION == 1\r
243         {\r
244                 xTaskCreate( vRegisterCheck, "RegChck", configMINIMAL_STACK_SIZE, mainDUMMY_POINTER, tskIDLE_PRIORITY, ( TaskHandle_t * ) NULL );\r
245                 xTaskCreate( vFLOPCheck1, "FLOP", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, ( TaskHandle_t * ) NULL );\r
246                 xTaskCreate( vFLOPCheck2, "FLOP", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, ( TaskHandle_t * ) NULL );\r
247         }\r
248         #endif \r
249 \r
250         xTaskCreate( vErrorChecks, "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, ( TaskHandle_t * ) NULL );\r
251 \r
252         /* Finally kick off the scheduler.  This function should never return. */\r
253         vTaskStartScheduler();\r
254 \r
255         /* Should never reach here as the tasks will now be executing under control\r
256         of the scheduler. */\r
257 }\r
258 /*-----------------------------------------------------------*/\r
259 \r
260 /*\r
261  * Setup the hardware prior to using the scheduler.  Most of the Cygnal\r
262  * specific initialisation is performed here leaving standard 8052 setup\r
263  * only in the driver code.\r
264  */\r
265 static void prvSetupHardware( void )\r
266 {\r
267 unsigned char ucOriginalSFRPage;\r
268 \r
269         /* Remember the SFR page before it is changed so it can get set back\r
270         before the function exits. */\r
271         ucOriginalSFRPage = SFRPAGE;\r
272 \r
273         /* Setup the SFR page to access the config SFR's. */\r
274         SFRPAGE = CONFIG_PAGE;\r
275 \r
276         /* Don't allow the microcontroller to automatically switch SFR page, as the\r
277         SFR page is not stored as part of the task context. */\r
278         SFRPGCN = mainAUTO_SFR_OFF;\r
279 \r
280         /* Disable the watchdog. */\r
281         WDTCN = mainDISABLE_BYTE_1;\r
282         WDTCN = mainDISABLE_BYTE_2;\r
283 \r
284         /* Set the on board LED to push pull. */\r
285         P1MDOUT |= mainPORT_1_BIT_6;\r
286 \r
287         /* Setup the cross bar to enable serial comms here as it is not part of the \r
288         standard 8051 setup and therefore is not in the driver code. */\r
289         XBR0 |= mainENABLE_COMS;\r
290         P0MDOUT |= mainCOMS_LINES_TO_PUSH_PULL;\r
291 \r
292         /* Enable the cross bar so our hardware setup takes effect. */\r
293         XBR2 = mainENABLE_CROSS_BAR;\r
294 \r
295         /* Setup a fast system clock. */\r
296         prvSetupSystemClock();\r
297 \r
298         /* Return the SFR page. */\r
299         SFRPAGE = ucOriginalSFRPage;\r
300 }\r
301 /*-----------------------------------------------------------*/\r
302 \r
303 static void prvSetupSystemClock( void )\r
304 {\r
305 volatile unsigned short usWait;\r
306 const unsigned short usWaitTime = ( unsigned short ) 0x2ff;\r
307 unsigned char ucOriginalSFRPage;\r
308 \r
309         /* Remember the SFR page so we can set it back at the end. */\r
310         ucOriginalSFRPage = SFRPAGE;\r
311         SFRPAGE = CONFIG_PAGE;\r
312 \r
313         /* Use the internal oscillator set to its fasted frequency. */\r
314         OSCICN = mainSELECT_INTERNAL_OSC | mainDIVIDE_CLOCK_BY_1;\r
315 \r
316         /* Ensure the clock is stable. */\r
317         for( usWait = 0; usWait < usWaitTime; usWait++ );\r
318 \r
319         /* Setup the clock source for the PLL. */\r
320         PLL0CN &= ~mainPLL_USES_INTERNAL_OSC;\r
321 \r
322         /* Change the read timing for the flash ready for the fast clock. */\r
323         SFRPAGE = LEGACY_PAGE;\r
324         FLSCL |= mainFLASH_READ_TIMING;\r
325 \r
326         /* Turn on the PLL power. */\r
327         SFRPAGE = CONFIG_PAGE;\r
328         PLL0CN |= mainPLL_POWER_ON;\r
329 \r
330         /* Don't predivide the clock. */\r
331         PLL0DIV = mainPLL_NO_PREDIVIDE;\r
332 \r
333         /* Set filter for fastest clock. */\r
334         PLL0FLT = mainPLL_FILTER;\r
335         PLL0MUL = mainPLL_MULTIPLICATION;\r
336 \r
337         /* Ensure the clock is stable. */\r
338         for( usWait = 0; usWait < usWaitTime; usWait++ );\r
339 \r
340         /* Enable the PLL and wait for it to lock. */\r
341         PLL0CN |= mainENABLE_PLL;\r
342         for( usWait = 0; usWait < usWaitTime; usWait++ )\r
343         {\r
344                 if( PLL0CN & mainPLL_LOCKED )\r
345                 {\r
346                         break;\r
347                 }\r
348         }\r
349 \r
350         /* Select the PLL as the clock source. */\r
351         CLKSEL |= mainSELECT_PLL_AS_SOURCE;\r
352 \r
353         /* Return the SFR back to its original value. */\r
354         SFRPAGE = ucOriginalSFRPage;\r
355 }\r
356 /*-----------------------------------------------------------*/\r
357 \r
358 static void prvToggleOnBoardLED( void )\r
359 {\r
360         /* If the on board LED is on, turn it off and vice versa. */\r
361         if( P1 & ucLED_BIT )\r
362         {\r
363                 P1 &= ~ucLED_BIT;\r
364         }\r
365         else\r
366         {\r
367                 P1 |= ucLED_BIT;\r
368         }\r
369 }\r
370 /*-----------------------------------------------------------*/\r
371 \r
372 /*\r
373  * See the documentation at the top of this file. \r
374  */\r
375 static void vErrorChecks( void *pvParameters )\r
376 {\r
377 portBASE_TYPE xErrorHasOccurred = pdFALSE;\r
378         \r
379         /* Just to prevent compiler warnings. */\r
380         ( void ) pvParameters;\r
381         \r
382         /* Cycle for ever, delaying then checking all the other tasks are still\r
383         operating without error.   The delay period depends on whether an error\r
384         has ever been detected. */\r
385         for( ;; )\r
386         {\r
387                 if( xLatchedError == pdFALSE )\r
388                 {               \r
389                         /* No errors have been detected so delay for a longer period.  The\r
390                         on board LED will get toggled every mainNO_ERROR_FLASH_PERIOD ms. */\r
391                         vTaskDelay( mainNO_ERROR_FLASH_PERIOD );\r
392                 }\r
393                 else\r
394                 {\r
395                         /* We have at some time recognised an error in one of the demo\r
396                         application tasks, delay for a shorter period.  The on board LED\r
397                         will get toggled every mainERROR_FLASH_PERIOD ms. */\r
398                         vTaskDelay( mainERROR_FLASH_PERIOD );\r
399                 }\r
400 \r
401                 \r
402                 \r
403                 /* Check the demo application tasks for errors. */\r
404 \r
405                 if( xAreIntegerMathsTaskStillRunning() != pdTRUE )\r
406                 {\r
407                         xErrorHasOccurred = pdTRUE;\r
408                 }\r
409 \r
410                 if( xArePollingQueuesStillRunning() != pdTRUE )\r
411                 {\r
412                         xErrorHasOccurred = pdTRUE;\r
413                 }\r
414 \r
415                 if( xAreComTestTasksStillRunning() != pdTRUE )\r
416                 {\r
417                         xErrorHasOccurred = pdTRUE;\r
418                 }\r
419 \r
420                 if( xAreSemaphoreTasksStillRunning() != pdTRUE )\r
421                 {\r
422                         xErrorHasOccurred = pdTRUE;\r
423                 }\r
424 \r
425                 /* If an error has occurred, latch it to cause the LED flash rate to \r
426                 increase. */\r
427                 if( xErrorHasOccurred == pdTRUE )\r
428                 {\r
429                         xLatchedError = pdTRUE;\r
430                 }\r
431 \r
432                 /* Toggle the LED to indicate the completion of a check cycle.  The\r
433                 frequency of check cycles is dependent on whether or not we have \r
434                 latched an error. */\r
435                 prvToggleOnBoardLED();\r
436         }\r
437 }\r
438 /*-----------------------------------------------------------*/\r
439 \r
440 /*\r
441  * See the documentation at the top of this file.  Also see the standard FLOP\r
442  * demo task documentation for the rationale of these tasks.\r
443  */\r
444 static void vFLOPCheck1( void *pvParameters )\r
445 {\r
446 volatile portFLOAT fVal1, fVal2, fResult;\r
447 \r
448         ( void ) pvParameters;\r
449 \r
450         for( ;; )\r
451         {\r
452                 fVal1 = ( portFLOAT ) -1234.5678;\r
453                 fVal2 = ( portFLOAT ) 2345.6789;\r
454 \r
455                 fResult = fVal1 + fVal2;\r
456                 if( ( fResult > ( portFLOAT )  1111.15 ) || ( fResult < ( portFLOAT ) 1111.05 ) )\r
457                 {\r
458                         mainLATCH_ERROR();\r
459                 }\r
460 \r
461                 fResult = fVal1 / fVal2;\r
462                 if( ( fResult > ( portFLOAT ) -0.51 ) || ( fResult < ( portFLOAT ) -0.53 ) )\r
463                 {\r
464                         mainLATCH_ERROR();\r
465                 }\r
466         }\r
467 }\r
468 /*-----------------------------------------------------------*/\r
469 \r
470 /*\r
471  * See the documentation at the top of this file.\r
472  */\r
473 static void vFLOPCheck2( void *pvParameters )\r
474 {\r
475 volatile portFLOAT fVal1, fVal2, fResult;\r
476 \r
477         ( void ) pvParameters;\r
478 \r
479         for( ;; )\r
480         {\r
481                 fVal1 = ( portFLOAT ) -12340.5678;\r
482                 fVal2 = ( portFLOAT ) 23450.6789;\r
483 \r
484                 fResult = fVal1 + fVal2;\r
485                 if( ( fResult > ( portFLOAT ) 11110.15 ) || ( fResult < ( portFLOAT ) 11110.05 ) )\r
486                 {\r
487                         mainLATCH_ERROR();\r
488                 }\r
489 \r
490                 fResult = fVal1 / -fVal2;\r
491                 if( ( fResult > ( portFLOAT ) 0.53 ) || ( fResult < ( portFLOAT ) 0.51 ) )\r
492                 {\r
493                         mainLATCH_ERROR();\r
494                 }\r
495         }\r
496 }\r
497 /*-----------------------------------------------------------*/\r
498 \r
499 /*\r
500  * See the documentation at the top of this file. \r
501  */\r
502 static void vRegisterCheck( void *pvParameters )\r
503 {\r
504         ( void ) pvParameters;\r
505 \r
506         for( ;; )\r
507         {\r
508                 if( SP != configSTACK_START )\r
509                 {\r
510                         mainLATCH_ERROR();\r
511                 }\r
512 \r
513                 _asm\r
514                         MOV ACC, ar0\r
515                 _endasm;\r
516 \r
517                 if( ACC != 0 )\r
518                 {\r
519                         mainLATCH_ERROR();\r
520                 }\r
521 \r
522                 _asm\r
523                         MOV ACC, ar1\r
524                 _endasm;\r
525 \r
526                 if( ACC != 1 )\r
527                 {\r
528                         mainLATCH_ERROR();\r
529                 }\r
530                 _asm\r
531                         MOV ACC, ar2\r
532                 _endasm;\r
533 \r
534                 if( ACC != 2 )\r
535                 {\r
536                         mainLATCH_ERROR();\r
537                 }\r
538                 _asm\r
539                         MOV ACC, ar3\r
540                 _endasm;\r
541 \r
542                 if( ACC != 3 )\r
543                 {\r
544                         mainLATCH_ERROR();\r
545                 }\r
546                 _asm\r
547                         MOV ACC, ar4\r
548                 _endasm;\r
549 \r
550                 if( ACC != 4 )\r
551                 {\r
552                         mainLATCH_ERROR();\r
553                 }\r
554                 _asm\r
555                         MOV ACC, ar5\r
556                 _endasm;\r
557 \r
558                 if( ACC != 5 )\r
559                 {\r
560                         mainLATCH_ERROR();\r
561                 }\r
562                 _asm\r
563                         MOV ACC, ar6\r
564                 _endasm;\r
565 \r
566                 if( ACC != 6 )\r
567                 {\r
568                         mainLATCH_ERROR();\r
569                 }\r
570                 _asm\r
571                         MOV ACC, ar7\r
572                 _endasm;\r
573 \r
574                 if( ACC != 7 )\r
575                 {\r
576                         mainLATCH_ERROR();\r
577                 }\r
578 \r
579                 if( DPL != 0xcd )\r
580                 {\r
581                         mainLATCH_ERROR();\r
582                 }\r
583 \r
584                 if( DPH != 0xab )\r
585                 {\r
586                         mainLATCH_ERROR();\r
587                 }\r
588 \r
589                 if( B != 0x01 )\r
590                 {\r
591                         mainLATCH_ERROR();\r
592                 }                       \r
593         }\r
594 }\r
595 \r
596 \r