# TX issue on TRW 24G

**URL:** <https://community.sparkfun.com/t/tx-issue-on-trw-24g/510>\
**Category:** Wireless & IoT\
**Created:** [April 18, 2005, 11:15pm UTC](https://community.sparkfun.com/t/tx-issue-on-trw-24g/510 "2005-04-18T23:15:57Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![ragudelo](https://avatars.discourse-cdn.com/v4/letter/r/ac8455/32.png) [@ragudelo](https://community.sparkfun.com/u/ragudelo)\
**Post date:** [April 18, 2005, 11:15pm UTC](https://community.sparkfun.com/t/tx-issue-on-trw-24g/510/1 "2005-04-18T23:15:57Z")

</div>

Hi… I recently bought a couple of these modules and it has been a couple of weeks since I finally received some data (noise I believe). Then I enabled the CRC and set it to 16 bits, along with a 40 bit address. So they are no longer receiving noise, it works!!!

So I went on to configure the other RF module in order to establish my own little RF wireless network, right? The configuration word is almost the same, I just changed the device address (so it is not the same as the rx\_device address) and cleared the RX\_EN.

I started one of the PIC’s timer so it interrupts on overflow and must send data via the tx\_rf\_module… but im not getting any data on the other side, my rx\_rf\_module doesn’t set DR1… Anyone know what is wrong with my routine???

I’m posting my tx\_rf\_ module configuration routines:

void tx\_modulo(unsigned char dato\_spi)

{

LATDbits.LATD0 = 1; //CE set high.

Delay10TCYx(5); //5us delay

OpenSPI(SPI\_FOSC\_64, MODE\_11, SMPMID);

WriteSPI(0xa0);

WriteSPI(0xa0);

WriteSPI(0xa0);

WriteSPI(0x01);

WriteSPI(0x15);

WriteSPI(dato\_spi);

WriteSPI(dato\_spi);

WriteSPI(dato\_spi);

WriteSPI(dato\_spi);

WriteSPI(dato\_spi);

WriteSPI(dato\_spi);

CloseSPI();

LATDbits.LATD0 = 0; //CE set low

Delay10TCYx(185); //195us delays

}

void configurar\_trf24g (void)

{

INTCON3bits.INT1IE = 0; conf\_trf[1] = 0xff;

conf\_trf[2] = 0x08;

conf\_trf[3] = 0xff;

conf\_trf[4] = 0xff;

conf\_trf[5] = 0xff;

conf\_trf[6] = 0xff;

conf\_trf[7] = 0xff;

conf\_trf[8] = 0xbb;

conf\_trf[9] = 0xbb;

conf\_trf[10] = 0xbb;

conf\_trf[11] = 0xbb;

conf\_trf[12] = 0xbb;

conf\_trf[13] = 0b10100011;

conf\_trf[14] = 0b01101111; conf\_trf[15] = 0b00;

LATDbits.LATD0 = 0; //CE set low

Delay1KTCYx(30); //3 ms. delay

LATDbits.LATD1 = 1; //CS set high Delay10TCYx(5); //5us delay

i\_trf = 1;

for(i\_trf = 1 ; i\_trf \< 16 ; i\_trf++)

{

salida = escribir\_spi(conf\_trf[i\_trf]);

}

LATDbits.LATD1 = 0; //CS set low

Delay1TCY(); //100 ns delay LATDbits.LATD0 = 1; //CE set high, it is now active

}

Thanks for your help!!!

---

<div class="post-metadata">

**Author:** ![Lajon](https://avatars.discourse-cdn.com/v4/letter/l/ea666f/32.png) [@Lajon](https://community.sparkfun.com/u/Lajon)\
**Post date:** [April 19, 2005, 12:57pm UTC](https://community.sparkfun.com/t/tx-issue-on-trw-24g/510/2 "2005-04-19T12:57:12Z")

</div>

Hi,

Some things that may be problematic:

I think the delay

```auto
Delay1KTCYx(30); //3 ms. delay 

```

should be before you start to configure.

```auto
conf_trf[2] = 0x08; 

```

Thats the payload size I belive. It is in bits so this is only one byte payload (and you seem to send 6 bytes).

You are using the conf\_trf starting at index 1. Thats ok as long as it is dimensioned with one extra entry (in your case it would need to be 16 bytes).

---

<div class="post-metadata">

**Author:** ![ragudelo](https://avatars.discourse-cdn.com/v4/letter/r/ac8455/32.png) [@ragudelo](https://community.sparkfun.com/u/ragudelo)\
**Post date:** [April 19, 2005, 2:15pm UTC](https://community.sparkfun.com/t/tx-issue-on-trw-24g/510/3 "2005-04-19T14:15:02Z")

</div>

Hi…

Thanks for your advice, but I need to know one thing. When Im transmitting data to another RF module, shouldn’t I write first the adress of the receiving device??? Then the data???

In my code, I’ve configured the receiving module with a 40bits address, so that’s why i’m sending the address first and then the data.

Thanks for your help and concern, hope you help me… i’m stuck in this!!!

---

<div class="post-metadata">

**Author:** ![Lajon](https://avatars.discourse-cdn.com/v4/letter/l/ea666f/32.png) [@Lajon](https://community.sparkfun.com/u/Lajon)\
**Post date:** [April 19, 2005, 7:58pm UTC](https://community.sparkfun.com/t/tx-issue-on-trw-24g/510/4 "2005-04-19T19:58:54Z")

</div>

Yes, that is correct. But have you also configured the receiver payload size (48 bits to match your tx\_modulo function). Maybe you could show the receiver code also. Or you could have a look at the code I have posted in the AVR Code forum here (ok, you use PIC but since it is C -code it could be useful to look at anyway).

/Lars

---

<div class="post-metadata">

**Author:** ![John\_at\_J\_amp\_S](https://avatars.discourse-cdn.com/v4/letter/j/9d8465/32.png) [@John\_at\_J\_amp\_S](https://community.sparkfun.com/u/John_at_J_amp_S)\
**Post date:** [April 19, 2005, 8:31pm UTC](https://community.sparkfun.com/t/tx-issue-on-trw-24g/510/5 "2005-04-19T20:31:54Z")

</div>

Lars:

I don’t know “C”. Is there a flow chart I can refer to? I want to write assembly code for a Motorola MCU.

---

<div class="post-metadata">

**Author:** ![ragudelo](https://avatars.discourse-cdn.com/v4/letter/r/ac8455/32.png) [@ragudelo](https://community.sparkfun.com/u/ragudelo)\
**Post date:** [April 19, 2005, 11:53pm UTC](https://community.sparkfun.com/t/tx-issue-on-trw-24g/510/6 "2005-04-19T23:53:46Z")

</div>

Here is my latest receiver code…

#include \<p18f452.h\>

#include \<delays.h\>

#include \<i2c.h\>

#include \<spi.h\>

#define TAMANORF 16

unsigned char conf\_trf[TAMANORF]= {0};

unsigned char escribir\_spi(unsigned char dato\_spi);

void configurar\_trf24g (void);

void main (void);

unsigned char salida;

unsigned char i\_trf;

void main()

{

TRISD = 0;

TRISC = 0b10011000;

TRISB = 0b00000111;

LATD = 0;

LATBbits.LATB5 = 1;

configurar\_trf24g();

INTCON = 0b11100000;

INTCON2 = 0b00000000;

INTCONbits.GIEL = 1;

INTCON2bits.INTEDG1 = 0;

INTCON3bits.INT1IP = 0;

INTCON3bits.INT1IE = 1;

INTCON3bits.INT1IF = 0;

RCONbits.IPEN = 1;

Delay1TCY();

LATDbits.LATD0 = 1; //Set CE (high)

while(1)

{

LATBbits.LATB4 = !LATBbits.LATB4;

}

}

unsigned char escribir\_spi(unsigned char dato\_spi)

{

OpenSPI(SPI\_FOSC\_64, MODE\_00, SMPMID);

WriteSPI(dato\_spi);

CloseSPI();

return 0;

}

void configurar\_trf24g (void)

{

conf\_trf[1] = 0x44;

conf\_trf[2] = 0x08;

conf\_trf[3] = 0xff;

conf\_trf[4] = 0xff;

conf\_trf[5] = 0xff;

conf\_trf[6] = 0xff;

conf\_trf[7] = 0xff;

conf\_trf[8] = 0xa0;

conf\_trf[9] = 0xa0;

conf\_trf[10] = 0xa0;

conf\_trf[11] = 0x01;

conf\_trf[12] = 0x01;

conf\_trf[13] = 0b10100011 conf\_trf[14] = 0b01101111;

conf\_trf[15] = 0x01;

LATDbits.LATD0 = 0; //clear CE

LATDbits.LATD1 = 1; //set CS Delay10TCYx(10); //10us delay

i\_trf = 1;

for(i\_trf = 1 ; i\_trf \< 16 ; i\_trf++)

{

salida = escribir\_spi(conf\_trf[i\_trf]);

}

LATDbits.LATD1 = 0; //clear CS

Delay1TCY(); //100ns delay @ 40 Mhz

LATDbits.LATD0 = 1; //set CE

}

I’ll try and post later some sort of steps to follow in order to configure these modules, at least what i’m doing… don’t know if it is correct, though, John…

Good luck everyone and thanks again…

I’ve included the suggestions made by Lajon, changed the initial 3ms delay and added a couple more bits to receive… still not working…

---

<div class="post-metadata">

**Author:** ![ragudelo](https://avatars.discourse-cdn.com/v4/letter/r/ac8455/32.png) [@ragudelo](https://community.sparkfun.com/u/ragudelo)\
**Post date:** [April 20, 2005, 12:06am UTC](https://community.sparkfun.com/t/tx-issue-on-trw-24g/510/7 "2005-04-20T00:06:50Z")

</div>

#include \<p18f452.h\>

#include \<delays.h\>

#include \<i2c.h\>

#include \<spi.h\>

#define TAMANORF 16

void InterruptHandlerLow (void);

unsigned char conf\_trf[TAMANORF]= {0};

unsigned char escribir\_spi(unsigned char dato\_spi);

void configurar\_trf24g (void);

void main (void);

void tx\_modulo(unsigned char dato\_spi);

unsigned char salida;

unsigned char i\_trf;

unsigned int i2\_tx = 0;

unsigned int i\_tx = 0;

void main()

{

TRISD = 0;

TRISC = 0b10010000;

TRISB = 0b00000111;

LATD = 0;

LATBbits.LATB5 = 1;

LATBbits.LATB6 = 0;

configurar\_trf24g();

INTCON = 0b11100000;

INTCON2 = 0b00000000;

INTCONbits.GIEL = 1;

INTCON2bits.INTEDG1 = 0;

INTCON3bits.INT1IP = 0; INTCON3bits.INT1IE = 1;

INTCON3bits.INT1IF = 0;

RCONbits.IPEN = 1;

LATDbits.LATD0 = 1; //SET CE

while(1)

{

LATBbits.LATB4 = !LATBbits.LATB4;

if(i\_tx==62)

{

i\_tx=0;

i2\_tx++;

if(i2\_tx == 4) //a little loop, perhaps .5 Hz

{

tx\_modulo(0b10101010);

LATBbits.LATB6 = !LATBbits.LATB6;

i2\_tx=0;

}

}

i\_tx++;

}

}

unsigned char escribir\_spi(unsigned char dato\_spi)

{

OpenSPI(SPI\_FOSC\_64, MODE\_00, SMPMID);

WriteSPI(dato\_spi);

CloseSPI();

return 0;

}

void tx\_modulo(unsigned char dato\_spi)

{

TRISCbits.TRISC3 = 0; LATDbits.LATD0 = 1; // SET CE

Delay10TCYx(5); //5us delay

OpenSPI(SPI\_FOSC\_64, MODE\_00, SMPMID);

WriteSPI(0xa0);

WriteSPI(0xa0);

WriteSPI(0xa0);

WriteSPI(0x01);

WriteSPI(0x01);

WriteSPI(dato\_spi);

CloseSPI();

LATDbits.LATD0 = 0; //CLEAR CE

Delay10TCYx(185); //195us delay

}

void configurar\_trf24g (void)

{

INTCON3bits.INT1IE = 0; //disable ext\_int1

conf\_trf[1] = 0xff;

conf\_trf[2] = 0x08;

conf\_trf[3] = 0xff;

conf\_trf[4] = 0xff;

conf\_trf[5] = 0xff;

conf\_trf[6] = 0xff;

conf\_trf[7] = 0xff;

conf\_trf[8] = 0xbb;

conf\_trf[9] = 0xbb;

conf\_trf[10] = 0xbb;

conf\_trf[11] = 0xbb;

conf\_trf[12] = 0xbb;

conf\_trf[13] = 0b10100011;

conf\_trf[14] = 0b01101111; conf\_trf[15] = 0b00; LATDbits.LATD0 = 0; //CLEAR CE

Delay1KTCYx(30); //3ms delay

LATDbits.LATD1 = 1; //SET CS Delay10TCYx(5); //5us delay

i\_trf = 1;

for(i\_trf = 1 ; i\_trf \< 16 ; i\_trf++)

{

salida = escribir\_spi(conf\_trf[i\_trf]); }

LATDbits.LATD1 = 0; //CLEAR CS

Delay1TCY(); //100ns delay LATDbits.LATD0 = 1; //SET CE

INTCON3bits.INT1IE = 1; //enable ext\_int1

}

// Low priority interrupt vector

#pragma code InterruptVectorLow = 0x18

void

InterruptVectorLow (void)

{

\_asm

goto InterruptHandlerLow //jump to interrupt routine

\_endasm

}

//----------------------------------------------------------------------------

#pragma code

#pragma interrupt InterruptHandlerLow

void

InterruptHandlerLow ()

{

if( INTCON3bits.INT1IF)

{

LATDbits.LATD1 = 0; //CLEAR CS

LATDbits.LATD0 = 0; //CLEAR CE

LATBbits.LATB5 = !LATBbits.LATB5 ;

OpenSPI(SPI\_FOSC\_64, MODE\_00, SMPMID); salida = ReadSPI();

INTCON3bits.INT1IF = 0;

}

}

Still, not working… im not getting any significant data… HELP ANYONEE… please!!!

Good luck!!

---

<div class="post-metadata">

**Author:** ![Lajon](https://avatars.discourse-cdn.com/v4/letter/l/ea666f/32.png) [@Lajon](https://community.sparkfun.com/u/Lajon)\
**Post date:** [April 20, 2005, 7:19am UTC](https://community.sparkfun.com/t/tx-issue-on-trw-24g/510/8 "2005-04-20T07:19:00Z")

</div>

In the tx is this your actual line?

```auto
LATDbits.LATD1 = 1; //SET CS Delay10TCYx(5); //5us delay 

```

or is it a problem with the post (you can mark your code and press the Code button to make it easier to read).

The line above comments out the 5us delay which is a problem.

I don’t see any immediate other problems but I don’t know PIC so it could be something with that or timing.

Also did you see the “Free nRF2401 Configuration Software” thread in this forum? Might be useful to verify the configuration.

/Lars

---

<div class="post-metadata">

**Author:** ![Lajon](https://avatars.discourse-cdn.com/v4/letter/l/ea666f/32.png) [@Lajon](https://community.sparkfun.com/u/Lajon)\
**Post date:** [April 20, 2005, 10:54am UTC](https://community.sparkfun.com/t/tx-issue-on-trw-24g/510/9 "2005-04-20T10:54:11Z")

</div>

John at J&S:

I don’t have any other description but did you look at the data sheet? It is actually quite good with a step by step description of what needs to be done (and what the chip does) for the different modes.

Also, it should be possible to look at the code even if you don’t know C and you can use the program mentioned (the thread “Free nRF2401 Configuration Software”) to generate the config data.

/Lars
