|
|
View previous topic :: View next topic |
Author |
Message |
stefsun
Joined: 23 May 2007 Posts: 22
|
two pic commnicate with PC via RS232? |
Posted: Sun Jun 17, 2007 7:25 pm |
|
|
when I use two pic commnicate with PC via RS232,one is 16F877,the other is 18F4523.when I
connect the Oscillator with the pics,they work as following
16F877 18F4523 results
4M 10M NO
4M 4M NO
share the same 4M Oscillator,they work well.
Can I use the Oscillator separately? |
|
|
arunb
Joined: 08 Sep 2003 Posts: 492 Location: India
|
re: |
Posted: Sun Jun 17, 2007 7:29 pm |
|
|
You mean the PICs are sharing an oscillator ??
Dont' know if that is a good idea, but yes you can run the PICs using different oscillators, but keep in mind the max osc. requirements for the PICs,
For serial connection to work, the baud rates of both the PICs must be the same ...
thanks
arunb |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Jun 17, 2007 8:14 pm |
|
|
Post your #use rs232() statement for each PIC.
Also post the #use delay() and #fuses statements for each PIC. |
|
|
stefsun
Joined: 23 May 2007 Posts: 22
|
|
Posted: Sun Jun 17, 2007 8:59 pm |
|
|
The 16F877 and the 18F4523's PIN25(TX) and PIN26(RX) connect each other.they reply according to PC'instruction separately.
the 16F877 code is
Code: |
#include <16F877.h> // PICF4523 header file
#device ADC=10 // 12 bits ADC
#use delay(clock=4000000) // for 10Mhz crystal
#fuses XT, NOWDT, NOPROTECT, NOLVP // for debug mode
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, PARITY=N,BITS =8,stream=MYPC)
void main(void)
{
int8 c=0;
SET_TRIS_C( 0xFF );
while(1)
{
while(!kbhit())
delay_us(10);
if(kbhit())
{
c=fgetc(MYPC);
if(2==c)
{
//putc(c);
printf("877 is ready\n");
SET_TRIS_C( 0x8F ); }
else
SET_TRIS_C(0XFF); }
}
}
|
the 18F4523 code is
Code: |
#include <18F4523.h> // PICF4523 header file
#device ADC=12 // 12 bits ADC
#use delay(clock=4000000) // for 4Mhz crystal
#fuses XT, NOWDT, NOPROTECT, NOLVP // for debug mode
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, PARITY=N,BITS =8,stream=MYPC)
void main(void)
{
int8 c=0;
SET_TRIS_C( 0xFF );
while(1)
{
while(!kbhit())
delay_us(10);
if(kbhit())
{
c=fgetc(MYPC);
if(1==c)
{
//putc(c);
printf("4523 is ready\n");
SET_TRIS_C( 0x8F ); }
else
SET_TRIS_C( 0xFF ); }
}
} |
|
|
|
|
|
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
|