Module_4
Module_4
1
The four 8-bit I/O ports P0, P1, P2 and P3 each uses 8 pins
Solution:
The 50% duty cycle means that the “on”and “off”state (or the high and low
portion of the pulse) have the same length. Therefore, we toggle P1.0 with a
time delay in between each state.
If the timer contains for example number 1000 (decimal), then the
TH0 register (high byte) will contain the number 3, while the TL0
register (low byte) will contain decimal number 232.
‰
Both Timer 0 and Timer 1 are 16 bits wide
3. Convert the result of Step2 to hex, where yyxx is the initial hex
How does it operate? Each coming pulse causes the lower register bits
to change their states. After receiving 32 pulses, this register is
loaded and automatically cleared, while the higher byte (TH0) is
incremented by 1.
6. When TH0-TL0 rolls over from FFFFH to 0000, the 8051 set TF0=1.
TH0-TL0= FFFEH, FFFFH, 0000H (Now TF0=1)
7. Keep monitoring the timer flag (TF) to see if it is raised.
AGAIN: JNB TF0, AGAIN
8. Clear TR0 to stop the process.
CLR TR0
9. Clear the TF flag for the next round.
CLR TF0
Solution:
In order to register each 55th pulse, the best solution is to write the
number 200 to the TH0 register and configure the timer to operate in
mode 2.
The TL0 timer turns into timer 0, while the TH0 timer turns
into timer 1.
MODULE - 4 ECE3003–Microcontroller and Applications 53
Timer 0 Mode-3 (Split Timer)
The only real use I can see of using split timer mode is if
you need to have two separate timers and, additionally, a
baud rate generator.
In such case you can use the real Timer 1 as a baud rate
generator and use TH0/TL0 as two separate timers.
MODULE - 4 ECE3003–Microcontroller and Applications 55
Timer 0 Mode-3 (Split Timer)
The counter counts up as pulses are fed from pins 14 and 15, these
pins are called T0 (timer 0 input) and T1 (timer 1 input)