Write an ALP to test timer in different modes and use it to produce square wave for 8051 micro controller.
Aim:
Write an ALP to test timer in different modes and use it to produce square wave for 8051 micro controller.
Apparatures: /Software:
1. 8051 microcontrollerkit /keil evaluation version/sdcc—1 2. C.R.O 3. Connecting wires.
Algorithm:
; calculate the frequency of the square wave generated on pin using timer0 P1. 5.
Solution:
Step1: load control word in to TMOD Register to set Timer 0 with mode 1 (16-bit mode) Step2: Load TL0=F2H, the low byte and TH0=FFH, the high byte Step3: Complement P1.0. Step4: Call Delay using timer 0 Step5: Repeat from step1 Delay sub routine Step1: start the timer 0 by setting TR1 Flag. Step2: wait until TF1 Is set/timer rolls over. Step3: stop timer 0 Step4: clear timer 0 flag Step5: return
Program 1:
HERE: MOV TL0, #0F2H ; 2 machine cycles MOV TH0, #0FFH ; 2 machine cycles CPL P1.0 ; 1 machine cycles ACALL DELAY ; 2 machine cycles SJMP HERE ; 2 machine cycles DELAY: SETB TR0 ; 1 machine cycle AGAIN: JNB TF0, AGAIN ; 14 machine cycles CLR TR0 ; 1 machine cycle CLR TF0 ; 1 machine cycle RET ; 2 machine cycles ;Total 28 ; Frequency calculations ;T = 2 × 28 × 1.085 us = 60.76 us and F = 16458.2 Hz
Algorithm:
; calculate the frequency of the square wave generated on pin using timer1 mode2 P1.5.
Step1: load control word in to TMOD Register to set Timer 1 with 8-bit auto reload mode Step2: Load TH1 with count. Step3: start the timer 1 by setting TR1 Flag. Step4: wait until TF1 Is set/timer rolls over. Step5: Complement P1.0. Step6: Clear timer Flag. Step7: Repeat from step4
Program 2:
Assembly Language Program before execution:
MOV TMOD, #20H ;T1/8-bit/auto reload MOV TH1, #22 ;TH1 = 5 SETB TR1 ;start the timer 1 BACK: JNB TF1, BACK ;till timer rolls over CPL P1.0 ;P1.0 to hi, lo CLR TF1 ;clear Timer 1 flag SJMP BACK
Result:
Hex file generated:
Program 1
:10000000758901758AF2758CFFB290110F80F4D258 :090010008C308DFDC28CC28D22E2 :00000001FF
Program 2
:10000000758920758D16D28E308FFDB290C28F808B :01001000F7F8 :00000001FF
Result:
A square wave is generated as shown below.
Viva-voce questions:
1) How many no. of pins available for 8051? 2) How many timesr/ counters are available in 8051? 3) Explain different modes of timer/counter in 8051? 4) Define baud rate? 5) Which is the highest priority interrupt for 8051?
-
UpdatedOct 23, 2014
-
Views8,716
Write and execute an alp to 8086 Microprocessor to add, subtract and multiply two 16 bit unsigned numbers. Store the result in extra segment
Write and execute an alp to 8086 Microprocessor to a sort the give array of 32 bit number in ascending and descending order.
Program to generate following waveforms
- Ramp waveform
- Square waveform
- Step waveform
- Triangle waveform
Write and execute an alp to 8086 Microprocessor to find the length of a given string which terminates with a special character
Write and execute an alp to 8086 Microprocessor to divide a 32 bit unsigned numbers by a 16 bit unsigned number. Store the result in stack segment
Interface a stepper motor to 8086 and operate it in clock wise and anticlockwise by choosing variable stepsize.