This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF24L01 Ack issue / tx giving max_rt error / PIC18F25K20

Hi,

I am having problem with setting up TX side of my project. It always giving me max_rt error if I am sending only once per cycle. 1 Cycle is every 30seconds. All working fine without ACK enabled, with ACK enabled all stops. Only few times I have managed to get rid of this error and it started transmitting and receiving, same code used and the only difference I have accidentally reapplied power to the radio module. Seen few topics already on the forums but answers mentioned there not helped me at all.

Power circuit is fine, with additional low pass filter, decoupling capacitors and etc,. The strange about this, that it transmits and receives ACK if I am transmitting more than once per cycle.

    for (a = 0; a < 2; a++)
    { 
        TransmitMessage2TheHub(); 
    }

But if I am transmitting only once it always sending MAX_RT error in response.

The code of transmission is here:

void Transmit_nRF24L01_TX( unsigned char *TX_Data )
{
unsigned char i, data, cmd;
unsigned char reply;
_asm clrwdt _endasm; 
SPI_CE = 0;
SPI_CSN = 0;
SPI_nRF24L01_Send_Read(0x00);                   // Read from CONFIG Register Address 0x00; R_REGISTER 000 00000 
SPI_nRF24L01_Send_Read(0xFF);                   // Read value from buffer
SPI_CSN = 1;  
Nop();Nop();Nop();Nop();
Nop();Nop();Nop();Nop();
Nop();Nop();Nop();Nop();     
SPI_CSN = 0;
SPI_nRF24L01_Send_Read(0x20);                   // Write to CONFIG Register Address 0x00; W_REGISTER 001 00000 
SPI_nRF24L01_Send_Read(0x0A);                   // Disable IRQ on TX & RX; Enable CRC; 1 Byte CRC scheme; Power Enable; Enable TX Mode 
SPI_CSN = 1; 
Nop();Nop();Nop();Nop();
Nop();Nop();Nop();Nop();
Nop();Nop();Nop();Nop();    
Nop();Nop();Nop();Nop();
Nop();Nop();Nop();Nop();
Nop();Nop();Nop();Nop();
SPI_CSN = 0;
SPI_nRF24L01_Send_Read(0xB0);                   // W_TX_PAYLOAD_NO ACK; Used in TX mode. Disables AUTOACK on this specific packet.
for (i = 0; i < RF_PAYLOAD; i++)
{
	SPI_nRF24L01_Send_Read(TX_Data[i]);
}
SPI_CSN = 1;
Delay10KTCYx(1);
SPI_CE = 1;
Delay10KTCYx(35);
SPI_CE = 0;
SPI_CSN = 0;
reply = SPI_nRF24L01_Send_Read(0x07);                   // Read from Address 0x07;
SPI_CSN = 1; 
Nop();Nop();Nop();Nop();
Nop();Nop();Nop();Nop();
Nop();Nop();Nop();Nop(); 
SPI_CSN = 0;
SPI_nRF24L01_Send_Read(0xE2);                   // FLUSH_RX - 1110 0010; Flush RX FIFO, used in RX mode
SPI_CSN = 1;   
Nop();Nop();Nop();Nop();
Nop();Nop();Nop();Nop();
Nop();Nop();Nop();Nop(); 
SPI_CSN = 0;
SPI_nRF24L01_Send_Read(0xE1);                   // FLUSH_TX - 1110 0001; Flush TX FIFO, used in TX mode 
SPI_CSN = 1;   
Nop();Nop();Nop();Nop();
Nop();Nop();Nop();Nop();
Nop();Nop();Nop();Nop();  
SPI_CSN = 0;
SPI_nRF24L01_Send_Read(0x07);                   // Read from Address 0x07;
SPI_CSN = 1; 
Nop();Nop();Nop();Nop();
Nop();Nop();Nop();Nop();
Nop();Nop();Nop();Nop();  
SPI_CSN = 0;
SPI_nRF24L01_Send_Read(0x27);                   // Write to STATUS Register Address 0x07; W_REGISTER 001 00111
SPI_nRF24L01_Send_Read(0x7E);                   // Clear RX FIFO bit; Clear TX FIFO bit; Clear MAX number of retransmits bit; RX FIFO EMPTY; Available locations in TX FIFO
SPI_CSN = 1;  
Nop();Nop();Nop();Nop();
Nop();Nop();Nop();Nop();
Nop();Nop();Nop();Nop(); 
SPI_CSN = 0;
SPI_nRF24L01_Send_Read(0x07);                    // Read from Address 0x07;
SPI_CSN = 1; 
Nop();Nop();Nop();Nop();
Nop();Nop();Nop();Nop();
Nop();Nop();Nop();Nop();    
SPI_CSN = 0;
SPI_nRF24L01_Send_Read(0x00);                   // Read from CONFIG Register Address 0x00; R_REGISTER 000 00000 
SPI_nRF24L01_Send_Read(0xFF);                   // Read value from buffer
SPI_CSN = 1;  
Nop();Nop();Nop();Nop();
Nop();Nop();Nop();Nop();
Nop();Nop();Nop();Nop();    
SPI_CSN = 0;
SPI_nRF24L01_Send_Read(0x20);                   // Write to CONFIG Register Address 0x00; W_REGISTER 001 00000 
SPI_nRF24L01_Send_Read(0x0A);                   // Disable  IRQ on TX& RX; Enable CRC; 1 Byte CRC scheme; Power Enable; Enable TX Mode 
SPI_CSN = 1; 
Nop();Nop();Nop();Nop();
Nop();Nop();Nop();Nop();
Nop();Nop();Nop();Nop(); 
Delay1KTCYx(3);
SPI_CE = 1;                               }//Transmit_nRF24L01_TX( unsigned char *TX_Data )

Thank you in advance!

Parents Reply Children
  • Yes, No is CE HIGH before sleep and LOW when in sleep and PWR_UP low. Not sure, might be. As the module is shielded I cannot check it, unless to open it. I will probably do it on Monday.

    If I am sending continuously, it works fine. And receives every-time I am sending even without changing the packet content.

  • Do you have full control of the code ? I would assume CE is controlled by the MCU ?

    What I'm saying is that if you enable the radio, send 1 packet, then disable and enable the radio and send the same packet, the RX will misunderstood that it's a re-transmission and ignore the packet.

    If you send packet continuously without disable and enable the radio, the PID will be flipped for each packet and then the RX can detect that they are new packets.

    If you want to send packets and disable then enable radio, you should add 1 more byte/bit into the payload and change that bit so that each packet would have different payload.

Related