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

esb RX can't change PID of payloads sent to TX

In a project using esb, with two nrf52832 devices configured as default, one as RX, one as TX, with dynamic payload, TX sending packets to RX can change the packet pid (and using a debugger I can see that the pid changes on every subsequent packet provided I have a command such as tx_payload.pid++ on every send). However this doesn't work for RX; even with the above command, packets I receive with TX from RX always have pid == 0. Is this intended behaviour? Should I not be changing pid in the TX program?

In the meantime I've switched to using the first byte of each packet to store a packet identifier, which lets TX request a packet from RX that it hasn't obtained during a transfer, but if I could do the same with the pid that would make things cleaner, and give me an extra byte to store things in.

  • Hello Adrien Rapeaux

    The PID of the packets is only changed on the TX side. The RX ACK PID should be the same as the TX PID used in the message it is answering. This is meant to help the TX confirm that the payload it received is in fact an answer to its previous message. Take a look at the packet format descriptions and transaction diagrams of the nRF24L01P product specification, sections 7.3 and 7.4 pages 28 and 45.

    What happens if you do not try to change the value of the ACK PID? Does it then mirror the PID from the transmitter?

    Best regards

    Jørn Frøysa

  • Hello Jorn and thanks for your answer. This is quite interesting; I had no idea this was how the nrf52832 devices worked with regards to pid - there is no mention of this in the esb user manual available on the knowledge centre. I will try this and get back to you. Best, Adrien

  • I believe the ESB for the nRF5x families should be compatible, so it should behave in the same way. I will look further into this, but I will probably not be able to get back to you until tomorrow.

  • I have spoken to a colleague and it turns out the TX side does not load the PID value from the payload buffer. If you go to nrf_esb.c, line 627 you will find the line

    if (rx_fifo_push_rfbuf((uint8_t)NRF_RADIO->TXADDRESS, 0))
    

    Try changing this to

    if (rx_fifo_push_rfbuf((uint8_t)NRF_RADIO->TXADDRESS, m_rx_payload_buffer[1]>>1))
    

    That should make the pid available in the rx_payload.pid in main.

Related