This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

how to set nRF24 PTX with ack payload

Hi,Nordic now, nRF52 as PRX, nRX24 as PTX.

App process

  1. PTX send data via ESB, PRX can receive

    But nRF24 can not receive event HAL_NRF_TX_DS, why?

  2. Then nRF52 send payload, but nRF24 can not receive

If nRF52 as PTX, nRF24 as PRX, it's OK.

Could you tell me how to set nRF24?

Thanks.

nrf52_esb_prx.rar

nRF24_usb_hid_rf.rar

  • nRF52 configuration:

    err_code = esb_init();
    APP_ERROR_CHECK(err_code);
    err_code = nrf_esb_start_rx();
    APP_ERROR_CHECK(err_code);
    
    void nrf_esb_event_handler(nrf_esb_evt_t const * p_event)
    {
        case NRF_ESB_EVENT_RX_RECEIVED:
    NRF_LOG_DEBUG("RX RECEIVED EVENT\r\n");
        if (nrf_esb_read_rx_payload(&rx_payload) == NRF_SUCCESS)
        {
          tx_payload.noack = false;
          if (nrf_esb_write_payload(&tx_payload) == NRF_SUCCESS)
          {}
        }
    }
    

    nRF24 Configuration:

    static void rf_config(void)
    {
        hal_nrf_get_clear_irq_flags();
        hal_nrf_flush_rx();
        hal_nrf_flush_tx();
    
        hal_nrf_enable_ack_payload(true);
        hal_nrf_enable_dynamic_payload(true);
        hal_nrf_setup_dynamic_payload(0xff);
    
       hal_nrf_set_power_mode(HAL_NRF_PWR_UP);
       hal_nrf_set_operation_mode(HAL_NRF_PTX);
       CE_LOW();
    }
    
    static void rf_send_buffer()
    {
      CE_LOW();
      hal_nrf_set_operation_mode(HAL_NRF_PTX);
      transmitted = false;
      hal_nrf_write_tx_payload(usb_out_buf, 32);
      CE_PULSE();
      radio_busy = true;
      while(radio_busy);
    }
    
    static void rf_receive_ms(uint16_t time_ms)
    {
      packet_received = false;
      hal_nrf_set_operation_mode(HAL_NRF_PRX);
      CE_HIGH();
      while(time_ms--)
      {
        if (packet_received)
          break;
        delay_ms(1);
      }
      CE_LOW();
    }
    

    on main()

       while(true)
       {
         rf_send_buffer();
         if (transmitted)
         {
           rf_receive_ms(10);
         }
       }
    

    Plz help me check.

  • Hi Chaw,

    Are you sure it's correct, in your code it's nRF52 works as PRX.

    Also please upload the full project.

    Have you made sure you use NRF_ESB_LEGACY_CONFIG instead of NRF_ESB_DEFAULT_CONFIG in esb_init() ?

  • Hi,I have upload full project, nRF52 and nRF24

  • @Chaw: thanks, but could you let me know exactly in which mode do you have the issue ? What I can see in the code is that the NRF52 is in PRX mode, this is the mode you said works fine:

    1. nRF24 as PTX, nRF52 as PRX 2. nRF24 send data to nRF52, it work well.

    Why should I look at the code ?

    Please be aware, you don't have to switch the PTX to PRX mode to be able to receive ack payload ! You simply enable ACK payload in the configuration and you should be able to receive ack payload. Please check out the Figure 11 in nRF24LU1P Product Spec you can find the mode switching is done automatically, you only have to wait for the TX_DS and RX_DR IRQ return when there is Ack payload return.

    Note that you need to prepare data in the TX buffer on the PRX side so that the PRX can send something back in the ack payload. I don't see that in your code in the application, which data you are expecting from the NRF5 to send back to the nRF24 ?

  • sorry, my upload project has some problem. nRF24 as PTX, nRF52 as PRX. It's right. My app step is this:

    1. PTX(nRF24) send data to PRX(nRF52), PRX(nRF52) can receive data, it's OK
    2. Then PRX(nRF52) send ACK payload to PTX(nRF24), it's not OK. after step 1, I change nRF24 from PTX mode to PRX mode, you said, I do not need, I will try. But it still do not work. Maybe when PRX(nRF52) send ACK payload, I use wrong method, now I use

    tx_payload.noack = true; nrf_esb_write_payload(&tx_payload);

    from PRX(nRF52), I see TX success log, but same time, PTX(nRF24) do not receive this ACK.

    Could you check?

Related