-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathEpoch.lst
1415 lines (1410 loc) · 35.6 KB
/
Epoch.lst
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
CCS PCM C Compiler, Version 4.121, 59578 05-jun-11 19:55
Filename: C:\Users\Daniel\PIC\Epoch\Epoch.lst
ROM used: 1179 words (58%)
Largest free fragment is 869
RAM used: 53 (40%) at main() level
85 (63%) worst case
Stack: 4 worst case (3 in main + 1 for interrupts)
*
0000: NOP
0001: MOVLW 04
0002: MOVWF 0A
0003: GOTO 46E
0004: MOVWF 7F
0005: SWAPF 03,W
0006: CLRF 03
0007: MOVWF 21
0008: MOVF 7F,W
0009: MOVWF 20
000A: MOVF 0A,W
000B: MOVWF 27
000C: CLRF 0A
000D: SWAPF 20,F
000E: MOVF 04,W
000F: MOVWF 22
0010: MOVF 77,W
0011: MOVWF 23
0012: MOVF 78,W
0013: MOVWF 24
0014: MOVF 79,W
0015: MOVWF 25
0016: MOVF 7A,W
0017: MOVWF 26
0018: BCF 03.7
0019: BCF 03.5
001A: BTFSS 0B.5
001B: GOTO 01E
001C: BTFSC 0B.2
001D: GOTO 054
001E: MOVF 22,W
001F: MOVWF 04
0020: MOVF 23,W
0021: MOVWF 77
0022: MOVF 24,W
0023: MOVWF 78
0024: MOVF 25,W
0025: MOVWF 79
0026: MOVF 26,W
0027: MOVWF 7A
0028: MOVF 27,W
0029: MOVWF 0A
002A: SWAPF 21,W
002B: MOVWF 03
002C: SWAPF 7F,F
002D: SWAPF 7F,W
002E: RETFIE
.................... //
.................... // Epoch - contador de segundos a partir da fundação do GHC
.................... //
....................
.................... #include <16f882.h>
.................... //////// Standard Header file for the PIC16F882 device ////////////////
.................... #device PIC16F882
.................... #list
....................
....................
.................... #device adc=8
.................... #use delay(clock=8000000)
.................... #fuses NOWDT, NOCPD, NOPROTECT
.................... #fuses MCLR, INTRC_IO
....................
.................... #use fast_io(A)
.................... #use fast_io(B)
.................... #use fast_io(C)
....................
.................... // Pinos utilizados
.................... #use rs232 (baud=9600, UART1)
....................
.................... #define DS1302_CE PIN_B0
.................... #define DS1302_IO PIN_B1
.................... #define DS1302_SCLK PIN_B2
....................
.................... #define DISP_S0 PIN_C0
.................... #define DISP_S1 PIN_C1
.................... #define DISP_S2 PIN_C2
....................
.................... #define LED PIN_C3
....................
.................... #define TAXA_DISP 3 // taxa de varredura do display
.................... #define INTS_SEG 3906 // taxa de varredura do display
....................
.................... // Alguns registradores do DS1302
.................... #define DS1302_WP 0x0E
.................... #define DS1302_TC 0x10
.................... #define DS1302_CBURST 0x3E
....................
.................... // Dias por mês 31 28 31 30 31 30 31 31 30 31 30
.................... const int dias[] = { 0,31,59,90,120,151,181,212,243,273,304,334 };
....................
.................... // Caracteres ASCII
.................... #define BS 8
.................... #define LF 10
.................... #define CR 13
.................... #define ESC 27
....................
.................... const char hexa[] = "0123456789ABCDEF";
....................
.................... // EPOCH0 - fundação do GHC em segundos após 1/1/2000 00:00:00
.................... #define EPOCH0 351549263L
....................
.................... // valor a apresentar no display
.................... int8 valor[16];
....................
.................... // valor a programar no relogio (ddmmaahhmmss)
.................... int8 horario[12];
....................
.................... // data/hora para o relogio
.................... byte relogio[8];
....................
.................... // Rotinas locais
.................... void InitHw (void);
.................... void LoadClk (void);
.................... void TrataUart (void);
....................
.................... void DS1302_ReadClock (byte *regs);
.................... void DS1302_WriteClock (byte *regs);
.................... byte DS1302_Read (byte ender);
.................... void DS1302_Write (byte ender, byte dado);
.................... void DS1302_TxByte (byte b);
.................... byte DS1302_RxByte ();
....................
.................... // Ponto de entrada e loop principal
.................... void main (void)
.................... {
*
046E: CLRF 04
046F: BCF 03.7
0470: MOVLW 1F
0471: ANDWF 03,F
0472: BSF 03.5
0473: BSF 03.6
0474: BCF 07.3
0475: MOVLW 0C
0476: BCF 03.6
0477: MOVWF 19
0478: MOVLW A2
0479: MOVWF 18
047A: MOVLW 90
047B: BCF 03.5
047C: MOVWF 18
047D: MOVLW 0F
047E: MOVWF 4D
047F: MOVLW 42
0480: MOVWF 4C
0481: MOVLW 03
0482: MOVWF 4E
0483: CLRF 4F
0484: BSF 03.5
0485: BSF 03.6
0486: MOVF 09,W
0487: ANDLW C0
0488: MOVWF 09
0489: BCF 03.6
048A: BCF 1F.4
048B: BCF 1F.5
048C: MOVLW 00
048D: BSF 03.6
048E: MOVWF 08
048F: BCF 03.5
0490: CLRF 07
0491: CLRF 08
0492: CLRF 09
.................... InitHw ();
0493: BCF 03.6
0494: GOTO 0A0
.................... LoadClk ();
0495: CALL 159
.................... enable_interrupts(GLOBAL);
0496: MOVLW C0
0497: IORWF 0B,F
.................... for (;;)
.................... {
.................... TrataUart();
0498: GOTO 37C
.................... }
0499: GOTO 498
.................... }
....................
.................... // Iniciação do hardware
.................... void InitHw (void)
.................... {
049A: GOTO 49A
.................... // Bota para correr
.................... setup_oscillator (OSC_8MHZ);
*
00A0: MOVLW 71
00A1: BSF 03.5
00A2: MOVWF 0F
00A3: MOVF 0F,W
....................
.................... // Dispositivos não usados
.................... setup_comparator(NC_NC);
00A4: BCF 03.5
00A5: BSF 03.6
00A6: CLRF 07
00A7: CLRF 08
00A8: CLRF 09
.................... setup_vref(FALSE);
00A9: BSF 03.5
00AA: BCF 03.6
00AB: CLRF 17
.................... setup_adc(ADC_OFF);
00AC: BCF 03.5
00AD: BCF 1F.0
....................
.................... // E/S
.................... set_tris_a (0x00); // RA0-RA7 output
00AE: MOVLW 00
00AF: BSF 03.5
00B0: MOVWF 05
.................... set_tris_b (0xFA); // RB0 e RB2 output
00B1: MOVLW FA
00B2: MOVWF 06
.................... set_tris_c (0xF0); // RC0-RC3 output
00B3: MOVLW F0
00B4: MOVWF 07
.................... output_low (LED);
00B5: BCF 03.5
00B6: BCF 07.3
....................
.................... // Timer
.................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_2);
00B7: BSF 03.5
00B8: MOVF 01,W
00B9: ANDLW C0
00BA: MOVWF 01
.................... setup_timer_1(T1_DISABLED);
00BB: BCF 03.5
00BC: CLRF 10
.................... enable_interrupts (INT_RTCC);
00BD: BSF 0B.5
....................
.................... // Uart
.................... while (kbhit())
.................... getc();
00BE: BTFSS 0C.5
00BF: GOTO 0C4
00C0: BTFSS 0C.5
00C1: GOTO 0C0
00C2: MOVF 1A,W
00C3: GOTO 0BE
.................... }
00C4: GOTO 495 (RETURN)
....................
.................... // Coloca no display o valor do relógio não volátil
.................... void LoadClk (void)
.................... {
.................... byte i, aux;
.................... unsigned int32 time;
....................
.................... DS1302_ReadClock (relogio);
*
0159: CLRF 59
015A: MOVLW 44
015B: MOVWF 58
.................... if ((relogio[3] & 0x3F) == 0)
*
0193: MOVF 47,W
0194: ANDLW 3F
0195: BTFSS 03.2
0196: GOTO 1A4
.................... {
.................... // não programado
.................... for (i = 0; i < 16; i++)
0197: CLRF 52
0198: MOVF 52,W
0199: SUBLW 0F
019A: BTFSS 03.0
019B: GOTO 1A3
.................... {
.................... valor[i] = 0;
019C: MOVLW 28
019D: ADDWF 52,W
019E: MOVWF 04
019F: BCF 03.7
01A0: CLRF 00
.................... }
01A1: INCF 52,F
01A2: GOTO 198
.................... return;
01A3: GOTO 36C
.................... }
....................
.................... // Zera os bits não implementados no timer
.................... relogio[0] &= 0x7F;
01A4: BCF 44.7
.................... relogio[1] &= 0x7F;
01A5: BCF 45.7
.................... relogio[2] &= 0x3F;
01A6: MOVLW 3F
01A7: ANDWF 46,F
.................... relogio[3] &= 0x3F;
01A8: ANDWF 47,F
.................... relogio[4] &= 0x1F;
01A9: MOVLW 1F
01AA: ANDWF 48,F
....................
.................... // Converte valores BCD para binário
.................... for (i = 0; i < 7; i++)
01AB: CLRF 52
01AC: MOVF 52,W
01AD: SUBLW 06
01AE: BTFSS 03.0
01AF: GOTO 1FD
.................... {
.................... relogio[i] = (relogio[i] >> 4) * 10 + (relogio[i] & 0x0F);
01B0: MOVLW 44
01B1: ADDWF 52,W
01B2: MOVWF 78
01B3: CLRF 7A
01B4: BTFSC 03.0
01B5: INCF 7A,F
01B6: MOVF 78,W
01B7: MOVWF 58
01B8: MOVF 7A,W
01B9: MOVWF 59
01BA: MOVLW 44
01BB: ADDWF 52,W
01BC: MOVWF 04
01BD: BCF 03.7
01BE: SWAPF 00,W
01BF: MOVWF 77
01C0: MOVLW 0F
01C1: ANDWF 77,F
01C2: MOVF 77,W
01C3: MOVWF 5B
01C4: MOVF 5B,W
01C5: MOVWF 5C
01C6: MOVLW 0A
01C7: MOVWF 5D
*
01EC: MOVLW 44
01ED: ADDWF 52,W
01EE: MOVWF 04
01EF: BCF 03.7
01F0: MOVF 00,W
01F1: ANDLW 0F
01F2: ADDWF 78,W
01F3: MOVWF 5A
01F4: MOVF 58,W
01F5: MOVWF 04
01F6: BCF 03.7
01F7: BTFSC 59.0
01F8: BSF 03.7
01F9: MOVF 5A,W
01FA: MOVWF 00
.................... }
01FB: INCF 52,F
01FC: GOTO 1AC
....................
.................... // Determina o número de dias nos anos inteiros
.................... // Na faixa 2000 a 2099 os anos divisíveis por 4 são bissextos
.................... // Cada grupo de 4 anos tem 3*365+366 dias
.................... time = ((unsigned int32) (relogio[6] >> 2)) * (3L*365L+366L);
01FD: RRF 4A,W
01FE: MOVWF 77
01FF: RRF 77,F
0200: MOVLW 3F
0201: ANDWF 77,F
0202: MOVF 77,W
0203: CLRF 5C
0204: CLRF 5B
0205: CLRF 5A
0206: MOVWF 59
0207: MOVF 5C,W
0208: MOVWF 60
0209: MOVF 5B,W
020A: MOVWF 5F
020B: MOVF 5A,W
020C: MOVWF 5E
020D: MOVF 59,W
020E: MOVWF 5D
020F: CLRF 64
0210: CLRF 63
0211: MOVLW 05
0212: MOVWF 62
0213: MOVLW B5
0214: MOVWF 61
0215: CALL 0E0
0216: MOVF 7A,W
0217: MOVWF 57
0218: MOVF 79,W
0219: MOVWF 56
021A: MOVF 78,W
021B: MOVWF 55
021C: MOVF 77,W
021D: MOVWF 54
.................... aux = (relogio[6] & 3);
021E: MOVF 4A,W
021F: ANDLW 03
0220: MOVWF 53
.................... if (aux > 0)
0221: MOVF 53,F
0222: BTFSC 03.2
0223: GOTO 256
.................... {
.................... time += 366;
0224: MOVLW 6E
0225: ADDWF 54,F
0226: MOVLW 01
0227: BTFSC 03.0
0228: MOVLW 02
0229: ADDWF 55,F
022A: MOVLW 00
022B: BTFSC 03.0
022C: MOVLW 01
022D: ADDWF 56,F
022E: MOVLW 00
022F: BTFSC 03.0
0230: MOVLW 01
0231: ADDWF 57,F
.................... if (aux > 1)
0232: MOVF 53,W
0233: SUBLW 01
0234: BTFSC 03.0
0235: GOTO 244
.................... time += 365;
0236: MOVLW 6D
0237: ADDWF 54,F
0238: MOVLW 01
0239: BTFSC 03.0
023A: MOVLW 02
023B: ADDWF 55,F
023C: MOVLW 00
023D: BTFSC 03.0
023E: MOVLW 01
023F: ADDWF 56,F
0240: MOVLW 00
0241: BTFSC 03.0
0242: MOVLW 01
0243: ADDWF 57,F
.................... if (aux > 2)
0244: MOVF 53,W
0245: SUBLW 02
0246: BTFSC 03.0
0247: GOTO 256
.................... time += 365;
0248: MOVLW 6D
0249: ADDWF 54,F
024A: MOVLW 01
024B: BTFSC 03.0
024C: MOVLW 02
024D: ADDWF 55,F
024E: MOVLW 00
024F: BTFSC 03.0
0250: MOVLW 01
0251: ADDWF 56,F
0252: MOVLW 00
0253: BTFSC 03.0
0254: MOVLW 01
0255: ADDWF 57,F
.................... }
....................
.................... // Soma os dias até a data atual
.................... time += dias[relogio[4]-1];
0256: MOVLW 01
0257: SUBWF 48,W
0258: CALL 02F
0259: MOVWF 78
025A: ADDWF 54,F
025B: MOVLW 00
025C: BTFSC 03.0
025D: MOVLW 01
025E: ADDWF 55,F
025F: MOVLW 00
0260: BTFSC 03.0
0261: MOVLW 01
0262: ADDWF 56,F
0263: MOVLW 00
0264: BTFSC 03.0
0265: MOVLW 01
0266: ADDWF 57,F
.................... if ((aux == 0) && (relogio[4] > 2))
0267: MOVF 53,F
0268: BTFSS 03.2
0269: GOTO 276
026A: MOVF 48,W
026B: SUBLW 02
026C: BTFSC 03.0
026D: GOTO 276
.................... time++; // ano bissexto
026E: MOVLW 01
026F: ADDWF 54,F
0270: BTFSC 03.0
0271: INCF 55,F
0272: BTFSC 03.2
0273: INCF 56,F
0274: BTFSC 03.2
0275: INCF 57,F
.................... time += relogio[3]-1;
0276: MOVLW 01
0277: SUBWF 47,W
0278: ADDWF 54,F
0279: MOVLW 00
027A: BTFSC 03.0
027B: MOVLW 01
027C: ADDWF 55,F
027D: MOVLW 00
027E: BTFSC 03.0
027F: MOVLW 01
0280: ADDWF 56,F
0281: MOVLW 00
0282: BTFSC 03.0
0283: MOVLW 01
0284: ADDWF 57,F
....................
.................... // Soma as horas
.................... time = time*24UL + (unsigned int32) relogio[2];
0285: MOVF 57,W
0286: MOVWF 60
0287: MOVF 56,W
0288: MOVWF 5F
0289: MOVF 55,W
028A: MOVWF 5E
028B: MOVF 54,W
028C: MOVWF 5D
028D: CLRF 64
028E: CLRF 63
028F: CLRF 62
0290: MOVLW 18
0291: MOVWF 61
0292: CALL 0E0
0293: MOVF 7A,W
0294: MOVWF 5B
0295: MOVF 79,W
0296: MOVWF 5A
0297: MOVF 78,W
0298: MOVWF 59
0299: MOVF 77,W
029A: MOVWF 58
029B: CLRF 78
029C: CLRF 79
029D: CLRF 7A
029E: MOVF 46,W
029F: ADDWF 58,W
02A0: MOVWF 54
02A1: MOVF 59,W
02A2: MOVWF 55
02A3: MOVF 78,W
02A4: BTFSC 03.0
02A5: INCFSZ 78,W
02A6: ADDWF 55,F
02A7: MOVF 5A,W
02A8: MOVWF 56
02A9: MOVF 79,W
02AA: BTFSC 03.0
02AB: INCFSZ 79,W
02AC: ADDWF 56,F
02AD: MOVF 5B,W
02AE: MOVWF 57
02AF: MOVF 7A,W
02B0: BTFSC 03.0
02B1: INCFSZ 7A,W
02B2: ADDWF 57,F
....................
.................... // Soma os minutos
.................... time = time*60UL + (unsigned int32) relogio[1];
02B3: MOVF 57,W
02B4: MOVWF 60
02B5: MOVF 56,W
02B6: MOVWF 5F
02B7: MOVF 55,W
02B8: MOVWF 5E
02B9: MOVF 54,W
02BA: MOVWF 5D
02BB: CLRF 64
02BC: CLRF 63
02BD: CLRF 62
02BE: MOVLW 3C
02BF: MOVWF 61
02C0: CALL 0E0
02C1: MOVF 7A,W
02C2: MOVWF 5B
02C3: MOVF 79,W
02C4: MOVWF 5A
02C5: MOVF 78,W
02C6: MOVWF 59
02C7: MOVF 77,W
02C8: MOVWF 58
02C9: CLRF 78
02CA: CLRF 79
02CB: CLRF 7A
02CC: MOVF 45,W
02CD: ADDWF 58,W
02CE: MOVWF 54
02CF: MOVF 59,W
02D0: MOVWF 55
02D1: MOVF 78,W
02D2: BTFSC 03.0
02D3: INCFSZ 78,W
02D4: ADDWF 55,F
02D5: MOVF 5A,W
02D6: MOVWF 56
02D7: MOVF 79,W
02D8: BTFSC 03.0
02D9: INCFSZ 79,W
02DA: ADDWF 56,F
02DB: MOVF 5B,W
02DC: MOVWF 57
02DD: MOVF 7A,W
02DE: BTFSC 03.0
02DF: INCFSZ 7A,W
02E0: ADDWF 57,F
....................
.................... // Soma os segundos
.................... time = time*60UL + (unsigned int32) relogio[0];
02E1: MOVF 57,W
02E2: MOVWF 60
02E3: MOVF 56,W
02E4: MOVWF 5F
02E5: MOVF 55,W
02E6: MOVWF 5E
02E7: MOVF 54,W
02E8: MOVWF 5D
02E9: CLRF 64
02EA: CLRF 63
02EB: CLRF 62
02EC: MOVLW 3C
02ED: MOVWF 61
02EE: CALL 0E0
02EF: MOVF 7A,W
02F0: MOVWF 5B
02F1: MOVF 79,W
02F2: MOVWF 5A
02F3: MOVF 78,W
02F4: MOVWF 59
02F5: MOVF 77,W
02F6: MOVWF 58
02F7: CLRF 78
02F8: CLRF 79
02F9: CLRF 7A
02FA: MOVF 44,W
02FB: ADDWF 58,W
02FC: MOVWF 54
02FD: MOVF 59,W
02FE: MOVWF 55
02FF: MOVF 78,W
0300: BTFSC 03.0
0301: INCFSZ 78,W
0302: ADDWF 55,F
0303: MOVF 5A,W
0304: MOVWF 56
0305: MOVF 79,W
0306: BTFSC 03.0
0307: INCFSZ 79,W
0308: ADDWF 56,F
0309: MOVF 5B,W
030A: MOVWF 57
030B: MOVF 7A,W
030C: BTFSC 03.0
030D: INCFSZ 7A,W
030E: ADDWF 57,F
....................
.................... // Contar a partir do EPOCH0
.................... time -= EPOCH0;
030F: MOVLW 4F
0310: SUBWF 54,F
0311: MOVLW 37
0312: BTFSS 03.0
0313: MOVLW 38
0314: SUBWF 55,F
0315: MOVLW F4
0316: BTFSS 03.0
0317: MOVLW F5
0318: SUBWF 56,F
0319: MOVLW 14
031A: BTFSS 03.0
031B: MOVLW 15
031C: SUBWF 57,F
....................
.................... // coloca no valor do display
.................... disable_interrupts (INT_RTCC);
031D: BCF 0B.5
.................... for (i = 0; i < 16; i++)
031E: CLRF 52
031F: MOVF 52,W
0320: SUBLW 0F
0321: BTFSS 03.0
0322: GOTO 36B
.................... {
.................... valor[15-i] = time % 10L;
0323: MOVF 52,W
0324: SUBLW 0F
0325: ADDLW 28
0326: MOVWF 78
0327: CLRF 7A
0328: BTFSC 03.0
0329: INCF 7A,F
032A: MOVF 78,W
032B: MOVWF 58
032C: MOVF 7A,W
032D: MOVWF 59
032E: CLRF 5B
032F: MOVF 04,W
0330: MOVWF 5A
0331: BCF 5B.0
0332: BTFSC 03.7
0333: BSF 5B.0
0334: BSF 03.1
0335: MOVLW 5C
0336: MOVWF 04
0337: BCF 03.7
0338: MOVF 57,W
0339: MOVWF 63
033A: MOVF 56,W
033B: MOVWF 62
033C: MOVF 55,W
033D: MOVWF 61
033E: MOVF 54,W
033F: MOVWF 60
0340: CLRF 67
0341: CLRF 66
0342: CLRF 65
0343: MOVLW 0A
0344: MOVWF 64
0345: CALL 10A
0346: MOVF 5A,W
0347: MOVWF 04
0348: BCF 03.7
0349: BTFSC 5B.0
034A: BSF 03.7
034B: MOVF 58,W
034C: MOVWF 04
034D: BCF 03.7
034E: BTFSC 59.0
034F: BSF 03.7
0350: MOVF 5C,W
0351: MOVWF 00
.................... time = time / 10L;
0352: BCF 03.1
0353: MOVF 57,W
0354: MOVWF 63
0355: MOVF 56,W
0356: MOVWF 62
0357: MOVF 55,W
0358: MOVWF 61
0359: MOVF 54,W
035A: MOVWF 60
035B: CLRF 67
035C: CLRF 66
035D: CLRF 65
035E: MOVLW 0A
035F: MOVWF 64
0360: CALL 10A
0361: MOVF 7A,W
0362: MOVWF 57
0363: MOVF 79,W
0364: MOVWF 56
0365: MOVF 78,W
0366: MOVWF 55
0367: MOVF 77,W
0368: MOVWF 54
.................... }
0369: INCF 52,F
036A: GOTO 31F
.................... enable_interrupts (INT_RTCC);
036B: BSF 0B.5
.................... }
036C: RETURN
....................
.................... // Trata comunicação com o PC
.................... void TrataUart (void)
.................... {
.................... char c;
.................... int i;
....................
.................... if (kbhit())
*
037C: BTFSS 0C.5
037D: GOTO 46D
.................... {
.................... c = getc();
037E: BTFSS 0C.5
037F: GOTO 37E
0380: MOVF 1A,W
0381: MOVWF 50
.................... if (c != CR)
0382: MOVF 50,W
0383: SUBLW 0D
0384: BTFSS 03.2
.................... return;
0385: GOTO 46D
....................
.................... output_high (LED);
0386: BSF 07.3
.................... putchar (CR);
0387: MOVLW 0D
0388: BTFSS 0C.4
0389: GOTO 388
038A: MOVWF 19
.................... putchar (LF);
038B: MOVLW 0A
038C: BTFSS 0C.4
038D: GOTO 38C
038E: MOVWF 19
.................... putchar ('>');
038F: MOVLW 3E
0390: BTFSS 0C.4
0391: GOTO 390
0392: MOVWF 19
.................... i = c = 0;
0393: CLRF 50
0394: MOVF 50,W
0395: MOVWF 51
.................... //ddmmaahhmmss
.................... while ((c != CR) || (i != 12))
.................... {
0396: MOVF 50,W
0397: SUBLW 0D
0398: BTFSS 03.2
0399: GOTO 39E
039A: MOVF 51,W
039B: SUBLW 0C
039C: BTFSC 03.2
039D: GOTO 3D7
.................... c = getc();
039E: BTFSS 0C.5
039F: GOTO 39E
03A0: MOVF 1A,W
03A1: MOVWF 50
.................... if ((c == ESC) || (c == 0))
03A2: MOVF 50,W
03A3: SUBLW 1B
03A4: BTFSC 03.2
03A5: GOTO 3A8
03A6: MOVF 50,F
03A7: BTFSC 03.2
.................... break;
03A8: GOTO 3D7
.................... if ((c == BS) && (i > 0))
03A9: MOVF 50,W
03AA: SUBLW 08
03AB: BTFSS 03.2
03AC: GOTO 3BE
03AD: MOVF 51,F
03AE: BTFSC 03.2
03AF: GOTO 3BE
.................... {
.................... putchar(BS);
03B0: MOVLW 08
03B1: BTFSS 0C.4
03B2: GOTO 3B1
03B3: MOVWF 19
.................... putchar(' ');
03B4: MOVLW 20
03B5: BTFSS 0C.4
03B6: GOTO 3B5
03B7: MOVWF 19
.................... putchar(BS);
03B8: MOVLW 08
03B9: BTFSS 0C.4
03BA: GOTO 3B9
03BB: MOVWF 19
.................... i--;
03BC: DECF 51,F
.................... }
.................... else if ((i < 12) && (c >= '0') && (c <= '9'))
03BD: GOTO 3D6
03BE: MOVF 51,W
03BF: SUBLW 0B
03C0: BTFSS 03.0
03C1: GOTO 3D6
03C2: MOVF 50,W
03C3: SUBLW 2F
03C4: BTFSC 03.0
03C5: GOTO 3D6
03C6: MOVF 50,W
03C7: SUBLW 39
03C8: BTFSS 03.0
03C9: GOTO 3D6
.................... {
.................... putchar(c);
03CA: MOVF 50,W
03CB: BTFSS 0C.4
03CC: GOTO 3CB
03CD: MOVWF 19
.................... horario[i++] = c-'0';
03CE: MOVF 51,W
03CF: INCF 51,F
03D0: ADDLW 38
03D1: MOVWF 04
03D2: BCF 03.7
03D3: MOVLW 30
03D4: SUBWF 50,W
03D5: MOVWF 00
.................... }
.................... }
03D6: GOTO 396
.................... putchar (CR);
03D7: MOVLW 0D
03D8: BTFSS 0C.4
03D9: GOTO 3D8
03DA: MOVWF 19
.................... putchar (LF);
03DB: MOVLW 0A
03DC: BTFSS 0C.4
03DD: GOTO 3DC
03DE: MOVWF 19
.................... if (c != ESC)
03DF: MOVF 50,W
03E0: SUBLW 1B
03E1: BTFSC 03.2
03E2: GOTO 46C
.................... {
.................... relogio[0] = (horario[10] << 4) | horario[11];
03E3: SWAPF 42,W
03E4: MOVWF 77
03E5: MOVLW F0
03E6: ANDWF 77,F
03E7: MOVF 77,W
03E8: IORWF 43,W
03E9: MOVWF 44
.................... relogio[1] = (horario[8] << 4) | horario[9];
03EA: SWAPF 40,W
03EB: MOVWF 77
03EC: MOVLW F0
03ED: ANDWF 77,F
03EE: MOVF 77,W
03EF: IORWF 41,W
03F0: MOVWF 45
.................... relogio[2] = (horario[6] << 4) | horario[7];
03F1: SWAPF 3E,W
03F2: MOVWF 77
03F3: MOVLW F0
03F4: ANDWF 77,F
03F5: MOVF 77,W
03F6: IORWF 3F,W
03F7: MOVWF 46
.................... relogio[3] = (horario[0] << 4) | horario[1];
03F8: SWAPF 38,W
03F9: MOVWF 77
03FA: MOVLW F0
03FB: ANDWF 77,F
03FC: MOVF 77,W
03FD: IORWF 39,W
03FE: MOVWF 47
.................... relogio[4] = (horario[2] << 4) | horario[3];
03FF: SWAPF 3A,W
0400: MOVWF 77
0401: MOVLW F0
0402: ANDWF 77,F
0403: MOVF 77,W
0404: IORWF 3B,W
0405: MOVWF 48
.................... relogio[5] = 1;
0406: MOVLW 01
0407: MOVWF 49
.................... relogio[6] = (horario[4] << 4) | horario[5];
0408: SWAPF 3C,W
0409: MOVWF 77
040A: MOVLW F0
040B: ANDWF 77,F
040C: MOVF 77,W
040D: IORWF 3D,W
040E: MOVWF 4A
.................... relogio[7] = 0x80;
040F: MOVLW 80
0410: MOVWF 4B
....................
.................... for (i = 0; i < 8; i++)
0411: CLRF 51
0412: MOVF 51,W
0413: SUBLW 07
0414: BTFSS 03.0
0415: GOTO 433
.................... {
.................... putchar (hexa[relogio[i] >> 4]);
0416: MOVLW 44
0417: ADDWF 51,W
0418: MOVWF 04
0419: BCF 03.7
041A: SWAPF 00,W
041B: MOVWF 77
041C: MOVLW 0F
041D: ANDWF 77,F
041E: MOVF 77,W
041F: CALL 03F
0420: BTFSS 0C.4
0421: GOTO 420
0422: MOVWF 19
.................... putchar (hexa[relogio[i] & 0x0F]);
0423: MOVLW 44
0424: ADDWF 51,W
0425: MOVWF 04
0426: BCF 03.7
0427: MOVF 00,W
0428: ANDLW 0F
0429: CALL 03F