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

NRF52 DK - Dynamic payload(DPL) and static payload.

I have an NRF24LE1 transmitter using ESB. It is sending a static payload of 10 bytes every sec. The other configurations on the transmitter are: RF channel:2, CRC: 1 byte, DataRate: 1MBPS.

I am trying to understand the given example code for esb_prx for NRF52-DK in NRF5 SDK 11.0. which I am using as Receiver.

It seem dynamic payload length - DPL is used as a default configuration. Can I use dynamic payload to talk to my current transmitter which has static payload ? What is dynamic payload mean, does it mean I can send any number of bytes to the Receiver? If so, payload_length field of nrf_esb_config_t in Receiver become irrelevant in DPL mode.

On a side question about esb_ptx in NRF52-DK:

#define NRF_ESB_CREATE_PAYLOAD(_pipe, ...)                                                  \
        {.pipe = _pipe, .length = NUM_VA_ARGS(__VA_ARGS__), .data = {__VA_ARGS__}};         \
        STATIC_ASSERT(NUM_VA_ARGS(__VA_ARGS__) > 0 && NUM_VA_ARGS(__VA_ARGS__) <= 63)

static nrf_esb_payload_t        tx_payload = NRF_ESB_CREATE_PAYLOAD(0, 0x01, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00);

What will be the pipe number, length and data values using NRF_ESB_CREATE_PAYLOAD macro ? But nrf_esb_payload_t is defined as follows:

typedef struct
{
    uint8_t length;                             /**< Length of the packet. Should be equal or less than      
                                                        NRF_ESB_MAX_PAYLOAD_LENGTH. */
    uint8_t pipe;                                   /**< Pipe used for this payload. */
    int8_t  rssi;                                   /**< RSSI for received packet. */
    uint8_t noack;                                  /**< Flag indicating that this packet will not be 
                                                          acknowledged. */
    uint8_t pid;                                    /**< PID assigned during communication. */
    uint8_t data[NRF_ESB_MAX_PAYLOAD_LENGTH];  /**< The payload data. */
} nrf_esb_payload_t;

Does the macro fill all the fields of this structure, if so, what will be the values of each field in this example?

Thanks,

  • Hi,

    Dynamic payload means that payload length is configurable for every packet sent.

    In non-DPL mode every payload has to be of pre-determined length.

    I don't believe DPL <-> fixed payload length communication is possible.

    DPL is configured in the nrf_esb_config_t->protocol field, and can take the following values:

    NRF_ESB_PROTOCOL_ESB,      /*< Enhanced ShockBurst with fixed payload length.                                            */
    NRF_ESB_PROTOCOL_ESB_DPL   /*< Enhanced ShockBurst with dynamic payload length.      
    

    What you want to do is configure ESB to run in fixed packet length mode. I think this configuration should be suitable for your scenario:

    nrf_esb_config_t nrf_esb_config         = NRF_ESB_DEFAULT_CONFIG;
    nrf_esb_config.payload_length           = 10;
    nrf_esb_config.protocol                 = NRF_ESB_PROTOCOL_ESB; //No DPL
    nrf_esb_config.bitrate                  = NRF_ESB_BITRATE_1MBPS;
    nrf_esb_config.mode                     = NRF_ESB_MODE_PRX;
    nrf_esb_config.crc                      = NRF_ESB_CRC_8BIT // 1 byte CRC
    nrf_esb_config.event_handler            = nrf_esb_event_handler;
    nrf_esb_config.selective_auto_ack       = false;
    

    When using DPL the payload_length field in nrf_esb_config_t is ignored, and the length specified in the payload struct is used instead.

  • I think you are referring to nrf_esb_payload_t struct's length field, am i right? Can you give an example for a given DPL length value and the sent packet length value?

    Could you look into my second question about esb_tx as well if possible ?

    Thanks,

  • Yes, I was referring to nrf_esb_payload_t struct.

    Not sure what you mean by your second question. In DPL mode, setting nrf_esb_payload_t->length to eg 12 will result in a packet with payload length 12.

    I now see that the doc is unclear here:

    nrf_esb.h line 242: "Length of the packet. Should be equal or less than NRF_ESB_MAX_PAYLOAD_LENGTH."

    This should be:

    "Length of the payload. Should be equal or less than NRF_ESB_MAX_PAYLOAD_LENGTH."

    About the macro, it will only fill the fields data, length and pipe. The other fields will be set to zero according to C spec.

    Should use this as NRF_ESB_CREATE_PAYLOAD(pipe, payload_data)

    So NRF_ESB_CREATE_PAYLOAD(0, 0x0a, 0x0b, 0x0c) will give packet.length=3, packet.pipe=0 and packet.data= {0x0a, 0x0b, 0x0c}

  • In the esb_ptx code, it is given:

    nrf_esb_payload_t tx_payload = NRF_ESB_CREATE_PAYLOAD(0, 0x01, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00);

    It mean, pipe = 0; length = 8; data[8] = { 0x01, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00 }

    At line no: 149 of main.c, NRF_LOG_HEX_CHAR(tx_payload.data[1]). I think this line is displaying the character in HEX that is to be sent to the Receiver. Is it sending just 1 byte which is data[1]=0x00 instead of 8 byte payload here?

    In the esb_prx, payload_length is given as 8 at line 100 of main.c file. At line 70 of main.c: NRF_LOG_HEX_CHAR(rx_payload.data[1]); It seem to be receiving the same byte that is sent at the Transmitter?

    Thanks,

  • This example is always sending 8 byte payloads, but only data[1] is logged and used.

    And yes, it is correct that the receiver is receiving the same byte that is sent at the transmitter. Anything else would not be a very useful protocol :)

Related