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.

Stream of data from PC to Microcontroller

Status
Not open for further replies.

lats

Full Member level 4
Joined
Oct 27, 2005
Messages
216
Helped
13
Reputation
26
Reaction score
6
Trophy points
1,298
Activity points
2,945
Hello everybody,
Just for a hobby, i'm trying to send a small message from PC to Microcontroller, which i want to display on LCD. For example :- if someone types a message in a textbox "sum = 34" it should be displayed on LCD. I want to control a relay(attached to Microcontroller) through PC, I want to do this only through RS232. I'm able to read stream of data from Microcontroller but i'm unable to send a stream from PC to Microcontroller, I'm only able to send one character. I tried to search net and EDABoard for the same the best similar thing i was able to find was



I'm using 89c51 microcontroller with RS232, and Visual Basic 6 for PC software.

Thanks in advance to everyone.
 

One option of addressing this issue is to implement serial port interrupt with Tx and Rx buffers .. By doing this you will not loose bytes and the incoming string is processed by microcontroller while waiting for another character to arrive to the SBUF ..
Here is the ready-to-go assembly code ..
https://www.pjrc.com/tech/8051/uartintr.html

Regards,
IanP
 

sounds like your code to address the serial port file is the problem

when addressing a port you must send
1} a single char
2} an array of chars

if you need to send more than one char

then you must

1} group your array to a buffer
2} open the port
3} send the array


provided the mcu firmware is set up to

wait for port
read one byte
wait for next byte etc....

you must add a loop with a timeout branch
the time out is a counter driven event

look for examples at http://www.8052.com/

sounds like you need to use a port monitor app like

portmon its a good software shows you whats going on
a tip is to get a pci video card plug it in connect a second monitor and run this on that

this is what i do to debug ports
even use three monitors and a two head agp card


http://www.softpedia.com/get/Tweak/Network-Tweak/Portmon.shtml

take time to do it yourself

youll soon see your error

and dont hammer your head
sometimes a rest give's clarity

best solve this problem with heinsight and time shift
 

I see that you have forgot to clear the RI flag of the microcontroller. if you use interupt based serial port you have to clear the RI flag every time you receive a byte.

hope this solution solve your problem
 

Hi

I think you need to use flow control
JUST connect CTS and RTS.
This two signals will force your PC to stop sending char's till the microcontroller buffer is ready to Recieve more char.

Salam
Hossam Alzomor
www.i-g.org
 

Hi,

What you need to do is wait for for the Enter to be pressed 0X0D. So, you will keep on getting one char at a time from the PC to the MCU. You will gater all that information to a buffer with a pre defined size. Then you will output what ever you have in the buffer to the LCD only when the Enther in the keyboard was pressed.
With this method, you will need to put some restrictions in the MCU ( you dont have to, but its batter this way ). For example, what happnes if you start typing but never press Enter? Or what happens if you send this signes: !@#$%^&*( Do you stil want to print them on the LCD?

Good luck.
 

see the one for AVR
**broken link removed**

u can use the same logic

Bibin John
www.bibinjohn.tk
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top