-
Notifications
You must be signed in to change notification settings - Fork 0
/
7SEG_M5450_Receiver.a51
491 lines (407 loc) · 9.08 KB
/
7SEG_M5450_Receiver.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
$nomod51
$include (89S8253.mcu)
SOH EQU 0FAh
ETB EQU 0FBh
ACK EQU 0FCh
NAK EQU 0FDh
eemen EQU 00001000b
eemwe EQU 00010000b
eeld EQU 00100000b
DataEnable bit P1.0
DataIn bit P1.1
Clock bit P1.2
llPort EQU P2
ScanPort EQU P2
; DATA FORMAT
;Low Nibble bildet einen BCD Wert
;High Nibble ist als Parameter integriert
;Bit 4 kennzeichnet "Komma"
;Bit 5 kennzeichnet "Blinken"
PROG EQU RESET ;STARTING ADDRESS FOR THE PROGRAM
inBufCount EQU 10
byteCtr EQU R3 ;wird in Empfangsroutine verwendet(uart.a51)
Row EQU R2
;Variablen Deklaration
DSEG AT 48
msgRam : DS 32
driverRam : DS 4
_400Hz_Teiler : DS 1
bitCtr : DS 1
copyCtr : DS 1
KommaChecker : DS 1
animChar : DS 1
LEDmuster : DS 1
llTimer : DS 1
_7segMuster : DS 2
temp1 : DS 1
answerToPC : DS 1
inBuf : DS 10 ;1 AddrField + 8Digits + 1ETB
BSEG AT 0
_400Hz : DBIT 1
blink : DBIT 1
llDirection : DBIT 1
TransferComplete : DBIT 1
ISEG AT 128
STACK : DS 1
CSEG AT Prog
ORG PROG + RESET
LJMP startup
ORG PROG + EXTI0
RETI
ORG PROG + TIMER0 ;SERVED
ljmp TIMER0_ISR
ORG PROG + EXTI1
RETI
ORG PROG + TIMER1
RETI
ORG PROG + SINT ;SERVED
ljmp uart_isr
ORG PROG + TIMER2
RETI
TIMER0_ISR: ;Timer 0 Interrupt
;3900KHz @12MHZ; 3600KHz @11MHz
djnz _400Hz_Teiler, Retii ;400Hz Teiler
mov _400Hz_Teiler, #8
setb _400Hz
Retii:
RETI
ORG PROG + 100H
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$include (uart.a51)
$include (time.a51)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
startup:
clr DataEnable
mov ScanPort, #0
mov SP, #Stack
;von eeprom laden
orl eecon, #eemen ;eeprom einschalten
mov R1, #msgRam+0
mov dptr, #0 ; zeiger auf eeprom adresse
mov byteCtr, #32
LoadByte:
movx A, @DPTR
mov @R1, A
inc R1
inc dptr
djnz byteCtr, LoadByte
xrl eecon, #eemen ;eeprom auschalten
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
mov row,#00000001b ;row1
mov _400Hz_Teiler, #9
clr _400Hz
lcall PrepareDataReception
lcall init_uart_intr
mov TL0, #0
mov TH0, #0
mov TMOD, #00000010b ;T0 im 8-Bit Autoreloadmodus
setb TR0
mov IP, #00010000b ;Prioritaet fuer Serial Port
mov IE, #10010010b ;T0, ES, und EA Interrupt freigeben
mov animChar, #10000000b
mov copyCtr, #24
lcall AnimDisp ;Dauert ca. 6 Sekunden
mov ScanPort, #0
mov LEDmuster, #01111111b
mov llTimer, #5
mov _7segMuster+1, #00000100b
mov _7segMuster+0, #1000000b
mov temp1, #2
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;MAIN LOOP
LOOP:
jnb _400Hz, Loop
clr _400Hz
lcall Display
sjmp Loop
;*****************************************************************************
;HAUPTPROGRAM ENDE************************************************************
;*****************************************************************************
;Hier muessen 35 Bit herausgeschoben werden + 1 Bit fuer den Start
Display:
anl ScanPort, #00000000b
cjne row, #1, checkRow1
mov driverRam+0, msgRam+0
mov driverRam+1, msgRam+8
mov driverRam+2, msgRam+16
mov driverRam+3, msgRam+24
lcall getPat
ljmp M5450
checkRow1:
cjne row, #2, checkRow2
mov driverRam+0, msgRam+1
mov driverRam+1, msgRam+9
mov driverRam+2, msgRam+17
mov driverRam+3, msgRam+25
lcall getPat
ljmp M5450
checkRow2:
cjne row, #4, checkRow3
mov driverRam+0, msgRam+2
mov driverRam+1, msgRam+10
mov driverRam+2, msgRam+18
mov driverRam+3, msgRam+26
lcall getPat
ljmp M5450
checkRow3:
cjne row, #8, checkRow4
mov driverRam+0, msgRam+3
mov driverRam+1, msgRam+11
mov driverRam+2, msgRam+19
mov driverRam+3, msgRam+27
lcall getPat
ljmp M5450
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
checkRow4:
cjne row, #16, checkRow5
mov driverRam+0, msgRam+4
mov driverRam+1, msgRam+12
mov driverRam+2, msgRam+20
mov driverRam+3, msgRam+28
lcall getPat
ljmp M5450
checkRow5:
cjne row, #32, checkRow6
mov driverRam+0, msgRam+5
mov driverRam+1, msgRam+13
mov driverRam+2, msgRam+21
mov driverRam+3, msgRam+29
lcall getPat
ljmp M5450
checkRow6:
cjne row, #64, checkRow7
mov driverRam+0, msgRam+6
mov driverRam+1, msgRam+14
mov driverRam+2, msgRam+22
mov driverRam+3, msgRam+30
lcall getPat
ljmp M5450
checkRow7:
cjne row, #128, DisplayExit
mov driverRam+0, msgRam+7
mov driverRam+1, msgRam+15
mov driverRam+2, msgRam+23
mov driverRam+3, msgRam+31
lcall getPat
;;;;;;;;;;;;;;;************************************************
M5450:
clr clock
setb DataIN ;Startbit wird reingecklockt
setb clock
clr clock
mov A, driverRam+0
mov bitCtr, #8
lcall OutputData
mov A, driverRam+1
mov bitCtr, #8
lcall OutputData
mov A, driverRam+2
mov bitCtr, #8
lcall OutputData
mov A, driverRam+3
mov bitCtr, #8
lcall OutputData
mov bitCtr, #3 ;Ist egal was hier steht (in DPTR)
lcall OutputData
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;,,,
mov A, row
orl ScanPort, A
rl A
mov row, A
cjne A, #00000001b, DisplayExit
mov row, #00000001b
DisplayExit:
RET
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
OutputData:
rlc A
mov dataIN, C
setb clock ;Takt Begin
clr clock ;Takt Ende
djnz bitCtr, OutputData
RET
;******************************************************************************
getPat:
mov A, driverRam+0
mov KommaChecker, A
anl A, #00001111b
add A, #_7Seg_Table-$-3
movc a, @a+pc
mov driverRam+0, A
mov A, KommaChecker
jnb ACC.5, LoadPat0
jnb blink, LoadPat0
mov driverRam+0, #0
ljmp GetPat1
LoadPat0:
jnb ACC.4, getPat1
mov A, driverRam+0
setb ACC.0
mov driverRam+0, A
GetPat1:
mov A, driverRam+1
mov KommaChecker, A
anl A, #00001111b
add A, #_7Seg_Table-$-3
movc a, @a+pc
mov driverRam+1, A
mov A, KommaChecker
jnb ACC.5, LoadPat1
jnb blink, LoadPat1
mov driverRam+1, #0
ljmp GetPat2
LoadPat1:
jnb ACC.4, getPat2
mov A, driverRam+1
setb ACC.0
mov driverRam+1, A
GetPat2:
mov A, driverRam+2
mov KommaChecker, A
anl A, #00001111b
add A, #_7Seg_Table-$-3
movc a, @a+pc
mov driverRam+2, A
mov A, KommaChecker
jnb ACC.5, LoadPat2
jnb blink, LoadPat2
mov driverRam+2, #0
ljmp GetPat3
LoadPat2:
jnb ACC.4, getPat3
mov A, driverRam+2
setb ACC.0
mov driverRam+2, A
GetPat3:
mov A, driverRam+3
mov KommaChecker, A
anl A, #00001111b
add A, #_7Seg_Table-$-3
movc a, @a+pc
mov driverRam+3, A
mov A, KommaChecker
jnb ACC.5, LoadPat3
jnb blink, LoadPat3
mov driverRam+3, #0
ljmp GetPatExit
LoadPat3:
jnb ACC.4, getPatExit
mov A, driverRam+3
setb ACC.0
mov driverRam+3, A
getPatExit:
cjne row, #01000000b, getPatExit1
mov A, msgRam+6
cjne A, #10, getPatExit1
mov driverRam+1, _7segMuster+1
mov driverRam+2, _7segMuster+0
getPatExit1:
RET
;7 Segment LookUp Table
_7Seg_Table:
db 11111100b ;0
db 01100000b ;1
db 11011010b ;2
db 11110010b ;3
db 01100110b ;4
db 10110110b ;5
db 10111110b ;6
db 11100000b ;7
db 11111110b ;8
db 11110110b ;9
db 00000000b ;blank
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
UpdateTimer:
djnz llTimer, ExitUpdateTimer
mov llTimer, #5
cpl llDirection
jb llDirection, changeLedPattern
mov ledMuster, #01111111b
RET
changeLedPattern:
mov ledMuster, #00111111b
ExitUpdateTimer:
RET
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
AnimDisp:
clr clock
setb DataIN ;Startbit wird reingecklockt
setb clock
clr clock
mov A, animChar
mov bitCtr, #8
lcall OutputData
mov A, animChar
mov bitCtr, #8
lcall OutputData
mov A, animChar
mov bitCtr, #8
lcall OutputData
mov A, animChar
mov bitCtr, #8
lcall OutputData
mov bitCtr, #3 ;Ist egal was hier steht (in DPTR)
lcall OutputData
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;,,,
mov ScanPort, #0FFh
mov A, #100
lcall F_wait_m
mov A, animChar
rr A
mov animChar, A
djnz copyCtr, AnimDisp
RET
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Lauflicht:
mov A, ledMuster
jb llDirection, RotateLeft
rr A
mov llPort, A
mov ledMuster, A
RET
RotateLeft:
rl A
mov llPort, A
mov ledMuster, A
RET
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
AnimSmS:
djnz temp1, ExitAnimSmS
mov A, _7segMuster+1
rl A
cjne A, #00000001b, saveAnimSmS1
mov A, #00000100b
saveAnimSmS1:
mov _7segMuster+1, A
mov A, _7segMuster+0
rr A
cjne A, #00000010b, saveAnimSmS0
mov A, #10000000b
saveAnimSmS0:
mov _7segMuster+0, A
mov temp1, #3
ExitAnimSmS:
RET
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
SaveToEeprom:
orl eecon, #eemen ;eeprom einschalten
orl eecon, #eemwe ;schreiben in eeprom ermöglichen
orl eecon, #eeld ;zuerst nur laden(page write ermöglichen)
mov R1, #msgRam+0
mov dptr, #0 ; zeiger auf eeprom adresse
mov byteCtr, #31
SaveToEeprom1:
mov A, @R1
movx @dptr, A
inc R1
inc dptr
djnz byteCtr, SaveToEeprom1
xrl eecon, #eeld
mov A, @R1
movx @dptr, A
mov A, #5 ;5 ms auf schreibende warten
lcall F_wait_m
xrl eecon, #eemwe ;schreiben in eeprom abschalten
xrl eecon, #eemen ;eeprom auschalten
RET
END