Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Check my code for interfacing PC with a 8051

Status
Not open for further replies.

hot_ice

Member level 1
Joined
Feb 7, 2006
Messages
38
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
1,599
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!!!
 

Re: chk this code...

If you posted code so it could be read, I bet more people would help. Try using the code tag.

Personally, I don't review people's code, especially student code. That's what debugging is about.
 

Re: chk this code...

hot_ice said:
let me know if there r any errors...

There are no errors in your code.

hot_ice said:
probably have 3 (or more) toggle buttons

If you're going to use more, watch out to R7 bank0 and subsequent R0-R7 from bank 1 and the default value of SP after reset.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top