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

PIC to PIC serial communication

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



Joined: 22 Sep 2008
Posts: 6

View user's profile Send private message Yahoo Messenger MSN Messenger

PIC to PIC serial communication
PostPosted: Sat Dec 06, 2008 1:24 am     Reply with quote

Hi this is hussain,
I am doing a project in which I need to share data between two
PIC16F877's serially.
The first PIC is sending the data via virtual serial while the 2nd one receives the data on its hardware serial.
But the 2nd one does not receive the data correctly.
I don't have any idea about whether the 1st one is not sending the data correctly or the 2nd one doesn't receive correctly ?

Anyone can give me any idea of what is going wrong ?

Thanks in advance.
_________________
!!!!...HUSSAIN AFTAB...!!!!
Rohit de Sa



Joined: 09 Nov 2007
Posts: 282
Location: India

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

PostPosted: Sat Dec 06, 2008 5:53 am     Reply with quote

Quote:
The first PIC is sending the data via virtual serial
Do you mean software serial?

A way to troubleshoot this problem would be to individually test the two PICs - try to localize the problem. Use a PC as a tester. Connect the transmitting PIC to a PC and check if you receive valid data on a terminal program (Hyperterminal or SIOW).

Next, connect the receiver PIC to the PC and check if you can transmit data from the PC to it successfully.

Software serial has several configurable options. It is up to you to make sure the options are valid and appropriate.

Make sure the baud rates on both devices are the same. Make sure the data lines are connected correctly (RX1 to TX2 and TX1 to RX2). Make sure a ground wire is connected between the two PICs.

Rohit
hussain_kiet



Joined: 22 Sep 2008
Posts: 6

View user's profile Send private message Yahoo Messenger MSN Messenger

PostPosted: Sat Dec 06, 2008 10:58 am     Reply with quote

Yes I definitely mean software serial!!!

I've checked the baud rates, ground wire is common of both PIC's.
I've checked receiving of 2nd PIC, but when I transmit through the 1st PIC (through software serial) and check the data at the hyperterminal it shows wrong data, but the trend was always similar, means if transmit "A"
then it will receive something else but it will always remains same!!

Hope you understand what I meant to say. Confused
_________________
!!!!...HUSSAIN AFTAB...!!!!
Ttelmah
Guest







PostPosted: Sat Dec 06, 2008 1:50 pm     Reply with quote

Start by testing the clock speed of both chips.
Use a program that just raises a line for a time interval, and drops it again. If you have a reasonably well calibrated scope, then use a short interval like 100mSec, and time the pulse with your scope. If not, use a much longer time like 10 seconds, and time the pulse with a stopwatch. If the times from either chip is wrong, then this is the problem. Verify that your crystals, do match the clock rates entered in the clock statements on each chip. This sort of basic timing, needs to be 'right', before serial can work.
Second comment. Is the chip doing anything else while sending the character on the software serial?. Do you have any interrupts running?. If so, then this is the problem. Sotware async serial as implemented by CCS, requires that the processor does basically nothing else during the transmission (or reception) of a character using the software port.
What baud rate, start bit, stop bit etc., are you using?.

Best Wishes
Rohit de Sa



Joined: 09 Nov 2007
Posts: 282
Location: India

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

PostPosted: Sat Dec 06, 2008 11:45 pm     Reply with quote

So its the PIC running software serial that's giving erroneous data? Make sure that the crystal that you use and the #use delay statement tally.

Also post your code.

Rohit
adanali
Guest







pic to pc serial communication
PostPosted: Sun Jan 11, 2009 12:27 am     Reply with quote

Hi all,
I also have this problem and my code is:
Code:
#include "16f877a.H"
#use rs232(baud=9600, XMIT=PIN_C6,RCV=PIN_C7,STREAM=COMA,ERRORS)
#use rs232(baud=9600, XMIT=PIN_B2,RCV=PIN_B3,STREAM=COMB)


Pic A:

Code:
while(TRUE)
{
putc('B',COM_A);
if(kbhit(COM_A)){
c=getc(COM_A);
putc(c,COM_B)
}
}

Pic B:

Code:
while(TRUE)
{
putc('B',COM_A);
if(kbhit(COM_A)){
c=getc(COM_A);
putc(c,COM_B)
}
}


the problem is code or something from hardware i couldn't understand.
Is it why because i am using hardware and software serial together?
adanali
Guest







pic to pc serial communication
PostPosted: Sun Jan 11, 2009 12:29 am     Reply with quote

sorry the PIC B code will be :
Code:
while(TRUE)
{
putc('A',COM_A);
if(kbhit(COM_A)){
c=getc(COM_A);
putc(c,COM_B)
}
}
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Sun Jan 11, 2009 11:12 am     Reply with quote

Did you try what Rohit de Sa suggested? Does either PIC say the right thing to a PC? If not, do they say anything at all? Is it repeatable. It would be best to post a whole test program. Something we can compile and run.
_________________
The search for better is endless. Instead simply find very good and get the job done.
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