Professional Documents
Culture Documents
Expt. No. 4
1. Write a program to create a square wave of 50% duty cycle on bit 0 of port1.
ORG 0000h
AJMP START
START:
SETB P1.0
LCALL DELAY
CLR P1.0
LCALL DELAY
SJMP START
SETB P1.0
LCALL DELAY
LCALL DELAY
CLR P1.0
LCALL DELAY
SJMP START
3. Assuming that clock pulses fed into pin T1, write a program for counter 1 in mode2 to
count the pulses and display the state of the TL1 count on P2.
ORG 0000h
AJMP START
START:
AGAIN:
BACK:
1
Department of Biomedical Engineering, Manipal Institute of Technology, Manipal 576 104
MOV P2, A
JNB TF1, BACK
CLR TR1
CLR TF1
SJMP AGAIN
END
4. Implement a 2-digit decimal up counter and display the counts on Port 2 pins.
ORG 0000H
AJMP START
START:
AGAIN:
MOV A, #00
ADD A, #01
DA A
MOV P2, A
ACALL DELAY
SJMP AGAIN
DELAY:
UP1:
UP2:
UP3:
5. Implement a 16- bit hexadecimal up counter and update the counts in register R0 and R1
register.
ORG 0000H
AJMP START
START:
UP:
2
Department of Biomedical Engineering, Manipal Institute of Technology, Manipal 576 104
DELAY:
UP1:
UP2:
UP3:
6. Read an 8-bit number through port 1 and perform logical AND operation with AAH and
send the result to port2.
EXERCISES
1. Implement an 8 bit ring counter.
2. Assuming R1:R0 registers as an 16 bit register rotate the content of this register left
such that bit-7 of R0 becomes bit 0 of R1 and bit-7 of R1 becomes bit-0 of R0.
3. Implement an 8-bit octal up counter.
4. Program Timer 1 to be an event counter in mode 2 and display the decimal count on
P0, P1 and P2 continuously. Set the initial count to 99.
PRACTICE PROGRAMS
1.
2.
3.
4.
3
Department of Biomedical Engineering, Manipal Institute of Technology, Manipal 576 104