Microprocessor controlled traffic light system is a microprocessor based electronics system that controls traffic lights for street pedestrian crossing. It consists of two car detecting sensors, a push button, a loudspeaker, green and red light on both sides of the road, for the pedestrians. It has a set of red, yellow and green lights, for the two lanes, whose main purpose is either to deny or set priority to the incoming cars.To achieve the different delays, I used a 16-bit time, that is to say, Timer1 in 16-bit Mode.
Below is how a 1 second delay:
;*********************************************
;* ONE second delay from which different
;Delays are derived *
;* HUNDRED = 100, COUNT = -10,000:
100X10000us = 1 sec *
; -10,000D = FFFFD8F0H
; LOWCOUNT = 0F0H, HIGHCOUNT = 0D8H *
;*******************************************
DELAY01SEC:
MOV R7, #00H; reset R7
MOV R7, #HUNDRED
; move contents of HUNDRED to R7
LOOP01SEC:
MOV TMOD, #010H
; Put timer 1 into mode 1
MOV TH1, #HIGHCOUNT
; move high byte of COUNT to timer1′s high
MOV TL1, #LOWCOUNT;
move low byte of COUNT to timer1′s low
SETB EA; Enable interrupt
SETB ET1; Set timer 0 bit
SETB TR1; start the timer1
WAIT01SEC:
JNB UTF1,WAIT01SEC
; wait for timer1 to overflow
CLR UTF1; reset overflow flag
CLR TR1; stop timer1
DJNZ R7, LOOP01SEC
RET
Post time: Jun-18-2017