ESB RX answer Ack to TX when TX periodical send data

Hello, 

I am using ESB to communicate between 2 devices. One works as TX and one works as RX. I start from esb_ptx and esb_prx example in nrf sdk 17.1 

My TX ack set up:

         nrf_esb_config.selective_auto_ack       = true;

         tx_payload.noack = fasle; 

My RX ack set up:

         nrf_esb_config.selective_auto_ack       = false;

In my project, I use TIMER1, TIMER3, SPIM3

My code running flow:

1. Tx use TIMER3 send the question to Rx each 1s. 

2. If Rx answer correctly, Stop TIMER3, Tx will begin getting the data from external peripheral device via SPIM3, data rate ~ 1.3Mbps. TX send the packets of 252 payload data to RX each 1.5ms (TIMER1)

My problem is "I can not send the ack from Rx to Tx when Tx always working with SPIM3 and TIMER1. 

Please suggest me the solution. 

Thank you very much. 

MinhDuc

  • Update: I solve my problem.

    Another question I hope I can get the suggestion here. 

    Most of the time, I want to send data without ack ( tx_payload.noack = true). 

    So I code like this 

    uint8_t count;

    while (true)

    {

             count++

             if (count > 250) {tx_payload.noack = false}

             else {tx_payload.noack = true}

    }

    By this way I always can send ack to Tx in some packet. 

    As I understand, In PRX side, I just write tx_payload.data to buffer then driver wait until the next Rx packet with ack expectation to send it back to PTX side. Am I right? 

    PTX set up:  selective_auto_ack = true; 

    PRX set up: selective_auto_ack = false; 

    But I am not success with this target. 

    Please suggest the solution. 

    Bests,

  • Hi!

    MinhDuc said:
    Update: I solve my problem.

    Great!

    MinhDuc said:
    But I am not success with this target. 

    What is not working? Never acked or always acked?

    MinhDuc said:
    PRX set up: selective_auto_ack = false; 

    If I recall correctly, if you set setting selective_auto_ack=false, then noack is ignored, and all packets are acked.

  • Hello Sigurd, 

    Thanks for your reply. 

    In PRX side, I set the selective_auto_ack = true and noack = true then it works. 

    Can you explain to me why noack = true affects the way PRX answer to PTX? As I understand, only PTX decide to expect ack from PRX or not. 

    And one more small question. If I connect external antenna to nrf52840-dk, SWF connector will automatically disconnect the signal from PCB antenna. Am I right? 

    Bests,

  • Hello Sigurd, 

    Just want to update. 

    I successfully set the tx_payload.noack state for Tx. 250 packet noack = true then 6 noack = false then ... 

    My current problem is "sometimes, PTX can not get the answer from PRX at packet with noack = false. Then my system stop" 

    How can I be sure that PTX always send the next packet even if PRX doesn't answer the packet with noack = false? 

    Bests,

  • MinhDuc said:
    Can you explain to me why noack = true affects the way PRX answer to PTX? As I understand, only PTX decide to expect ack from PRX or not. 

    When the PRX receives a packet that does not require an ACK, it does not send an ACK packet to the PTX

    MinhDuc said:
    And one more small question. If I connect external antenna to nrf52840-dk, SWF connector will automatically disconnect the signal from PCB antenna. Am I right? 

    Correct.

    MinhDuc said:
    How can I be sure that PTX always send the next packet even if PRX doesn't answer the packet with noack = false?

    You can set the desired retransmit count with the function nrf_esb_set_retransmit_count(). Try setting it to 0, if you don't want retransmit.

Related