Pic to Pic communication

Status
Not open for further replies.

I007

New Member
Hi. I need to send 5 bits of data from one 18f4431 pic to another 18f4431. I am using PICKit2 and C18 compiler. I have connected the TX of the sending pic to the RX of the receiver pic. No resistor in between? Is that good?

My code looks like this:

Sender:

#include <p18F4431.h>
#include <delays.h>
#include <usart.h>


void main()
{
TRISC = 0x00;
OSCCON = 0xf0;

OpenUSART(USART_TX_INT_OFF & USART_RX_INT_OFF &
USART_ASYNCH_MODE & USART_EIGHT_BIT &
USART_CONT_RX & USART_BRGH_LOW, 12); //baud rate 9600 1.36% error

while(1)
{
WriteUSART(PORTB); //some random value
}

}







And receiver:

#include <p18F4431.h>
#include <delays.h>
#include <usart.h>


void main()
{

unsigned char c;
TRISC = 0xff;
OSCCON = 0xf0;

OpenUSART(USART_TX_INT_OFF & USART_RX_INT_OFF
& USART_ASYNCH_MODE & USART_EIGHT_BIT &
USART_CONT_RX & USART_BRGH_LOW, 12);

while(1)
{
while (!DataRdyUSART())
c = ReadUSART();
PORTB = c;
}
}

But if i switch 5V to PortB of the sender I do not get any output from PortB on my receiver. The mclr is connected to Vdd with a resistor on both and Vdd and Vss are connected. Can anyone tell me what is wrong? Guess it's my code? Thanks
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…