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 support@ccsinfo.com

Serial Comm. problem between 2 PICs

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



Joined: 30 May 2005
Posts: 10
Location: India

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

Serial Comm. problem between 2 PICs
PostPosted: Tue Jun 28, 2005 4:23 am     Reply with quote

Hello,

Im trying to communicate between 2 pics ,with no success
The ADC value[10bit] from pic1 is transmitted to pic2.
i get a few values from pic 2 and then it stops receiving..

im working at 9600 baud ,20Mhx crystals and two PIC16f873A 's


My setup is in this format

PIC1(Hardware UART)
|||||||
(Software UART)PIC2(Hardware UART)
|||||||
PC COM Port


b is an array of char >>b[20]

Transmit routine:
Code:

  while(TRUE)
   {
   test=read_adc();
   delay_ms(10);
   sprintf(b,"%lu",test);
   puts(b);
   }



Receive routine:
Code:

while(TRUE)
   {
   fgets(b,picpic);
   x=atol(b);
   fprintf(picpc,"%4lu\n",x);
   }



Thank you
_________________
**ice**
Machinegrid.com :: Robots at Work!!
arunb



Joined: 08 Sep 2003
Posts: 492
Location: India

View user's profile Send private message Send e-mail

RE:
PostPosted: Tue Jun 28, 2005 5:25 am     Reply with quote

Hi,

MCU: 16F877
Compiler: PCM 3.169

Have you specified the stream parameter in #use RS232 statement.

Eg.:

Code:

#use rs232(baud=9600,xmit=pin_c6, rcv=pin_c7,parity=n,brgh1ok,stream=PC)
#use rs232(baud=9600,xmit=pin_b1, rcv=pin_b2,parity=n,brgh1ok,stream=LASERCONTROLLER)



Here LASERCONTROLLER is the software USART, and PC the hatrdware one.

thanks
arunb
Guest








PostPosted: Tue Jun 28, 2005 6:06 am     Reply with quote

Thanks for your reply ..yes i did specify the streams

Code:

#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7,stream=PicPc ) 
#use rs232(baud=9600, xmit=PIN_C4, rcv=PIN_C5,stream=PicPic )
[/code]
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Tue Jun 28, 2005 6:08 am     Reply with quote

fgets() reads until it receives a RETURN. You are not sending any that I can see. Also make sure that you have specified ERRORS in you #use RS232 statement. Personally I wouldn't use the fgets() function. Sure is an easy way to overrun a buffer.
Ttelmah
Guest







PostPosted: Tue Jun 28, 2005 6:55 am     Reply with quote

Yes.
It is far 'better', to include 'input.c', and use the 'get_string' function. This allows you to specify a maximum length for the string, which will 'block' if more characters arrive than expected, or re-code this to default to return when the string is full. :-)

Best Wishes
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