I want to transmit Data From one Pic18f2550 to Another using a cheap 434mhz wireless module. but its not working at all.
Following are the circuits for Tx and Rx respectively.
the code for Tx part is given below. written in MikroC v8.2
void tx_data(char);
#define FREQ 20000000
#define baud 9600
#define spbrg_value (((FREQ/64)/baud)-1) // Refer to the formula for Baud rate calculation in Description tab
void main()
{
SPBRG=spbrg_value; // Fill the SPBRG register to set the Baud Rate
RCSTA.SPEN=1; // To activate Serial port (TX and RX pins)
TXSTA.TXEN=1; // To enable transmission
RCSTA.CREN=1; // To enable continuous reception
TRISA=0;
TRISB=255;
while(1)
{
tx_data(PORTB);
delay_ms(100);
LATA.LATA4=1;
delay_ms(100);
LATA.LATA4=0;
}
}
void tx_data(char data1)
{
TXREG=data1; // Store data in Transmit register
while(PIR1.TXIF==0); // Wait until TXIF gets low
}
and the Rx code
unsigned char rx_data(void);
#define FREQ 20000000
#define baud 9600
#define spbrg_value (((FREQ/64)/baud)-1)
void main()
{
unsigned int state;
SPBRG=spbrg_value; // Fill the SPBRG register to set the Baud Rate
RCSTA.SPEN=1; // To activate Serial port (TX and RX pins)
TXSTA.TXEN=1; // To enable transmission
RCSTA.CREN=1; // To enable continuous reception
TRISB=0;
while(1)
{
state=rx_data();
PORTB=state;
} //main loop while(1)!!
} //end main()
unsigned char rx_data(void)
{
while(PIR1.RCIF==0); // Wait until RCIF gets low
return RCREG; // Retrieve data from reception register
}
But this Setup wont transmit/receive data? i've tried by replacing wireless module with wires.. then it works perfectly... maybe the RF module is faulty... but thats highly improbable cuz i've tried with 10 different pairs of RF modules.
So is there any problem with the circuit or if the RF module is supposed to be faulty, is there anyway to check that it works?
UPDATE:
as asked I've attached the picture of the RF module i'm using...no i dont know the part no. but it looks like the following picture
I also Tried connecting the RF receiver at the USB-TTL board to see if any data is being transmitted... but no.. nothing is being transmitted. any help?