
PROGRAMMING THE PERIPHERALS OF 8051 545
e program in Example 14.9 generates a square wave on pin P1.3. It uses Timer 0 in
mode 2. e count loaded in TH0 is 0. Note that, after TF0 is cleared, there is no ‘re-
load’ operation for TH0. e count is automatically re-loaded by the 8051, after the
timer fl ag is cleared.
Now let’s calculate the frequency of the square wave, generated (assuming an 8051
with a clock frequency of 1MHz).
e count increments from 0 to 255, and then to 0.
Delay = 256
× 1 μsec = 256 μsecs
e square wave has a period of 256 × 2 = 512 μsecs, i.e., f = 0.001953 MHz
at is, 1.9 KHz. A square wave of 1.9 KHz is generated. ...