CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

232 com between 2 pics test

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
MR A
Guest







232 com between 2 pics test
PostPosted: Wed Jan 20, 2010 6:37 am     Reply with quote

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
PostPosted: Wed Jan 20, 2010 6:56 am     Reply with quote

Solved it

just had to
Code:

puts("hello");

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

View user's profile Send private message Visit poster's website

PostPosted: Wed Jan 20, 2010 8:59 am     Reply with quote

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

View user's profile Send private message AIM Address

PostPosted: Wed Jan 20, 2010 7:40 pm     Reply with quote

of course printf("hello\r\n"); is a fine way 2
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group