Hi, I have been working in a project with AT89C51. Specifically it is a car that follows a black line and it has to be communicated with a raspberry pi 2 that has a camera to see some signals like turn left, turn right or stop. It is neccesary to use interruptions and serial communication ( it is the only way to communicate both things), the problem is the microcontroller doesn´t recognize serial inputs. I have simulated the code in proteus and it is working pretty well but in real life the serial communication is not working. I have tried serial communication with an arduino but has the same problem.I don´t know if Im missing something. My code is the next one:
ORG 000H // origin LJMP MAIN ORG 23H LJMP SERIAL MAIN: MOV P1,#204 // sets port 1 as input port MOV P2,#0000000B // sets port 0 as output port MOV P0,#0000000B MOV A,#0000 MOV SCON,#50H MOV TMOD,#20H // TIMER1 mode autoreload MOV TH1,#0FDH //9600 baudrate MOV IE,#10010000B SETB TR1 (HERE IT IS THE MAIN CODE OF LINE FOLLOWER AND DEPENDIG OF THE VALUE OF REGISTER A,THE CAR STOPS OR TURNS LEFT/RIGHT) HERE IT IS THE SERIAL INTERRUPT PART //SERIAL PORT SUBRUTINA ORG 120H SERIAL: SETB P0.1 MOV A,SBUF CLR RI RETI END // end statement
Thanks for your help
The basic first step for serial comms in any context - not specific to any particular microcontroller or system - is to start with a terminal.
So - can your code successfully communicate with a terminal (or a terminal emulator) on a PC?
I have never tried with a terminal, I have tried with an arduino and another microcontroller. Im now getting a usb- serial cable in order to see if I can communicate with terminal.
I'm now getting a usb- serial cable in order to see if I can communicate with terminal.
make sure that either the cable is TTL (VERY rare) ot that you have a MAX232(equivalent) between your controller and the cable (see the schematic for ant devboard as to how)
HERE IT IS THE SERIAL INTERRUPT PART //SERIAL PORT SUBRUTINA ORG 120H SERIAL: SETB P0.1 MOV A,SBUF CLR RI RETI
1) the above should be preceded by if (RI)
and you need to process TI
I guess you have to, but why use assembler?
So , you say that I need to add a " if RI =0, do something?" Before i put the code the code of the serial part? Sorry if I dont understand you very well.
Hi. Im Karek. Im working on exactly same stuff. Im stuck. Can you say what the SETB does. Can you explain what is the best way to use it.
Waiting for your naswer.
"Waiting for your naswer"
Don't just sit there waiting. You have the entire internet at your disposal - get searching!
Again, the 8051 is decades old: there is no shortage of books and tutorials - especially on basic topics like this.
Have you reviewed your class notes?
Have you studied the instruction set documentation?
Can you say what the SETB does
www.danlhenry.com/.../80C51_FAM_ARCH_1.pdf www.danlhenry.com/.../80C51_FAM_HARDWARE_1.pdf www.danlhenry.com/.../80C51_FAM_PROG_GUIDE_1.pdf
I think it sets bounds. why is it useful?
Do you?
And what makes you think that?
if (RI) should be there as well as an if (TI) since you have no idea of the interrupt was from a read or a write
OK if you have no idea about C then JB RI and JB TI
I was not using that condition for one reason, I don´t have to transmit data from the 8051 to the other device so that I dont connect tx of 8051 to the Rx of the rapsbery so I ignore the TX flag because Im not transmitting something, I don´t know if I have to ask the condition however im not transmitting. Can be that the reason that I can´t communicate serially?
Have you enabled the receiver?
can anyone gonna help? wifi is broken now
Yes , I am, I did some tests yesterday following a tutorial, but still nothing. The code was the same, I tried to cooy exactly the external configuration ( capacitors, crystal, others) but the problem is that he was using some kind of board and not a protoboard so thag I can't see exactly what was he using
hi erik
will you tell me what the SETB does?
Have you looked it up in the Instruction Set documentation yet?
What part of that was unclear?
hi andrew.
the link didnt work and i can't find it on the internet.
is its calculus. is it en.wikipedia.org/.../Bounded_set
these do www.danlhenry.com/.../80C51_FAM_ARCH_1.pdf www.danlhenry.com/.../80C51_FAM_HARDWARE_1.pdf www.danlhenry.com/.../80C51_FAM_PROG_GUIDE_1.pdf
Then you really aren't trying!
If I just stick "SETB" into google, the very first hit is a reference to the 8051 Instruction Set on this very website!
"
Why on earth would it be?? We're talking 8051 assembler!!
hi erik.
i get virus warnings on your pages. and andy link is 404.
i will look more and get back to you.
Go on - seriously: you're doing a school project in 8051 assembler, and you don't have access to an instruction set document?
Not even an old-fashioned, hard-copy book from a real-life, bricks-and-mortar library?
Inconceivable!
found it
web.itu.edu.tr/.../setb_setnae.html
That's not 8051 - is it?
Again, having an Instruction Set reference to had is an absolutely fundamental requirement for programming in assembler. And, of course, it has to be the Instruction Set for the processor you are using!
How can you possibly have even considered starting this project without that?
You seem to have missed some really important classes - you need to talk to your teachers about catching up.
View all questions in Keil forum