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

NRF24L01+ TX and RX Timing Issue ?


Hi all.

I use a STM32F103C8T6 as a transmitter and an Arduino Uno as a receiver.
I cannot receive the value I am interested in. I have changed delay durations after each send and also CE pulse. I sometimes get it worked on spec by playing with delay durations.
To exemplify, I add a 200ms delay after TX function is executed and receiver receives very well then I disconnect the receiver and then when I connect it again, it receives nothing but zero.
Very similar situations occur when I play with CE pulse duration.
I cannot get it worked neither with auto-ack nor simple rx-tx operation.
I would like to mention that when I change roles (TX device is Arduino and RX device is STM) everything works perfectly.

I've checked STM32 by a logic analyzer to see whether the payload is filled properly or not and could not see any problem.
After I fill the payload, I check FIFO_STATUS register and everything is fine.
After I apply a pulse for a certain duration, I check STATUS register and can see that TX_DS bit is set.

I've discovered that just applying 10us pulse on CE may not be enough. It can take up to 500us.
Then decided to set CE pin high until TX_DS bit is set, but this method also did not work.

Here's the code for STM32F103:

void TX_Mode(uint8_t data2send)
{
	
	Flush_TX();
	CleanInterrupts();
	SetPRIM(PRIM_TX); //set as transmitter
		
	csn_low(); //CSN=0
	HAL_SPI_Transmit(&hspi2, &COMD_W_TX_PAYLOAD, 1,150); //send command to write to payload
	HAL_SPI_TransmitReceive(&hspi2, &data2send, &dummy, 1, 150); // fill the payload
	while(HAL_SPI_GetState(&hspi2) != HAL_SPI_STATE_READY);
	csn_high();
	

	
	ChipEnable_high();
	while( !(TXDS_Bit_Is_Set() )); //wait until payload is sent
	ChipEnable_low();
	
}

Parents
  • Hi,

    Is this a nordic library?

    If you look at one of our examples. e.g. nRFgo SDK 2.3.0.10040\source_code\projects\nrfgo_sdk\enhanced_shockburst_examples\ptx\Keil\nRF24le1

    You can see that we do something like this:

        // Write payload to radio TX FIFO
        hal_nrf_write_tx_payload(payload, 3U);
    
        // Toggle radio CE signal to start transmission
        CE_PULSE();
    
        radio_busy = true;
        // Wait for radio operation to finish
        while (radio_busy)
        {
        }

    Then in the ISR we do this:

    NRF_ISR()
    {
      uint8_t irq_flags;
    
      // Read and clear IRQ flags from radio
      irq_flags = hal_nrf_get_clear_irq_flags();
    
      switch(irq_flags)
      {
        // Transmission success
        case (1 << (uint8_t)HAL_NRF_TX_DS):
          radio_busy = false;
          // Data has been sent
          break;
        // Transmission failed (maximum re-transmits)
        case (1 << (uint8_t)HAL_NRF_MAX_RT):
          // When a MAX_RT interrupt occurs the TX payload will not be removed from the TX FIFO.
          // If the packet is to be discarded this must be done manually by flushing the TX FIFO.
          // Alternatively, CE_PULSE() can be called re-starting transmission of the payload.
          // (Will only be possible after the radio irq flags are cleared)
          hal_nrf_flush_tx();
          radio_busy = false;
          break;
        default:
          break;
      }

  • Hi. It is not a nordic lib. The library is prepared by me. 

    Could you please share the link of the example ?

Reply Children
Related