Page 1 of 2

test 315Mhz Tx & Rx

PostPosted: Tue Mar 12, 2013 3:28 am
by geevan
Hi, im using pic16f877a to connect with 315mhz Rx & Tx..can anyone help me by giving a simple coding to test this rf module when swicth(RB0) at Tx is pressed, LED(RB0) at Rx is blink..here i post my coding which is not work and i don't where is the mistake. Can anyone correct it. Thankz
TX
CODE: SELECT_ALL_CODE
#include <htc.h>
#include "usart.h"
#include "delay.h"

__CONFIG(0x3F72);

unsigned char Data = 0;

void main()
{
   TRISB = 0x01;
   PORTB = 0x00;
   init_comms();
   Data = 0b10101010;
   while(1)
   {
      if(RB0 == 1)
      {
         putch(Data);
         RB1 = 1;
         DelayMs(200);
      }
   }
}


RX
CODE: SELECT_ALL_CODE
#include <htc.h>
#include "usart.h"
#include "delay.h"

__CONFIG(0x3F72);

unsigned char Data = 0;

void main()
{
   TRISB = 0x00;
   PORTB = 0x00;
   init_comms();

   while(1)
   {
      Data = getch();
      DelayMs(200);
      if(Data == 0b10101010)
      {
         RB0 = 1;
      }
   }
}

Re: test 315Mhz Tx & Rx

PostPosted: Tue Mar 12, 2013 11:28 am
by A380
Would you mind to show your schematics for TX and RX here?

Re: test 315Mhz Tx & Rx

PostPosted: Tue Mar 19, 2013 1:51 am
by geevan
Rx and Tx schematic

Re: test 315Mhz Tx & Rx

PostPosted: Tue Mar 19, 2013 9:46 am
by robosang
What is the baud rate? what is the crystal value?

The circuit looks weird to me. Is there any power to microcontroller? If so why is 5V battery there?

Re: test 315Mhz Tx & Rx

PostPosted: Tue Mar 19, 2013 10:29 am
by shahrul
You must delete DelayMs(200); and putch(Data); continuously. Also use baudrate 1200.

Re: test 315Mhz Tx & Rx

PostPosted: Tue Mar 19, 2013 1:39 pm
by geevan
can you edit back my source code for tx and rx...because i dont know where should at the baudrate 1200

Re: test 315Mhz Tx & Rx

PostPosted: Tue Mar 19, 2013 1:48 pm
by geevan
my crystal value is 20Mhz...power supply for microcontroller is 5v as per schematic

Re: test 315Mhz Tx & Rx

PostPosted: Tue Mar 19, 2013 1:59 pm
by shahrul
geevan WROTE:can you edit back my source code for tx and rx...because i dont know where should at the baudrate 1200

For learning, you must do it yourself. Not my job to write a code for you.

Re: test 315Mhz Tx & Rx

PostPosted: Tue Mar 19, 2013 2:19 pm
by geevan
ok thanks...atleast can u tell me where sholud at the baudrate 1200

Re: test 315Mhz Tx & Rx

PostPosted: Tue Mar 19, 2013 4:49 pm
by robosang
at least? :mrgreen: