View previous topic :: View next topic |
Author |
Message |
lucas
Joined: 17 May 2011 Posts: 5
|
serial communication RS232? |
Posted: Tue May 17, 2011 12:27 pm |
|
|
Can someone help me for serial communication between a PIC16F628 and a ultrasonic sensor (SFR02)? The project is to build an ultrasonic meter, but I don't know exactly what I have to do for the serial communication because I never used. The serial interface is a standard TTL level UART format at 9600 baud, 1 start, 2 stop and no parity bits. I often used assembly and I'm not expert to use CCS.
(sorry for any errors. I'm learning english)
ps: If someone want to contact me in private, this is my emailaddr: lucadinamo@hotmail.it |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9225 Location: Greensville,Ontario
|
|
|
lucas
Joined: 17 May 2011 Posts: 5
|
|
Posted: Thu May 19, 2011 8:39 am |
|
|
ok..i saw it but i'm not sure that the program will be ok..i have to programming a PIC with CCS but i'm not a good programmer yet beacuse i'm studing it since march..so i'll try it..can you give me other suggestions?
thank you for the help |
|
|
vladtess
Joined: 14 May 2011 Posts: 26
|
|
Posted: Thu May 19, 2011 9:09 am |
|
|
Lucas, it's pretty simple.
First off, make sure #use delay (clock = x) command is in the code.
Then, make sure to include #use rs232 directive. (SEE THE MANUAL< IT EXPLAINS VERY WELL WHAT OPTIONS TO ADD TO THE DIRECTIVE).
Such as:
Code: | #use delay (clock = 4000000)
#use rs232 xmit=A0, rcv=A1, invert |
This makes PortA pin 0 transmit pin, and PortA pin 1 receive pin, and the outputs will be inverted (as needed I believe; you can always remove invert option and see if it works).
Then simply use the "putc(var)" function to send commands to the module, where var is a variable that contains a command to send. Refer to the site posted earlier by temtronic to understand what commands to send. Make sure NOT to use MAX232 chip.
Very simple once you get it.
PS> If you have two PICs, I suggest establishing communication between them first to understands how it all works.
I hope this somewhat helps!
VT |
|
|
lucas
Joined: 17 May 2011 Posts: 5
|
|
Posted: Fri May 20, 2011 8:15 am |
|
|
oh..thank you so much..i finished it last day and now i'm working on the program ;) it's my exam's project and i hope that will be ok ;) thank you a lot..if there is something wrong could i post here the program? |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Fri May 20, 2011 7:50 pm |
|
|
lucas wrote: | oh..thank you so much..i finished it last day and now i'm working on the program ;) it's my exam's project and i hope that will be ok ;) thank you a lot..if there is something wrong could i post here the program? |
If you have a complete sample that isn't super long that displays they problem you are having, feel free to post it here for us to look at it.
Again, it needs to be complete. It needs to display the problem and most important, it can't be pages and pages of code. Make your example show just the problem you are having.
Make sure to include what PIC device you are using and the version of CCS's compiler. _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
lucas
Joined: 17 May 2011 Posts: 5
|
|
Posted: Mon May 23, 2011 8:02 am |
|
|
bkamen wrote: | lucas wrote: | oh..thank you so much..i finished it last day and now i'm working on the program ;) it's my exam's project and i hope that will be ok ;) thank you a lot..if there is something wrong could i post here the program? |
If you have a complete sample that isn't super long that displays they problem you are having, feel free to post it here for us to look at it.
Again, it needs to be complete. It needs to display the problem and most important, it can't be pages and pages of code. Make your example show just the problem you are having.
Make sure to include what PIC device you are using and the version of CCS's compiler. |
mm ok i'll tell you something if it doesn't work.. PIC: 16F628
CCS's version...mmm i'm not sure....so i'll check it.
thank'u for all..see you soon!
ps: if some1 wants schematic or pcb, i can share it.[/img] |
|
|
|