ESB "Hiccup"

I am currently working on a project in which I want to transmit audio wirelessly from one nRF chip to another. Currently I am using the nRF Dongle to act as the transmitter and a nRF-DK board as the receiver. I have finally gotten them to talk to each other through ESB, and the transmitter is currently sending a digital sine wave table out to the receiver which is then using SPI to interface with an external DAC. The problem lies in these "hiccups" that occur periodically, and while the frequency of the wave is something I can control, I can't seem to get rid of these hiccups. I am new to the Nordic development environment and I don't have much experience in the ESB protocol, and so I'm not sure if it's a hardware limitation, an acknowledgement issue, or something that I've overlooked in my code. At some point, the transmission will live in an SAADC callback function. That version works in terms of the signal path, but is experiencing the same problem that is outlined here. The problem is shown below, and here is my initialization of ESB, along with the transmission. Any help is greatly appreciated!

uint32_t esb_init( void )
{
    uint32_t err_code;
    uint8_t base_addr_0[4] = {0xE7, 0xE7, 0xE7, 0xE7};
    uint8_t base_addr_1[4] = {0xC2, 0xC2, 0xC2, 0xC2};
    uint8_t addr_prefix[8] = {0xE7, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8 };

    nrf_esb_config_t nrf_esb_config         = NRF_ESB_DEFAULT_CONFIG;
    nrf_esb_config.protocol                 = NRF_ESB_PROTOCOL_ESB_DPL;
    nrf_esb_config.retransmit_delay         = 100;
    nrf_esb_config.bitrate                  = NRF_ESB_BITRATE_2MBPS;
    nrf_esb_config.event_handler            = nrf_esb_event_handler;
    nrf_esb_config.mode                     = NRF_ESB_MODE_PTX;
    nrf_esb_config.selective_auto_ack       = true;
    nrf_esb_config.payload_length           = 2;
    nrf_esb_config.retransmit_count         = 1;

    err_code = nrf_esb_init(&nrf_esb_config);

    VERIFY_SUCCESS(err_code);

    err_code = nrf_esb_set_base_address_0(base_addr_0);
    VERIFY_SUCCESS(err_code);

    err_code = nrf_esb_set_base_address_1(base_addr_1);
    VERIFY_SUCCESS(err_code);

    err_code = nrf_esb_set_prefixes(addr_prefix, NRF_ESB_PIPE_COUNT);
    VERIFY_SUCCESS(err_code);

    return err_code;
}

int i = 0;

    while (true)
    {
        tx_payload.data[0] = SineWave[i] & 0xFF;
        tx_payload.data[1] = SineWave[i] >> 8;
        tx_payload.noack = true;
        nrf_esb_write_payload(&tx_payload);

        i++;

        if (i >= 80)
        {
            i = 0;
        }

        nrf_delay_ms(50);
    }

 

Parents
  • Hi 

    As a general rule I would suggest using longer packets, and a higher number of retransmits, to ensure more efficient and reliable communication. 

    Still, if you are only sending a packet every 50ms, and experiencing regular repeated interruptions, then it points to a more critical issue. 

    Are you logging the ESB callbacks on the TX side to see if you are receiving TX failed interrupts or not?

    Do you have any interrupts in the system running at the highest priority, other than the ESB library?
    The ESB library is not designed to allow other interrupt at priority 0, and unfortunately this is the default priority if you don't change it to something else. 

    Could you try to add a sequence counter to the ESB payload? 
    This could be as simple as an 8-bit counter that you increment for every packet. 

    Then it is very easy to spot reception issues on the RX side, such as dropped or repeated packets. 

    Best regards
    Torbjørn

  • Thank you for your quick response! 

    I have tried to initialize the logger, but for some reason, I cannot seem to get it working on this project (only in other project files). I have tried adding a sample counter to the payload, but since I cannot print it out to the log, I cannot see the sample number in real time. 

    For the transmitter, is it possible to use the log even though it is just the nRF Dongle? I figured I would only be able to use it on the DK board for the reception side. 

    On the reception side, currently the SPI interrupt priority is at 0, and the ESB is at default, so I will go ahead and change that. 

  • Hi 

    Getting logging working through USB on the nRF52840 dongle is possible, but it is not straight forward unfortunately, and it is not natively supported in the SDK. 

    Jimmy Wong wrote a blog about this a while ago: 
    https://jimmywongiot.com/2019/10/25/how-to-use-the-nrf52840-dongle-pca10059-as-development-board/

    You could try following that blog, but be aware that the software examples he uses are quite old at this point (made for v15 of the SDK). 

    It would be easier if you have a J-Link programmer or an nRF52840DK available, but this requires additional hardware that you might not have access to.

    A third option is to output UART logging on one of the available pins on the dongle, and connect it to some kind of serial to USB converter, but in this case you need to ensure that the voltages are compatible. 

    What about logging on the RX side? 
    Have you not been able to get this working either?
    For the DK's there are several options for handling logging, such as RTT or UART. 

    Regarding the sample sine wave, could you try to send a simple counter value instead?
    This should look like a sawtooth if you analyze it like an audio sample, and might be a more intuitive way to figure out what is happening with the signal.  

    Best regards
    Torbjørn

  • I have not been able to get logging functioning on the RX side. Even when I have enabled logging in the config file for both UART as well as RTT. Is there something else I need to enable?

    I will try the counter approach and update with any findings. 

  • Hi 

    Any chance you could send me your code so I can have a look at it? 

    If you do please just zip the project folder, including project and source files (you might want to remove temporary build files though). 

    Then I can take a look at it here and try to figure out why logging isn't working, and also if I can spot any other issues that could affect reliability. 

    If you don't want to share your code in a public case just let me know, and I will make the case private. 

    I would also need to know which SDK version you are using. 

    Best regards
    Torbjørn

Reply
  • Hi 

    Any chance you could send me your code so I can have a look at it? 

    If you do please just zip the project folder, including project and source files (you might want to remove temporary build files though). 

    Then I can take a look at it here and try to figure out why logging isn't working, and also if I can spot any other issues that could affect reliability. 

    If you don't want to share your code in a public case just let me know, and I will make the case private. 

    I would also need to know which SDK version you are using. 

    Best regards
    Torbjørn

Children
Related