Taffic Light Control System Using 8051
Taffic Light Control System Using 8051
org 0000h clr p0.1; yellow led on indicating red will turn off in sometime
delayfor10: mov tmod, #01h; initialize the timer delayfor5: mov tmod, #01h; initialize the timer
check: jnb tf0, check; 66ms (66ms * 152 = 10 sec) check1: jnb tf0, check1
djnz r0, back djnz r0, back1; we are able to generate the required delay
ret; ret;
end;
DELAY GENERATION
For Timer 0 Mode 1 (for maximum size of 16 bits) we set TMOD = 01H 10 s / 66 ms = 152
5 s / 66 ms = 76
Crystal Frequency = 11.0592 MHz
Timer Frequency = 11.0592 MHz / 12 = 921.6 KHz
T = 1/F
T = 1/921.6 KHz
T = 1.085 us
Maximum possible values in timer registers when Mode 1 (16 bits) = 2^16 = 65535
65535 * 1.085 us = 66 ms
The maximum delay we can produce using Timer 0 Mode 1 is 66 ms.
ADVANCED MODIFICATIONS