View previous topic :: View next topic |
Author |
Message |
MR A Guest
|
232 com between 2 pics test |
Posted: Wed Jan 20, 2010 6:37 am |
|
|
Hey all.
I am kinda rusty with my ccs programming. I am trying to communicate via 232 tx rx between 2 pics. The receive transmit part is fine but the receive code is not outputting anything. Both compiles with no errors. I'm not sure how to do the gets() here is my code below:
Transmit
Code: |
#include"16f877.h"
#use delay(clock=4000000)
#use rs232(baud=9600,xmit=PIN_C6,rcv=Pin_C7)
void main()
{ while(1)
{
printf("hello");
delay_ms(1000);
}
}
|
Receive code
Code: |
#include"16f877.h"
#use delay(clock=4000000)
#use rs232(baud=9600,xmit=PIN_C6,rcv=Pin_C7)
char mystring[30];
void main()
{
while(1)
{
gets(mystring);
delay_ms(700);
printf("string is %s ",mystring);
}
}
|
C6 of pic 1 is connected to C7 of pic 2 and C7 of pic 1 is connected to C6 of pic 2 |
|
|
MR A Guest
|
solved it |
Posted: Wed Jan 20, 2010 6:56 am |
|
|
Solved it
just had to
Can someone delete this disscusion? I'm a guest so not able to I think. |
|
|
mbradley
Joined: 11 Jul 2009 Posts: 118 Location: California, USA
|
|
Posted: Wed Jan 20, 2010 8:59 am |
|
|
Well, lets just explain for others reading, what had happened.
printf("hello"); // just sends out the word "hello"
puts("hello"); // sends out "hello" + end of line chr(s)
gets(mystring); // waits until end of line chr is received.
in the orgininal example, there was never an end of line, so it never returned. _________________ Michael Bradley
www.mculabs.com
Open Drivers and Projects |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Wed Jan 20, 2010 7:40 pm |
|
|
of course printf("hello\r\n"); is a fine way 2 |
|
|
|