nrf24l01 help, where are you brennen?

I have 2 MC9S12DP256’s with the nrf’s with the SMA connector on them. Well i have used brennens library and am pretty sure everything is okay. my problem is i am not getting communication between the two nrf’s. I did a dump all registers function from brennens lib and all looked okay on both trans and reciever. The transmitter is giving the TX_DS interrupt but the reciever never gets the RX_DR interrupt and never get any data in the RX FIFO. I am able to communicate through SPI to the nrf’s just fine and all internal regs to the nrf’s are set right but the reciever wont recieve any bytes, the CE line is high on the reciever and the transmitter keeps giving the interrupt which tells me that i think the trans is working but the reciever is not although the HCS12 communicates to the recieving nrf through SPI just fine. Is it possible for the nrf module to communicate through SPI and report that it is okay but still be defective and not be able to recieve or if the nrf is responding to SPI than it should recieve. I am going crazy, everything looks okay but no bytes across link. Help, brennen where are you?

Hookups1534

#include <mc9s12dp256.h>

#include “nrf24l01.h”

#include “init_dragon12.h”

void main(void)

{

bool data_ready = false;

unsigned char byte = 0x00;

unsigned char status = 0x00;

// unsigned char regs[36];

// unsigned char * pregs = &regs[0];

init_dragon12();

nrf24l01_initialize_debug(true, 0x01, false);

nrf24l01_power_up(true); //powers up, if already powered up, exits

nrf24l01_set_as_rx(true); //sets as reciever, if already set exits

nrf24l01_rx_standby_to_active();

nrf24l01_irq_clear_all();

nrf24l01_set_rf_ch(0x05);

while (1)

{

// nrf24l01_get_all_registers(pregs);

// data_ready=nrf24l01_cd_active();

// nrf24l01_irq_clear_all();

nrf24l01_rx_standby_to_active();

data_ready=nrf24l01_irq_pin_active();

// status=nrf24l01_get_fifo_status();

if (data_ready == true)

{

/*reads byte from rx fifo and stores it in byte, returns status register */

status=nrf24l01_read_rx_payload(&byte, 1); //reads byte from rx fifo and stores it in byte

// nrf24l01_irq_clear_rx_dr(); //clears rx dr flag

PORTB=byte;

}

else

{

status=nrf24l01_get_status();

// PORTB=status; //means no data recieved

}

}

}

and for the trans:

#include <mc9s12dp256.h>

#include “nrf24l01.h”

#include “init_dragon12.h”

void main(void)

{

unsigned char status=0x00;

unsigned char data=0x00;

bool transmit = false;

unsigned char interrupt_ident = 0x00;

unsigned char * pdata = &data;

init_dragon12();

nrf24l01_initialize_debug(false, 0x01, true);

nrf24l01_power_up(false);

nrf24l01_set_as_tx();

nrf24l01_set_rf_ch(0x05);

while (1)

{

nrf24l01_irq_clear_all();

data=PTT; //make this PTT when axiom

status=nrf24l01_write_tx_payload(pdata, 1, true);

transmit=nrf24l01_irq_pin_active();

interrupt_ident=nrf24l01_get_status();

if (transmit == true)

{ if ((interrupt_ident & 0x20) == 0x20) //checks is TX_DS is the cause of interrupt

{ PTM|=0x01;} // light up LED to tell data sent

}

else

{

PTM&=0xFE;

}

}

}

Haha it’s pretty crazy to see my name be called in a forum subject 8) . I can’t see anything that looks wrong right off hand, so will you send your transmitter and receiver main files (the ones that you have pasted into the forum) to me over email? I am going to see if I can modifiy your code to fit my micro and see if it works on my end. Send the files to brennen ~at~ diyembedded ~dot~ com.

Thanks for your help brennen, i sent you the source.

Brennen, my email box just told me there is a problem with your SMTP email server, What else should i do, do you have another email account?

I think I just found your error. You are configuring the TX to use Enhanced Shockburst and the RX not to. The line

nrf24l01_initialize_debug(false, 0x01, true); 

in your TX code should be changed to

nrf24l01_initialize_debug(false, 0x01, false); 

The fact that the packet formats in Shockburst and Enhanced Shockburst are different would explain why you are not receiving packets at the receiver at all. Try this out and let me know if it fixes your problem.

You also have quite a few function calls in there that aren’t really necessary, but as long as the code works, that’s what really matters. For instance, when you call the nrf24l01_initialize_debug(), you don’t have to call nrf24l01_power_up(), nrf24l01_set_as_rx(), nrf24l01_set_as_tx(), or nrf24l01_rx_standby_to_active(), since they are all taken care of for you. I am guessing, however, that you threw these function calls in when you were debugging and just didn’t take them out and you probably already knew what I just said. :wink:

I would also make a guess that right now the interrupt you are getting on the TX when you transmit a packet is MAX_RT rather than TX_DS. You might want to take a look at that, and if it is, then my suggestion should definitely get you going in the right way.

Hey im sorry, that is not the prob, i had them both turned off but i tried turning it on to see if that worked and it didnt, i must have left one on before i sent the code to you. I originally had them both turned off for AA. Thanks for the thought.

OK, I’ll look at the code this weekend and get back to you.

Brennen, this is going to be weird but i just got it working. this is a weird fix but i guess somehow the interrupt pin was the problem. i originally had it hardwired to the PORTM bit 6 and it was not working. I then removed the interrupt wire and it started working. The function for polling the interrupt must check for the bit in the status reg and not the actual IO pin. Is this correct. Well thanks for all your help with this you are the nrf guru.

For speed purposes, if you’re polling you generally check the pin first in a while loop. Then, once the pin is asserted, you check the status register. In the tutorials, I do it like this:

//for the TX
while(!(nrf24l01_irq_pin_active() && nrf24l01_irq_tx_ds_active()));
//for the RX
while(!(nrf24l01_irq_pin_active() && nrf24l01_irq_rx_dr_active()));

These loops simply wait on the IRQ pin to go active and then check to see if the appropriate internal interrupt is active.

If doing this doesn’t fix your problem when you hook the interrupt wire back up, my suggestion to you now is to watch the IRQ pin on the RX 24L01 with a multimeter to see if it in fact goes low. If the IRQ pin goes to ground when you receive a packet, then there’s something wrong with your microcontroller or how you have it set up. If the pin stays at VCC when you receive a packet, then you don’t have the RX_DR interrupt enabled in the CONFIG register.