Professional Documents
Culture Documents
TRAFFIC
TRAFFIC
PAGE 1
59
60 ; step2
8245 90A000 61 mov dptr,#0a000h ;make south and north yellow
8248 7422 62 mov a,#22h
824A F0 63 movx @dptr,a
64
824B EF 65 mov a,r7 time for yellow in south and north
824C FD 66 mov r5,a ;r5 is temporary reg.
824D 5172 67 k2: acall onesec
824F DDFC 68 djnz r5, k2
69
70 ; step3
8251 90A001 71 mov dptr,#0a001h ;make east and west green
8254 7444 72 mov a,#44h
8256 F0 73 movx @dptr,a
74
8257 90A000 75 mov dptr,#0a000h ;make south and north red
825A 7499 76 mov a,#99h ;and switch on pedestrian
825C F0 77 movx @dptr,a
78
825D EE 79 mov a,r6 ;time for green in
825E FD 80 mov r5,a ;east and west
825F 5172 81 k3: acall onesec
8261 DDFC 82 djnz r5, k3
83
84 ; step4
8263 90A001 85 mov dptr,#0a001h ;make east and west yellow
8266 7422 86 mov a,#22h
8268 F0 87 movx @dptr,a
88
8269 EF 89 mov a,r7 ;time for yellow in
826A FD 90 mov r5,a ;east and west
826B 5172 91 k4: acall onesec
826D DDFC 92 djnz r5, k4
93
826F 028206 94 ljmp input
95
8272 758910 96 onesec: mov tmod,#10h ;timer 1, mode 1
8275 7B0E 97 mov r3,#14 ;outer loop for time delay
8277 758B08 98 repeat: mov tl1,#08 ;tl reg. value
827A 758D01 99 mov th1,#01 ;th reg. value
827D D28E 100 setb tr1 ;switch on timer1
827F 308FFD 101 back: jnb tf1,back ;check for overflow flag
8282 C28E 102 clr tr1 ;if yes, switch off timer
8284 C28F 103 clr tf1 ;clear overflow flag
8286 DBEF 104 djnz r3,repeat ;repeat for 14 times
8288 22 105 ret
106
107 end