Wednesday, July 3, 2013

Here we are discussing some I/O program for 8051 micro controller

1.The 50% duty cycle means that the "ON" and "OFF" state have same length.therefore ,we toggle P1.0 with a time delay in between each state.
HERE:   SETB P1.0
              ACALL DELAY
              ACALL DELAY
              CLR P1.0
              ACALL DELAY
              ACALL DELAY
              SJMP HERE
DELAY:
              MOV  R5,#11
H3:        MOV  R4,#248
H2:        MOV  R3,#255
H1:        DJNZ R3,H1
              DJNZ R4,H2
              DJNZ R5,H3
              RET
              END  
 



2.Write a program to perform the followingA.Keep monitoring pin P0.1 Until becomes high.
B.when P0.1 becomes high,read in the data from port1.
C.send a low-to-high pulse on P0.2 to indicate that the data has been read.


               SETB P1.0
               MOV P1,#0FFH
HERE:    JNB P1,HERE
               MOV A,P1
               CLR P0.2
               SETB P0.2
               END


3.A switched connect to P1.7 and LED connected to P2.7.write program to read status of P1.7 and send it to P2.7

              SETB P1.7
AGAIN: MOV C,P1.7
              MOV P2.7,C
             SJMP AGAIN


4.A Switch is connected to pin P1.7.write program to check the status of SW and perform following :
a> IF SW=0 then send "N" to P2.
b> IF SW=1 then send "Y" to P1.


              SETB P1.7
AGAIN: JB P1.7,OVER
               MOV P2,"N"
OVER:   MOV P1,"Y"

               SJMP AGAIN 

Related Topics:

->Reset & Oscillator circuit of 8051
->8051 Pin Diagram
->Port configuration of 8051
->Function of 8051 Port
->Block diagram of 8051









   







0 comments:

Related Posts Plugin for WordPress, Blogger...
Subscribe to RSS Feed Follow me on Twitter!