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

send integer between two pic rs232!
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
temtronic



Joined: 01 Jul 2010
Posts: 9243
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat May 19, 2012 1:04 pm     Reply with quote

I'd do the following tests.

1) Have the 'transmitter' PIC (with MAX232) connected to PC serial port pin 2 and run a terminal program. Data FROM the transmitter PIC should be displayed on the terminal display

2) Have the 'receiver' PIC (with MAX232) connected to pin 3 of the PC serial port. Any key pressed on the PC should be sent to the PIC.

Be sure to connect PC serial port pin 5 (ground) to BOTH PICs though.

If 1 works , the transmitter PIC is good
If 2 works the receiver PIC is good.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat May 19, 2012 3:28 pm     Reply with quote

1. Post a link to a schematic of the project, showing both PICs and all
connections to them. It should also show all voltage and ground
connections to the PICs and other circuits. It show crystal frequencies,
(if used), etc.

2. Post a link to a photo of the project. Make it be a close-up photo so
we can see the wiring. Reduce the photo size so it's no larger than
1024x768. Do a Google search for: Image Resizer for Windows XP
(or whatever OS you are using).

Note: Use a free image hosting service to post these items.
Use something like http://www.imageshack.us

3. Post the test programs that you are running in each PIC.

4. Post a description of the test setup. For example, is one PIC
connected to an LCD ? And then you read the results of the
serial test on the LCD. Or, maybe one PIC is connected to a PC
and you read the results of the test on a terminal window.

5. Describe how you run the test. Tell us how you know that it fails.
Tell us what you expect the test to show, and tell us what it is actually
showing.

6. Tell us if this test is being done in actual hardware, or is it a Proteus
project.
karimpain



Joined: 15 Feb 2012
Posts: 39
Location: italia

View user's profile Send private message AIM Address MSN Messenger ICQ Number

PostPosted: Sun May 20, 2012 5:40 am     Reply with quote

No I'm doing the test in hardware and all of the steps that I'm going talk about are in hardware:
Here is the code for the both since the code send and receive data:
Code:

#include <16F877a.h>
#Fuses HS,NOPROTECT,NOWDT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600,xmit=PIN_c6, rcv=PIN_c7,BITS =8, PARITY=n, stop=1,errors)
#include<lcd420_b.c>

void main() {int valor;
 int valor1=9;//this is for the transmitter pic.
lcd_init();
 while(1){ {
     PUTC(valor1);
     delay_us(100);
     if (kbhit())
     {
       valor=getc();//this step is for the receiver pic
       printf(lcd_putc,"\fData= %d",valor);//connecting the tx to rx
       delay_ms(1000);//show data=9
       printf(lcd_putc,"\fNo Data");
       delay_ms(50);
     }
 }
}

and here is the image of the circuit:
http://imageshack.us/photo/my-images/803/18559266.png/
Now the steps that I've done are:
1st: I connect the tx to the rx of the transmitter pic to show if it sends and receive at the same time and showing the result on lcd, it was successful.
2nd: As the first step but on second pic, and I obtained the same result.
3rd: Connect them both (tx from the tr. to rx. on the receiver) but the receive pic didn't receive anything (it always show me "no data").
4th: Send and receive data from pc and to pc running on matlab and the pic receive the integer sent from computer and vice versa.
Now I really don't know what kind of step I have to do!!!!!!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun May 20, 2012 5:39 pm     Reply with quote

It works for me. I used your program on two PICDem2-Plus boards.
I didn't have two 16F877A chips, so on the transmitter board I used a
16F877. The receiver board has a 20x4 LCD on the lower right corner.
It shows "Data= 9". That's what you expected to see. So it's working.

I used a Null Modem cable between the two boards. Here are the
connections for the cable.
Pins
2 -> 3
3 -> 2
5 -> 5 (ground pin)

I took a photo of my setup and posted it here:
http://imageshack.us/photo/my-images/441/pictopicseriali.jpg/

Your posted schematic looks like a Proteus schematic. It's missing
the 22 pf ceramic capacitor that should be on the 20 MHz crystals.
So I wonder how your hardware works without those capacitors.
Also, you're supposed to use a 10K pull-up resistor on the MCLR pin
when you use a Microchip ICD2 programmer. Those are not on the
schematic.
Proteus doesn't care about missing components for many circuits.
But real hardware needs everything to be correct.

I don't know if you ever posted your CCS compiler version, so I just
used vs. 4.132 which is the latest version.
karimpain



Joined: 15 Feb 2012
Posts: 39
Location: italia

View user's profile Send private message AIM Address MSN Messenger ICQ Number

PostPosted: Mon May 21, 2012 3:34 am     Reply with quote

Thank you for everything .. Smile
Now finally the data is received correctly but the problem was something that i didn't expect. I canceled the lcd_init() and all the "printf" so the only command on the tx is the "putc" and the receiver here receive data(don't know the reason!!!) but the good news is that works Smile
Thanks yes I'm going to put the capacitor and pull up the mclr (I know about them but i looked that it works without them).
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Mon May 21, 2012 2:41 pm     Reply with quote

Hi,

OK, put me down as a 'skeptic'! All the stuff you commented out is related to the LCD, and should have no effect on your ability to send serial data via the UART. Also, it's quite unlikely that your circuit would run at all (in real hardware) without an active pullup on MCLR. Unless and until you post a picture of your real hardware, then this is just another Proteus exercise, IMHO.

I don't have a problem with Proteus per se, I just object to people saying "yeah, my problem occurs on real hardware, please help me" when it's really just a simulation. The level of help is just not there for pure simulation projects - you know that, and I know that!

Cheers,

John
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon May 21, 2012 2:55 pm     Reply with quote

Me too. I don't believe it was ever in hardware.
karimpain



Joined: 15 Feb 2012
Posts: 39
Location: italia

View user's profile Send private message AIM Address MSN Messenger ICQ Number

PostPosted: Tue May 22, 2012 2:36 pm     Reply with quote

Thanks for everything guys. Really the problem was the lcd. But i want to say something i worked a lot using proteus and i can say that it resolves 60% of the work (so i don't trust it at all) .... in my project proteus work with my code but in the real life doesn't..and here is the photo of my hardware with my imu 5 dof that i'm testing (sending data between accelro and gyro,that's why interfacing two pic Smile ) and i don't pull up the mclr, i know it's better but it works the same:
http://imageshack.us/photo/my-images/690/photo0121s.jpg/
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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