-
Notifications
You must be signed in to change notification settings - Fork 0
/
EM4095.a51
923 lines (759 loc) · 15.2 KB
/
EM4095.a51
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
$nomod51
$include (89S8253.mcu)
$include (ascii.a51)
KartenAnzahl EQU 250
EEMEN EQU 00001000b
EEMWE EQU 00010000b
DPS EQU 00000100b
EELD EQU 00100000b
TasterAdmin bit P3.6
TasterErase bit P3.7
ledGreen bit P1.0
ledRed bit P1.1
ledBlue bit P1.2
Pipser bit P2.7
Relais bit P2.6
RelaisTimeJumper bit P3.5
MOD_ bit P2.3
SHD bit P2.4
DEMOD bit P3.2
;RDY_CLK bit P3.4
inBufCount EQU 41
byteCtr EQU R3 ;wird in Empfangsroutine verwendet(uart.a51)
;byteCtrTest EQU R4
;R2 und R3 ist algemeiner djnz Hilfsvariable
;R3 is bitCounter
bitCtr EQU R4
bitCtr2 EQU R5
CtrEm4102Row EQU R6
Em4102ReadTrys EQU R7
;Variablen Deklaration
DSEG AT 48
msgRam : DS 32 ;Erstes Byte(msgRam+0) ist KommandoByte in ASCII
_50Hz_TeilerT1 : DS 1
_2Hz_TeilerT1 : DS 1
_1Hz_TeilerT1 : DS 1
_02Hz_TeilerT1 : DS 1
sendBuf : DS 7
LastCard : DS 4
CurrCard : DS 4
Em4102Rows : DS 11
CtrCardOk : DS 1
BSEG AT 0
_50HzT1 : DBIT 1
_2HzT1 : DBIT 1
_1HzT1 : DBIT 1
_02HzT1 : DBIT 1
Make : DBIT 1
CardSame : DBIT 1
MasterCardPresent : DBIT 1
CardInDB : DBIT 1
eepromFull : DBIT 1
TimeOut : DBIT 1
NormalMode : DBIT 1
ManchesterInverted : DBIT 1
CardPresent : DBIT 1
CaptureState EQU 2Fh ; Ganz oben auf dem Bitbereich
;CaptureState.0 = Header bits (Capture begin)
;CaptureState.1 = Customer ID bits
;CaptureState.2 = Data bits
;CaptureState.3 = Column parity bits
;CaptureState.4 = Capture ended
;CaptureState.5 = Capture Result
ISEG AT 128
inBuf : DS 41
STACK : DS 1
CSEG AT RESET
LJMP Startup
ORG EXTI0
LJMP EXTI0_ISR
ORG TIMER0
LJMP TIMER0_ISR
ORG EXTI1
LJMP EXTI1_ISR
ORG TIMER1
LJMP TIMER1_ISR
ORG SINT
LJMP uart_isr
ORG TIMER2
RETI
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
EXTI0_ISR:
clr EX0
clr TR0
mov TL0, #240
mov TH0, #224
mov CaptureState, #1 ;setb SyncFlag
setb TR0
EXTI0_ISR_EXIT:
RETI
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;
EXTI1_ISR:
RETI
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
TIMER0_ISR: ;Timer 0 Interrupt
jnb CaptureState.0, CheckCaptureState2 ;Quasi 1 Startbit
jb Demod, TIMER0_ISR_EXIT_Error
mov bitCtr, #16
mov CaptureState, #2
setb ManchesterInverted
RETI
CheckCaptureState2:
jnb CaptureState.1, CheckCaptureState4 ;8 Header Bits
jnb ManchesterInverted, CheckManchesterInverted
clr ManchesterInverted
jnb Demod, TIMER0_ISR_EXIT_Error
sjmp CheckBitCounter
CheckManchesterInverted:
setb ManchesterInverted
jb Demod, TIMER0_ISR_EXIT_Error
CheckBitCounter:
djnz bitCtr, TIMER0_ISR_EXIT
mov CaptureState,#4
setb ManchesterInverted
mov bitCtr, #10
mov CtrEm4102Row, #10
mov R0, #Em4102Rows+0
RETI
CheckCaptureState4: ;Customer Id
jnb CaptureState.2, CheckCaptureState8
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
jnb ManchesterInverted, CheckManchesterInverted1
clr ManchesterInverted
mov C, Demod
rrc A
sjmp CheckBitCounter1
CheckManchesterInverted1:
setb ManchesterInverted
;do nothing here
CheckBitCounter1:
djnz bitCtr, TIMER0_ISR_EXIT
rr A
rr A
rr A
mov C, ACC.4 ;Parity
anl A, #00001111b
jnc CheckPis0
jnb p, err
sjmp RowCaptured
CheckPis0:
jb p, err
sjmp RowCaptured
err:
clr TR0
mov CaptureState,#00010000b ;Capture ended with error
RETI
RowCaptured:
mov @R0, A
inc R0
djnz CtrEm4102Row, Reinit1
mov CaptureState,#8
mov bitCtr, #10
setb ManchesterInverted
RETI
Reinit1:
mov bitCtr, #10
RETI
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
CheckCaptureState8: ;Data bits
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
jnb ManchesterInverted, CheckManchesterInverted2
clr ManchesterInverted
mov C, Demod
rrc A
sjmp CheckBitCounter2
CheckManchesterInverted2:
setb ManchesterInverted
;do nothing here
CheckBitCounter2:
djnz bitCtr, TIMER0_ISR_EXIT
rr A
rr A
rr A
jb ACC.4, err
anl A, #00001111b
mov @R0, A
;5 Bits Captured
clr TR0
mov CaptureState,#00110000b ;Capture ended with success
RETI
TIMER0_ISR_EXIT_Error:
clr TR0
mov CaptureState,#00010000b ;Capture ended with error
TIMER0_ISR_EXIT:
RETI
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
TIMER1_ISR: ;Timer 1 Interrupt
djnz _50Hz_TeilerT1, TIMER1_ISR_EXIT
mov _50Hz_TeilerT1, #200
setb _50HzT1
djnz _2Hz_TeilerT1, TIMER1_ISR_EXIT
mov _2Hz_TeilerT1, #25
setb _2HzT1
jb NormalMode, NormalModeLabel
cpl ledBlue
NormalModeLabel:
djnz _1Hz_TeilerT1, TIMER1_ISR_EXIT
mov _1Hz_TeilerT1, #2
setb _1HzT1
djnz _02Hz_TeilerT1, TIMER1_ISR_EXIT
mov _02Hz_TeilerT1, #5
setb _02HzT1
jb Relais, SetBitTimeOut
setb Relais
clr ledGreen
setb ledBlue
RETI
SetBitTimeOut:
setb TimeOut ;For Add Cards Mode
TIMER1_ISR_EXIT:
RETI
ORG RESET + 200H
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$include (uart.a51)
$include (time.a51)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
startup:
mov SP, #Stack
orl WDTCON, #11100000b ;2 sec
orl WDTCON, #00000100b ;enable hardware watchdog
mov WDTRST, #01Eh
mov WDTRST, #0E1h; Watchdog enabled
mov _50Hz_TeilerT1, #200
clr _50HzT1
mov _2Hz_TeilerT1, #25
clr _2HzT1
mov _1Hz_TeilerT1, #2
clr _1HzT1
mov _02Hz_TeilerT1, #5
clr _02HzT1
lcall PrepareDataReception
lcall init_uart_intr
mov TL1, #9Ch
mov TH1, #9Ch
mov TMOD, #00100110b ;T1=Autoreload; and T0=Autoreload
mov IP, #00010000b ;Prioritaet fuer Serial Port
;IE REGISTER
setb ET0
setb ET1
setb ES
setb EA
;mov IE, #10011010b ;EA, ES, T1, T0 Interrupt freigeben
;;;;;;;;;;;;;;;;;;;;;;;;;;;
;TCON REGISTER
setb IT0
setb TR1
;;;;;;;;;;;;;;;;
orl eecon, #eemen ;eeprom einschalten
mov LastCard+0, #0FFh
mov LastCard+1, #0FFh
mov LastCard+2, #0FFh
mov LastCard+3, #0FFh
clr CardSame
clr MasterCardPresent
lcall Em4095SetUp
clr ledRed
clr ledGreen
clr ledBlue
setb NormalMode
;ljmp LoopNormalMode
jb TasterAdmin, CheckTasteErase
clr pipser
clr ledBlue
mov A, #50
lcall F_wait_m
setb pipser
mov A, #50
lcall F_wait_m
clr pipser
mov A, #50
lcall F_wait_m
setb pipser
LJMP LoopProgAdminMode
CheckTasteErase:
jb TasterErase, LoopNormalModePre
clr pipser
clr ledBlue
mov A, #50
lcall F_wait_m
setb pipser
mov A, #50
lcall F_wait_m
clr pipser
mov A, #50
lcall F_wait_m
setb pipser
LJMP EraseEeprom
;*****************************************************************************
;H A U P T P R O G R A M
;*****************************************************************************
LoopNormalModePre:
setb ledBlue
LoopNormalMode:
jnb _50HzT1, LoopNormalMode
clr _50HzT1
mov WDTRST, #01Eh
mov WDTRST, #0E1h
lcall ReadEM
jnb CardPresent, LoopNormalMode
;mov sbuf, CurrCard+0
;mov A, #10
;lcall F_wait_m
;mov sbuf, CurrCard+1
;mov A, #10
;lcall F_wait_m
;mov sbuf, CurrCard+2
;mov A, #10
;lcall F_wait_m
;mov sbuf, CurrCard+3
;mov A, #10
;lcall F_wait_m
;ljmp LoopNormalMode
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
lcall LastCardCheck
jnb CardSame, CheckFirstMasterCard ;SameCard
ljmp LoopNormalMode
CheckFirstMasterCard:
lcall MasterCardCheck
jnb MasterCardPresent, CheckNormal
ljmp LoopProgAddDelMode
CheckNormal:
lcall LookUpCardInDB
jnb CardInDB, CardNotInDB
clr Relais ;CardInDb
clr pipser
clr ledBlue
setb LedGreen
mov A, #50
lcall F_wait_m
jnb RelaisTimeJumper, LoadCloseTime5Sec
mov _02Hz_TeilerT1, #2
ljmp LoadCloseTime1SecLoaded
LoadCloseTime5Sec:
mov _02Hz_TeilerT1, #5
LoadCloseTime1SecLoaded:
setb pipser
LJMP LoopNormalMode
CardNotInDB: ;CardNotInDb
clr ledBlue
clr pipser
setb LedRed
mov A, #50
lcall F_wait_m
setb pipser
clr LedRed
mov A, #50
lcall F_wait_m
clr pipser
setb LedRed
mov A, #50
lcall F_wait_m
setb pipser
clr LedRed
setb LedBlue
LJMP LoopNormalMode
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
LoopProgAddDelMode:
clr NormalMode
setb Relais
clr ledBlue
clr Pipser
mov A, #255
lcall F_wait_m
setb Pipser
clr ledRed
orl eecon, #eemwe ;schreiben freigeben
mov _02Hz_TeilerT1, #10
clr TimeOut
LoopProgAddDelMode1:
jnb _50HzT1, LoopProgAddDelMode1
clr _50HzT1
mov WDTRST, #01Eh
mov WDTRST, #0E1h
jb TimeOut, ContinueAddDelExit
lcall ReadEm
jnb CardPresent, LoopProgAddDelMode1
mov _02Hz_TeilerT1, #10 ;Timeout verhindern
lcall LastCardCheck ;Hier adden oder deleten
jb CardSame, LoopProgAddDelMode1
lcall MasterCardCheck
jnb MasterCardPresent, ContinueAddDel
ContinueAddDelExit:
xrl eecon, #eemwe ;schreiben sperren
clr Pipser
clr ledBlue
mov A, #255
lcall F_wait_m
setb Pipser
setb ledBlue
setb NormalMode
ljmp LoopNormalMode ;Dieses Loop verlasssen
ContinueAddDel:
lcall LookUpCardInDB
jb CardInDB, DeleteCard
;Add Cards here
lcall GetFreePlace
jnb eepromFull, RegisterCard
setb ledRed
setb ledGreen
clr Pipser
mov A, #255
lcall F_wait_m
clr ledRed
clr ledGreen
setb Pipser
ljmp LoopProgAddDelMode1
RegisterCard:
clr TR1
clr ledBlue
clr Pipser
setb ledGreen
;mov dptr, #0 ;eepromadresse
mov A, #0 ; 4 Byte belegt kennzeichen
movx @dptr, A
mov A, #10
lcall F_wait_m
inc dptr
mov A, CurrCard+0 ; date zum schreiben
movx @dptr, A
mov A, #10
lcall F_wait_m
inc dptr
mov A, CurrCard+1 ; date zum schreiben
movx @dptr, A
mov A, #10
lcall F_wait_m
inc dptr
mov A, CurrCard+2 ; date zum schreiben
movx @dptr, A
mov A, #10
lcall F_wait_m
inc dptr
mov A, CurrCard+3 ; date zum schreiben
movx @dptr, A
mov A, #10
lcall F_wait_m
mov A, #50
lcall F_wait_m
setb Pipser
mov A, #255
lcall F_wait_m
clr ledGreen
setb TR1
LJMP LoopProgAddDelMode1
;;;;;;;;;;
DeleteCard:
clr TR1
clr ledBlue
clr Pipser
setb ledRed
;mov dptr, #0 ;eepromadresse
mov A, #0FFh ; date zum schreiben
movx @dptr, A
mov A, #100
lcall F_wait_m
setb Pipser
mov A, #255
lcall F_wait_m
clr ledRed
setb TR1
LJMP LoopProgAddDelMode1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
LoopProgAdminMode:
mov WDTRST, #01Eh
mov WDTRST, #0E1h
lcall ReadEm
jnb CardPresent, LoopProgAdminMode
clr Pipser
orl eecon, #eemwe ;schreiben freigeben
mov dptr, #0 ;eepromadresse
mov A, #0 ; date zum schreiben
movx @dptr, A
mov A, #10
lcall F_wait_m
mov dptr, #1 ;eepromadresse
mov A, CurrCard+0 ; date zum schreiben
movx @dptr, A
mov A, #10
lcall F_wait_m
mov dptr, #2 ;eepromadresse
mov A, CurrCard+1 ; date zum schreiben
movx @dptr, A
mov A, #10
lcall F_wait_m
mov dptr, #3 ;eepromadresse
mov A, CurrCard+2 ; date zum schreiben
movx @dptr, A
mov A, #10
lcall F_wait_m
mov dptr, #4 ;eepromadresse
mov A, CurrCard+3 ; date zum schreiben
movx @dptr, A
mov A, #10
lcall F_wait_m
xrl eecon, #eemwe ;schreiben sperren
setb Pipser
BlinkInLoopProgAdminMode:
cpl LedRed
mov A, #50
lcall F_wait_m
mov WDTRST, #01Eh
mov WDTRST, #0E1h; Watchdog enabled
LJMP BlinkInLoopProgAdminMode
;LJMP LoopNormalMode
;*****************************************************************************
;H A U P T P R O G R A M E N D E
;*****************************************************************************
LastCardCheck:
mov A, LastCard+0
cjne A, CurrCard+0, LastCardCheckExit
mov A, LastCard+1
cjne A, CurrCard+1, LastCardCheckExit
mov A, LastCard+2
cjne A, CurrCard+2, LastCardCheckExit
mov A, LastCard+3
cjne A, CurrCard+3, LastCardCheckExit
setb CardSame
RET
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
LastCardCheckExit:
mov LastCard+0, CurrCard+0
mov LastCard+1, CurrCard+1
mov LastCard+2, CurrCard+2
mov LastCard+3, CurrCard+3
clr CardSame
RET
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
MasterCardCheck:
mov DPTR, #1
movx A, @DPTR
cjne A, CurrCard+0, MasterCardCheckExit
mov DPTR, #2
movx A, @DPTR
cjne A, CurrCard+1, MasterCardCheckExit
mov DPTR, #3
movx A, @DPTR
cjne A, CurrCard+2, MasterCardCheckExit
mov DPTR, #4
movx A, @DPTR
cjne A, CurrCard+3, MasterCardCheckExit
setb MasterCardPresent
RET
MasterCardCheckExit:
clr MasterCardPresent
RET
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
LookUpCardInDB:
clr CardInDB
mov DPTR, #0
mov R2, #KartenAnzahl
LookUpInDB:
inc DPTR
inc DPTR
inc DPTR
inc DPTR
inc DPTR
movx A, @DPTR
jz CardChecken
ContinueLookUpInDB:
;jb CardInDB, LookUpInDBExit
djnz R2, LookUpInDB
;LookUpInDBExit:
RET
CardChecken:
mov DP1L, DP0L
mov DP1H, DP0H
orl EECON, #DPS
inc DPTR
movx A, @DPTR
cjne A, CurrCard+0, CardCheckenExit
inc DPTR
movx A, @DPTR
cjne A, CurrCard+1, CardCheckenExit
inc DPTR
movx A, @DPTR
cjne A, CurrCard+2, CardCheckenExit
inc DPTR
movx A, @DPTR
cjne A, CurrCard+3, CardCheckenExit
xrl EECON, #DPS
setb CardInDB
RET
;ljmp ContinueLookUpInDB1
CardCheckenExit:
xrl EECON, #DPS
clr CardInDB
ljmp ContinueLookUpInDB
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
GetFreePlace:
mov DPTR, #0
mov R2, #KartenAnzahl
clr eepromFull
GetFreePlace1:
inc DPTR
inc DPTR
inc DPTR
inc DPTR
inc DPTR
movx A, @DPTR
jz ContinueGetFreePlace1
RET
ContinueGetFreePlace1:
djnz R2, GetFreePlace1
setb eepromFull
RET
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
EraseEeprom:
orl eecon,#eemwe ;write enable
mov R2, #31
mov R3, #64
mov dptr,#0
orl eecon, #eeld
mov A, #0FFh
ContunueLoadingFF:
movx @dptr, A
inc dptr
djnz R2, ContunueLoadingFF
xrl eecon, #eeld ;Load last byte in page and program it
movx @dptr, A
mov A, #10
lcall F_wait_m
mov A, #0FFh
mov R2, #31
inc dptr
orl eecon, #eeld
djnz R3, ContunueLoadingFF
xrl eecon, #eeld
xrl eecon, #eemwe
;NUN Pruefen
mov R2, #32
mov R3, #64
mov dptr,#0
ContunueCheckingFF:
movx A, @dptr
cjne A, #0FFh, EepromBad
inc dptr
djnz R2, ContunueCheckingFF
mov R2, #32
djnz R3, ContunueCheckingFF
EepromOK:
cpl ledGreen
mov A, #100
lcall F_wait_m
mov WDTRST, #01Eh
mov WDTRST, #0E1h
ljmp EepromOK
EepromBad:
cpl ledRed
mov A, #50
lcall F_wait_m
mov WDTRST, #01Eh
mov WDTRST, #0E1h
ljmp EepromBad
;*****************************************************************************
;EM4095 R E A D
;*****************************************************************************
ReadEM:
mov CtrCardOk, #3
clr CardPresent
ReadEM1:
mov Em4102ReadTrys, #128
ReadEM2:
djnz Em4102ReadTrys, CountinueTry
clr CardPresent
mov LastCard+0, #0FFh
mov LastCard+1, #0FFh
mov LastCard+2, #0FFh
mov LastCard+3, #0FFh
RET
CountinueTry:
clr CaptureState.4
setb EX0
jnb CaptureState.4, $
jnb CaptureState.5, ReadEM2
mov A, Em4102Rows+0
xrl A, Em4102Rows+1
xrl A, Em4102Rows+2
xrl A, Em4102Rows+3
xrl A, Em4102Rows+4
xrl A, Em4102Rows+5
xrl A, Em4102Rows+6
xrl A, Em4102Rows+7
xrl A, Em4102Rows+8
xrl A, Em4102Rows+9
xrl A, Em4102Rows+10
jnz ReadEM2
djnz CtrCardOk, ReadEM1
;;;;;;;;;;;;;;;;;;;;;;
mov A, Em4102Rows+2
swap A
mov Em4102Rows+2, A
mov A, Em4102Rows+3
orl A, Em4102Rows+2
mov CurrCard+0, A
;;;;;;;;;;;;;;;;;;;;;;
mov A, Em4102Rows+4
swap A
mov Em4102Rows+4, A
mov A, Em4102Rows+5
orl A, Em4102Rows+4
mov CurrCard+1, A
;;;;;;;;;;;;;;;;;;;;;;
mov A, Em4102Rows+6
swap A
mov Em4102Rows+6, A
mov A, Em4102Rows+7
orl A, Em4102Rows+6
mov CurrCard+2, A
;;;;;;;;;;;;;;;;;;;;;;
mov A, Em4102Rows+8
swap A
mov Em4102Rows+8, A
mov A, Em4102Rows+9
orl A, Em4102Rows+8
mov CurrCard+3, A
;;;;;;;;;;;;;;;;;;;;;;
setb CardPresent
RET
;*****************************************************************************
;EM4095 M O D U L E C O N F I G U R A T I O N
;*****************************************************************************
EM4095SetUp:
clr Mod_
setb shd
lcall ws35ms
clr shd
lcall ws35ms
RET
;CardMaster : db 0A2h, 5Ch, 48h, 0AFh
; Warteschleife: 35 ms
; Anzahl Maschinenzyklen: 35000
ws35ms:
push PSW
push 0
push 1
mov 1,#159
ws35ms_labelB1:
mov 0,#18
ws35ms_labelB0:
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
djnz 0,ws35ms_labelB0
djnz 1,ws35ms_labelB1
nop
nop
pop 1
pop 0
pop PSW
ret
END