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.

RF Module interfacing with PIC

Status
Not open for further replies.

Chullaa

Advanced Member level 4
Joined
Aug 27, 2010
Messages
113
Helped
17
Reputation
34
Reaction score
17
Trophy points
1,298
Activity points
2,019
HI
I am willing to interface RF module TRW-24G with PIC16F877A. I am using CCS C complier.
Can any one suggest simple code or tutorial. will it use SPI port?
I have successfully done UART wired communication.

Thank you
Umair
 

sbit TRW_24G_CLK = P1^1;
sbit TRW_24G_DATA = P1^6;
sbit TRW_24G_CS = P1^2;
sbit TRW_24G_CE = P1^3;
sbit TRW_24G_DR1 = P1^4;

/* --------------------------------------------------------------------
Features: TRW-24G is written a BYTE (includes write the word with configuration information sent a BYTE)
------------------------------------------------------------------ */
void Write_TRW_24G_BYTE(x)
{
char i;
for(i=0;i<8;i++)
{
TRW_24G_CLK = 0; if(x&0x80) TRW_24G_DATA= 1;
else
TRW_24G_DATA= 0; x<<=1; TRW_24G_CLK = 1; TRW_24G_CLK = 1; TRW_24G_CLK = 1;
}
}
/* --------------------------------------------------------------------
Features: Reading a BYTE information from TRW-24G
----------------------------------------------------------------------*/
char Read_TRW_24G_BYTE(void)
{
char i,x;
for(i=0;i<8;i++)
{
TRW_24G_CLK = 0; TRW_24G_CLK = 0; TRW_24G_CLK = 0; TRW_24G_CLK = 1; x<<=1;
if(TRW_24G_DATA)
x|=0x01;
else
x|=0x00; } return(x);
}
/* --------------------------------------------------------------------
Features: TRW-24G configuration
-------------------------------------------------------------------- */
void Config_TRW_24G(void)
{
unsigned char i;
P1MDOUT |= 0x4E;
TRW_24G_CE = 0;
TRW_24G_CS = 1;
for(i=0;i<18;i++)
Write_TRW_24G_BYTE(RF_Buffer);
TRW_24G_CS = 0; if(RF_Status[0]&&(RF_Status[6]==1)) {
P1MDOUT &= 0xBD; P1 |= 0x42; TRW_24G_CE = 1;
}
}
/*--------------------------------------------------------------------
Function: The TRW-24G send a packet.
--------------------------------------------------------------------*/
void Send_TRW_24G(char x)
{
unsigned char i;
TRW_24G_CS = 0;
TRW_24G_CE = 1;
Write_TRW_24G_BYTE(0xF0);
Write_TRW_24G_BYTE(0xF0);
for(i=0;i<28;i++)
Write_TRW_24G_BYTE(x);
TRW_24G_CE = 0;
}
/* --------------------------------------------------------------------
Function: TRW-24G read out a packet
-------------------------------------------------------------------- */
char Receive_TRW_24G(void)
{
unsigned char i=0,RF_Data[30];
TRW_24G_CE = 1;
P1MDOUT &= 0xBF;
P1 |= 0x40;
TRW_24G_CLK = 0;
if(TRW_24G_DR1)
{
for(i=0;i<28;i++) RF_Data = Read_TRW_24G_BYTE();
i= RF_Data[4]; } return(i);
}
/////////////////////////////////////////////////////////
this is the sample code i googled from **broken link removed**
if u have any doubts regarding this u can get it from the above data sheet
 

I am trying to understand the code. I have seen some codes that use SPI or UART to interface TRW-24G, I could not figure out which one is this. or this is other method.

Thanks
Umair
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top