View previous topic :: View next topic |
Author |
Message |
casandralam
Joined: 26 Jan 2008 Posts: 15
|
rs232 data transmit from PC |
Posted: Sat Feb 16, 2008 3:20 am |
|
|
hi,i'm using PIC16f877a and i would like it to receive integer data where transmitted from PC.but i cant find any command that will get integer.i just can find the command of getchar which is get characters...may somebody help me in this pro? my aim is to receive transmitted integer from PC,the integer is from 0-100...
thx very much for ur help.. |
|
|
arunb
Joined: 08 Sep 2003 Posts: 492 Location: India
|
RE: |
Posted: Sat Feb 16, 2008 5:20 am |
|
|
Hi,
You can use the getc() function to get the data from the PC.
If you need to send integer data then send the ASCII code of the integer.
for example in VB you would do this as chr$(n) where n is the integer, of course you cannot exceed 255.
For large values break up the data into 2 byte format and send each byte individually, the PIC can then receive the bytes and re-construct the data using make16.
Alternatively you can send the integer as a string, "1", "2" etc.
But the PIC will receive the data as the equivalent ASCII code, for example "1" will be 49, 2 will be 50, to get the integer value subtract from 48..
hope this helps....
thanks
arunb |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Sat Feb 16, 2008 10:08 am |
|
|
In a nutshell, a PC RS232 port can only send data byte at a time. Getc() reads bytes. How to interpret those byte once you get then into the PIC is up to you. Beware of Big Endian vs. Little Endian problems between computers. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
casandralam
Joined: 26 Jan 2008 Posts: 15
|
thanks you very much |
Posted: Sun Feb 17, 2008 5:59 pm |
|
|
thanks you very much..
both of your reply is very useful for me
i would like to try it on my PIC
thanks.. |
|
|
|