Module 5 : Experiments on Microcontrollers

Lecture 40 : Frequency Divider Using AT89C51


To divide the given signal frequency applied at P3.5 by a digital value as obtained from Port-0 and output the signal through one of the port pins (say P1.0), i.e. OUT PUT_FREQ = (INP_FREQ) / (PORT0*2)

  1. Atmel 89C51 micro controller
  2. 8051 simulator- win8051
  3. Universal SP3 Programmer
  4. Software to load the code into Universal SP3 Programmer
  5. Computer System with Windows operating system and RS 232 Cable
  6. +5V D.C Power Supply
  7. SPST switches-1
  8. Resistors-8.2k-1
  9. Capacitors-30pF-2, 10uF-1
  10. 10MHz crystal
  11. Signal Generator and CRO
  1. Write the assembly code in win8051 simulator , compile it and check for errors
  2. Once the code is error free, run it and check the output.
  3. After checking the code in the simulator, the code (in .HEX format) was loaded into Atmel 89c51 microcontroller using Universal SP3 Programmer.
  4. Make connections as shown in the circuit diagram.
  5. Load some value into PORT0 by externally giving some digital input.
  6. Square wave of 0 to +5V is given to the Pin P3.5 (timer 1 external clock input.)
  7. Observe the signal at pin P1.0 in the CRO and ensure that it satisfies the formula (INP_FREQ)/(PORT0*2)
  8. Change the frequency of input square and observe the frequency of out put square wave and each time ensure that it satisfies the above formula.  (OUT PUT_FREQ = (INP_FREQ) / (PORT0*2) )
Timer-1 is used for dividing the input signal by a given number obtained from Port-0.
Assembly Code

Since input square wave is used as Timer 1 external clock input see the external clock requirements in the datasheet of Atm8051.


Input signal frequency was divided by the following formula and out put the signal through pin P1.0.


Circuit Diagram
Fig  40.1 Circuit diagram for frequency divider experiment