Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[Moved] PIC18f4550 board to board communication problem using USART

Status
Not open for further replies.

Harshal Dalal

Newbie level 3
Joined
Jul 23, 2014
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
23
hello everyone ,
I am interested in communication between to pic18f4550 hardware.
here is my 2 code..
1st is for transmit from 1st board to another,


Code:
unsigned char txbuf[]={0x02, 0x31, 0x37, 0x3B, 0x3B, 0x44, 0x45,0x03,};
unsigned char z, i;
void TXbyte(char data)
{
    while(TXSTAbits.TRMT==0); //wait tiiltransmit buffer in not empty
    TXREG = data; // Transmit Data
}//end TXbyte
-------------------------
------------------------
-----------------------
void main()
{
SPCON1 = 0; // Make sure SPI is disabled //Refer Datasheet
 TRISCbits.TRISC7=1; // RX
 TRISCbits.TRISC6=0; // TX
 SPBRG = 0x9B; //4800 baud XTAL=20MHz, Fosc=48Mhz

 TXSTA = 0x20; // TX enable BRGH=0
 RCSTA = 0x90; 

 for(i=0;txbuf[i]!='\0';i++)
  {
   TXbyte(txbuf[i]);
  }
}//main ends


and here is my 2nd code to receive the data from 1st board

Code:
void main()
{
SSPCON1 = 0; // Make sure SPI is disabled //Refer Datasheet
 TRISCbits.TRISC7=1; // RX
 TRISCbits.TRISC6=0; // TX
 SPBRG = 0x9B; //4800 baud XTAL=20MHz, Fosc=48Mhz
  TXSTA = 0x20; // TX enable BRGH=0
 RCSTA = 0x90; // continuous RX
 BAUDCON = 0x00; // BRG16 = 0
 
for(i=0;i<8;i++) //for loop receive 8 byte to receive and it will store in rxbuf
 {
 while(PIR1bits.RCIF==0); //Wait util data from PC is received
 rxbuf[i]=RCREG;
 PIR1bits.RCIF = 0;
 }
if (rxbuf[1]==0x31 && rxbuf[2]==0x37 ) // this loop will check 1st and 2nd byte whether it is 1 and 7 or not
{
PORTBbits.RB5=1;
}
}

my both code is perfectly working on hyper terminal and proteus simulation when i connect them "SEPARATELY" with PC
but when i try connect two pic with rs232 then its not working...
so plz help me.. yours suggestion are most welcome
 

Hi,
please post here your schematic design with all connections that u have used.
if your code is working, it is very likely that your problem is hardware.:wink:


if I understand it right, it looks like you tried to use two COM ports on your PC?
The pc can not manage more than one COM.
 

Hi, I have done PIC to PC communication. Did you used MAX232 IC for the data transfer. Because there is a difference in the voltage levels of PC and PIC.
PC are usually RS232 whereas PIC are TTL logic levels. MAX 232 is used to convert these levels. Thanks.

Syed Fahad Wasti
 

thank you "Syed Fahad Wasti"
yes i have used MAX232 IC...and communication between PIC and PC is perfectly working....
I want to communicate one pic with another ....

- - - Updated - - -

Hi,

if I understand it right, it looks like you tried to use two COM ports on your PC?
The pc can not manage more than one COM.

I have connected my tx-pic and rx-pic with pc only one at a time...
but now i want to connect 2 pic tx to rx directly... now no PC in between
 

Well, in order to connect multiple PICs (One PIC must be a Master and other PIC must be a Slave), you can use either SPI protocol or I2C protocol ..
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top