Hi every1!!!
well frndz, i'm given a task of interfacing PC with a 8051 µC (of course using serial port). on the PC i'll be developin a GUI which will probably have 3 (or more) toggle buttons as i press a button the FAN, BULB or TUBE_LIGHT attached with the µC turns off or on. i'm not good @ programmin. anywayz i've wriiten a code... plz chk it n let me know if there r any errors...
ORG 0
LJMP MAIN
ORG 23H
LJMP SPISR
ORG 30H
MAIN:
CLR P2.0
CLR P2.1
CLR P2.2
MOV R1,#00000000B ;turn fan off
MOV R2,#00001111B ;turn bulb off
MOV R3,#01010101B ;turn tube-light off
MOV R4,#11111111B ;turn fan on
MOV R5,#11110000B ;turn bulb on
MOV R6,#10101010B ;turn tube-light on
MOV TMOD,#00100000B
MOV TH1,#-3 ;baud rate==9600
SETB TR1
MOV SCON,#01010000B
MOV IE,#10010000B
SJMP $
SPISR:
MOV A,SBUF
CJNE A,R1,L1
CLR P2.0
L1:
CJNE A,R2,L2
CLR P2.1
L2:
CJNE A,R3,L3
CLR P2.2
L3:
CJNE A,R4,L4
SETB P2.0
L4:
CJNE A,R5,L5
SETB P2.1
L5:
CJNE A,R6,L6
SETB P2.2
L6:
CLR RI
RETI
END
i've done with the schematci part... just chk the code... the scheme is when a user press a button to turn fan on... a code from pc is transferred to the µC... plz chk it... THX!!!