About esb_ptx_ble & esb_prx_ble.

Can I copy the ESB code from SDK v3.3.0-preview3 into SDK v2.9.0, and then get the functionality in esb_ptx_ble & esb_prx_ble?

 

Is there any way to achieve it quickly?

Parents
  • Hello,

    Not sure I understand what problem you are trying to solve here, there should be ESB example projects for the nRF52840 in both the nRF Connect SDK releases you are referring to.

    Can I copy the ESB code from SDK v3.3.0-preview3 into SDK v2.9.0, and then get the functionality in esb_ptx_ble & esb_prx_ble?

    There may be some api changes, but for most part I would expect it should be pretty straight forward possible yes.

    Kenneth

  • Hello,

    Using nRF Connect SDK v3.3.0, one device runs esb_ptx_ble and broadcasts 2 packets of data every 5-10ms, with 15 devices running esb_prx_ble,esb rx interval 7300ms,rx window 15ms, 30 seconds is a receiving cycle, and failure to receive a packet of data within the cycle is considered a failure; After running 15 devices for a few days, occasionally one device experiences dozens of consecutive cycles without receiving data. Why is that?

    CONFIG_CONN_INTERVAL_MIN=990  //ms
    CONFIG_CONN_INTERVAL_MAX=1010
    CONFIG_CONN_LATENCY=6

    Is it phase entanglement? Or is it another question? How can I solve it?
  • Lets take a step back to the original question.

    You mention that you want to cherrypick a feature from NCS 3.3.0-preview3 into NCS 2.9.0. What stops you from migrating the project to 3.3.0? I know that Kenneth has said that he believes it is technically possible to do this, but I need to understand more about your project and what this feature is. Can you link to the specific PR with the feature you want to add?

    There might be an issue for the concurrent BLE + ESB in 3.3.0 (i.e the api you link to), which requires a different nrfxlib than the one used in 2.9.0. What is the version of nrfxlib in the 2.9.0 version of your project? 

    I'm not sure how you've added the features you're asking for from ESB/ MPSL to your 2.9.0 project. Could you explain this?

    Kind regards,
    Andreas

  • Hi AHaug,

    Thank you very much!

    I have completely abandoned the ESB+MPSL solution (my own code) in nRF Connect SDK v2.9.0.

    The solution I'm currently using is nRF Connect SDK v3.30's esb_ptx_ble (8dBm, 1Mbps, BLE peripheral) & esb_prx_ble (BLE peripheral).

     const struct esb_config config = {
            .protocol           = ESB_PROTOCOL_ESB_DPL,
            .mode               = APP_ESB_RX_MODE ? ESB_MODE_PRX : ESB_MODE_PTX,
            .event_handler      = event_handler,
            .bitrate            = ESB_BITRATE_1MBPS,
            .crc                = ESB_CRC_16BIT,
            .tx_output_power    = ESB_TX_POWER_8DBM,
            .retransmit_delay   = 600,
            .retransmit_count   = 0,
            .tx_mode            = ESB_TXMODE_AUTO,
            .payload_length     = CONFIG_ESB_MAX_PAYLOAD_LENGTH,
            .selective_auto_ack = true,
            .use_fast_ramp_up = IS_ENABLED(CONFIG_ESB_FAST_SWITCHING)
        };
    
    	err = esb_init(&config);

    I have completely abandoned the ESB+MPSL solution (my own code) in nRF Connect SDK v2.9.0.

    The solution I'm currently using is nRF Connect SDK v3.30's esb_ptx_ble (8dBm, 1Mbps, BLE peripheral) & esb_prx_ble (BLE peripheral).

    The latest test setup is: 1 esb_ptx_ble, 15 esb_prx_ble, all esb_prx_ble & esb_prx_ble peripherals connected to a single BLE central. PTX broadcasts 3 packets every 5-7ms; the PRX RX window is 8ms, the RX interval is 4000ms, and each 30-second interval is considered a receive cycle (approximately 7 RX window openings). Receiving one packet within a cycle is considered a successful reception. All RX devices are powered by the same regulated power supply (3.3V, 1A), and the devices are arranged in a star topology. The TX and RX devices are 40 meters apart, indoors, with no obstructions.

    For low power consumption, `esb_disable` and `esb_init` are called every RX cycle (8ms + 4000ms).

    An Arduino (connected to the computer via USB) is used to monitor whether an IO operation on the RX device flips within 30 seconds (a flip indicates at least one data packet has been received). After 7-10 days of operation, 1-2 RX devices may experience periods of 5-10 hours without receiving data.

    Kind regards,
    Leo Mo

  • Hello Leo,

    Andreas is currently tidyign up, and will be out of office for a couple of weeks, so he asked if I could look into your ticket. 

    One thing I struggle to understand:

    Leo Mo said:

    I have completely abandoned the ESB+MPSL solution (my own code) in nRF Connect SDK v2.9.0.

    The solution I'm currently using is nRF Connect SDK v3.30's esb_ptx_ble

    Does this mean you are using NCS (nRF Connect SDK) v3.3.0, or are you using v3.3.0's ESB inside your NCS v2.9.0?

    Leo Mo said:
    An Arduino (connected to the computer via USB) is used to monitor whether an IO operation on the RX device flips within 30 seconds (a flip indicates at least one data packet has been received). After 7-10 days of operation, 1-2 RX devices may experience periods of 5-10 hours without receiving data.

    Perhaps I just hasn't read the entire post properly, but you have got your setup working, but after a while, some devices experience a long time when they do not receive any messages (5-10 hours), and then they start picking up messages again? Or do you reset the devices, and then they start picking up messages again? Or what do you observe?

    Best regards,

    Edvin

  • Hi Edvin,

      Updated.

    I‘m using NCS v3.3.0.
    I did not restart the device.

    I observed the following:

    1. Sometimes, no data is received for 3-10 consecutive hours.

    2. Sometimes, no data is received for several minutes, then data is received again. There are no restart logs, so the program should be running normally, just not receiving data.

    Some err logs, It lasted for a long time.

    [00:08:07.359,802] <err> esb: Failed to initialize PPI
    [00:08:07.877,105] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:07.877,105] <err> esb: Failed to initialize PPI
    [00:08:08.404,510] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:08.404,510] <err> esb: Failed to initialize PPI
    [00:08:08.920,257] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:08.920,257] <err> esb: Failed to initialize PPI
    [00:08:09.294,311] <inf> visit: item count 7
    [00:08:09.441,040] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:09.441,040] <err> esb: Failed to initialize PPI
    [00:08:09.955,047] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:09.955,047] <err> esb: Failed to initialize PPI
    [00:08:10.481,353] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:10.481,353] <err> esb: Failed to initialize PPI
    [00:08:11.005,554] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:11.005,554] <err> esb: Failed to initialize PPI
    [00:08:11.526,580] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:11.526,580] <err> esb: Failed to initialize PPI
    [00:08:12.055,999] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:12.055,999] <err> esb: Failed to initialize PPI
    [00:08:12.577,209] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:12.577,209] <err> esb: Failed to initialize PPI
    [00:08:13.089,874] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:13.089,874] <err> esb: Failed to initialize PPI
    [00:08:13.616,943] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:13.616,943] <err> esb: Failed to initialize PPI
    [00:08:14.129,180] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:14.129,180] <err> esb: Failed to initialize PPI
    [00:08:14.646,057] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:14.646,057] <err> esb: Failed to initialize PPI
    [00:08:15.166,870] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:15.166,870] <err> esb: Failed to initialize PPI
    [00:08:15.679,351] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:15.679,351] <err> esb: Failed to initialize PPI
    [00:08:16.201,385] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:16.201,385] <err> esb: Failed to initialize PPI
    [00:08:16.727,294] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:16.727,294] <err> esb: Failed to initialize PPI
    [00:08:17.243,469] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:17.243,469] <err> esb: Failed to initialize PPI
    [00:08:17.766,143] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:17.766,143] <err> esb: Failed to initialize PPI
    [00:08:18.294,097] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:18.294,097] <err> esb: Failed to initialize PPI
    [00:08:18.806,640] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:18.806,640] <err> esb: Failed to initialize PPI
    [00:08:19.331,115] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:19.331,115] <err> esb: Failed to initialize PPI
    [00:08:19.845,520] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:19.845,520] <err> esb: Failed to initialize PPI
    [00:08:20.370,300] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:20.370,300] <err> esb: Failed to initialize PPI
    [00:08:20.886,169] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:20.886,169] <err> esb: Failed to initialize PPI
    [00:08:21.403,259] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:21.403,259] <err> esb: Failed to initialize PPI
    [00:08:21.927,001] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:21.927,001] <err> esb: Failed to initialize PPI
    [00:08:22.447,937] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:22.447,937] <err> esb: Failed to initialize PPI
    [00:08:22.963,806] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:22.963,806] <err> esb: Failed to initialize PPI
    [00:08:23.486,694] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:23.486,694] <err> esb: Failed to initialize PPI
    [00:08:24.000,610] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:24.000,610] <err> esb: Failed to initialize PPI
    [00:08:24.523,468] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:24.523,468] <err> esb: Failed to initialize PPI
    [00:08:25.044,036] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:25.044,036] <err> esb: Failed to initialize PPI
    [00:08:25.556,518] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:25.556,518] <err> esb: Failed to initialize PPI
    [00:08:26.068,267] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:26.068,267] <err> esb: Failed to initialize PPI
    [00:08:26.583,099] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:26.583,099] <err> esb: Failed to initialize PPI
    [00:08:27.108,886] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:27.108,886] <err> esb: Failed to initialize PPI
    [00:08:27.623,535] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:27.623,535] <err> esb: Failed to initialize PPI
    [00:08:28.144,683] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:28.144,683] <err> esb: Failed to initialize PPI
    [00:08:28.666,473] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:28.666,473] <err> esb: Failed to initialize PPI
    [00:08:29.189,544] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:29.189,544] <err> esb: Failed to initialize PPI
    [00:08:29.709,014] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:29.709,045] <err> esb: Failed to initialize PPI
    [00:08:30.222,534] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:30.222,534] <err> esb: Failed to initialize PPI
    [00:08:30.738,769] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:30.738,769] <err> esb: Failed to initialize PPI
    [00:08:31.256,713] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:31.256,713] <err> esb: Failed to initialize PPI
    [00:08:31.786,285] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:31.786,285] <err> esb: Failed to initialize PPI
    [00:08:32.313,720] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:32.313,720] <err> esb: Failed to initialize PPI
    [00:08:32.827,056] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:32.827,056] <err> esb: Failed to initialize PPI
    [00:08:33.340,270] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:33.340,270] <err> esb: Failed to initialize PPI
    [00:08:33.858,551] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:33.858,551] <err> esb: Failed to initialize PPI
    [00:08:34.373,291] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:34.373,291] <err> esb: Failed to initialize PPI
    [00:08:34.903,930] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:34.903,930] <err> esb: Failed to initialize PPI
    [00:08:35.420,349] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:35.420,349] <err> esb: Failed to initialize PPI
    [00:08:35.943,389] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:35.943,389] <err> esb: Failed to initialize PPI
    [00:08:36.465,728] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:36.465,728] <err> esb: Failed to initialize PPI
    [00:08:36.982,208] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:36.982,208] <err> esb: Failed to initialize PPI
    [00:08:37.508,148] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:37.508,148] <err> esb: Failed to initialize PPI
    [00:08:38.036,590] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:38.036,590] <err> esb: Failed to initialize PPI
    [00:08:38.551,696] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:38.551,696] <err> esb: Failed to initialize PPI
    [00:08:39.066,864] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:39.066,864] <err> esb: Failed to initialize PPI
    [00:08:39.595,550] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:39.595,550] <err> esb: Failed to initialize PPI
    [00:08:40.109,100] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:40.109,100] <err> esb: Failed to initialize PPI
    [00:08:40.637,145] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:40.637,145] <err> esb: Failed to initialize PPI
    [00:08:41.165,374] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:41.165,374] <err> esb: Failed to initialize PPI
    [00:08:41.683,441] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:41.683,441] <err> esb: Failed to initialize PPI
    [00:08:42.196,624] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:42.196,624] <err> esb: Failed to initialize PPI
    [00:08:42.718,444] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:42.718,444] <err> esb: Failed to initialize PPI
    [00:08:43.239,837] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:43.239,837] <err> esb: Failed to initialize PPI
    [00:08:43.759,979] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:43.759,979] <err> esb: Failed to initialize PPI
    [00:08:44.286,102] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:44.286,102] <err> esb: Failed to initialize PPI
    [00:08:44.811,187] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:44.811,187] <err> esb: Failed to initialize PPI
    [00:08:45.327,331] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:45.327,331] <err> esb: Failed to initialize PPI
    [00:08:45.842,529] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:45.842,529] <err> esb: Failed to initialize PPI
    [00:08:46.357,635] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:46.357,635] <err> esb: Failed to initialize PPI
    [00:08:46.869,476] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:46.869,476] <err> esb: Failed to initialize PPI
    [00:08:47.381,958] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:47.381,958] <err> esb: Failed to initialize PPI
    [00:08:47.893,585] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:47.893,585] <err> esb: Failed to initialize PPI
    [00:08:48.423,583] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:48.423,583] <err> esb: Failed to initialize PPI
    [00:08:48.937,866] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:48.937,866] <err> esb: Failed to initialize PPI
    [00:08:49.456,359] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:49.456,359] <err> esb: Failed to initialize PPI
    [00:08:49.975,097] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:49.975,097] <err> esb: Failed to initialize PPI
    [00:08:50.494,750] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:50.494,750] <err> esb: Failed to initialize PPI
    [00:08:51.012,207] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:51.012,207] <err> esb: Failed to initialize PPI
    [00:08:51.528,533] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:51.528,533] <err> esb: Failed to initialize PPI
    [00:08:52.042,053] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:52.042,053] <err> esb: Failed to initialize PPI
    [00:08:52.560,394] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:52.560,394] <err> esb: Failed to initialize PPI
    [00:08:53.079,833] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:53.079,833] <err> esb: Failed to initialize PPI
    [00:08:53.592,956] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:53.592,987] <err> esb: Failed to initialize PPI
    [00:08:54.115,539] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:54.115,539] <err> esb: Failed to initialize PPI
    [00:08:54.633,605] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:54.633,636] <err> esb: Failed to initialize PPI
    [00:08:55.162,902] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:55.162,902] <err> esb: Failed to initialize PPI
    [00:08:55.679,931] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:55.679,931] <err> esb: Failed to initialize PPI
    [00:08:56.198,089] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:56.198,089] <err> esb: Failed to initialize PPI
    [00:08:56.725,402] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:56.725,402] <err> esb: Failed to initialize PPI
    [00:08:57.238,677] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:57.238,677] <err> esb: Failed to initialize PPI
    [00:08:57.759,368] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:57.759,368] <err> esb: Failed to initialize PPI
    [00:08:58.270,812] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:58.270,812] <err> esb: Failed to initialize PPI
    [00:08:58.791,534] <err> esb: gppi_channel_alloc failed with: -12
    
    [00:08:58.791,534] <err> esb: Failed to initialize PPI
    [00:08:59.316,497] <err> esb: gppi_channel_alloc failed with: -12

    esb_ppi.c

    /*
     * Copyright (c) 2022 Nordic Semiconductor ASA
     *
     * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
     */
    
    #include <hal/nrf_egu.h>
    #include <hal/nrf_radio.h>
    #include <hal/nrf_timer.h>
    #include <hal/nrf_ppi.h>
    #include <helpers/nrfx_gppi.h>
    
    #include <zephyr/logging/log.h>
    
    #include "esb_peripherals.h"
    #include "esb_ppi_api.h"
    
    LOG_MODULE_DECLARE(esb, CONFIG_ESB_LOG_LEVEL);
    
    static nrf_ppi_channel_t radio_address_timer_stop;
    static nrf_ppi_channel_t timer_compare0_radio_disable;
    static nrf_ppi_channel_t timer_compare1_radio_txen;
    static nrf_ppi_channel_t egu_ramp_up;
    static nrf_ppi_channel_t egu_timer_start;
    static nrf_ppi_channel_t disabled_egu;
    static nrf_ppi_channel_t radio_end_timer_start;
    
    static nrf_ppi_channel_group_t ramp_up_ppi_group;
    
    void esb_ppi_for_fem_set(bool capture_timer)
    {
    	uint32_t egu_event = nrf_egu_event_address_get(ESB_EGU, ESB_EGU_EVENT);
    	uint32_t timer_task = nrf_timer_task_address_get(ESB_NRF_TIMER_INSTANCE,
    							 NRF_TIMER_TASK_START);
    	uint32_t capture_task =
    		nrf_timer_task_address_get(ESB_NRF_TIMER_INSTANCE, NRF_TIMER_TASK_CAPTURE1);
    
    	nrf_ppi_channel_endpoint_setup(NRF_PPI, egu_timer_start, egu_event, timer_task);
    	if (capture_timer) {
    		nrf_ppi_fork_endpoint_setup(NRF_PPI, egu_timer_start, capture_task);
    	}
    
    	nrf_ppi_channel_enable(NRF_PPI, egu_timer_start);
    }
    
    void esb_ppi_for_fem_clear(void)
    {
    	nrf_ppi_channel_disable(NRF_PPI, egu_timer_start);
    	nrf_ppi_channel_endpoint_setup(NRF_PPI, egu_timer_start, 0, 0);
    	nrf_ppi_fork_endpoint_setup(NRF_PPI, egu_timer_start, 0);
    }
    
    void esb_ppi_for_txrx_set(bool rx, bool timer_start)
    {
    	uint32_t channels_mask;
    	uint32_t egu_event = nrf_egu_event_address_get(ESB_EGU, ESB_EGU_EVENT);
    	uint32_t egu_task = nrf_egu_task_address_get(ESB_EGU, ESB_EGU_TASK);
    	uint32_t group_disable_task =
    			nrf_ppi_task_group_disable_address_get(NRF_PPI, ramp_up_ppi_group);
    	uint32_t radio_en_task = nrf_radio_task_address_get(NRF_RADIO,
    						rx ? NRF_RADIO_TASK_RXEN : NRF_RADIO_TASK_TXEN);
    	uint32_t radio_disabled_event = nrf_radio_event_address_get(NRF_RADIO,
    						NRF_RADIO_EVENT_DISABLED);
    	uint32_t timer_task = nrf_timer_task_address_get(ESB_NRF_TIMER_INSTANCE,
    							 NRF_TIMER_TASK_START);
    
    	nrf_egu_event_clear(ESB_EGU, ESB_EGU_EVENT);
    	nrf_ppi_channel_and_fork_endpoint_setup(NRF_PPI, egu_ramp_up, egu_event, radio_en_task,
    						group_disable_task);
    	nrf_ppi_channel_endpoint_setup(NRF_PPI, disabled_egu, radio_disabled_event, egu_task);
    
    	channels_mask = BIT(egu_ramp_up) | BIT(disabled_egu);
    
    	if (timer_start) {
    		nrf_ppi_channel_endpoint_setup(NRF_PPI, egu_timer_start, egu_event, timer_task);
    		channels_mask |= BIT(egu_timer_start);
    	}
    
    	nrf_ppi_channel_include_in_group(NRF_PPI, egu_ramp_up, ramp_up_ppi_group);
    	nrf_ppi_channels_enable(NRF_PPI, channels_mask);
    }
    
    void esb_ppi_for_txrx_clear(bool rx, bool timer_start)
    {
    	ARG_UNUSED(rx);
    
    	uint32_t channels_mask = (BIT(egu_ramp_up) | BIT(disabled_egu));
    
    
    	if (timer_start) {
    		channels_mask |= BIT(egu_timer_start);
    	}
    
    	nrf_ppi_channels_disable(NRF_PPI, channels_mask);
    
    	nrf_ppi_channel_and_fork_endpoint_setup(NRF_PPI, egu_ramp_up, 0, 0, 0);
    	nrf_ppi_channel_endpoint_setup(NRF_PPI, disabled_egu, 0, 0);
    
    	if (timer_start) {
    		nrf_ppi_channel_endpoint_setup(NRF_PPI, egu_timer_start, 0, 0);
    	}
    
    	nrf_ppi_channel_remove_from_group(NRF_PPI, egu_ramp_up, ramp_up_ppi_group);
    }
    
    void esb_ppi_for_retransmission_set(void)
    {
    	uint32_t channels_mask;
    
    	uint32_t egu_task = nrf_egu_task_address_get(ESB_EGU, ESB_EGU_TASK);
    	uint32_t radio_disabled_event = nrf_radio_event_address_get(NRF_RADIO,
    						NRF_RADIO_EVENT_DISABLED);
    	nrf_egu_event_clear(ESB_EGU, ESB_EGU_EVENT);
    	nrf_ppi_channel_endpoint_setup(NRF_PPI, disabled_egu, radio_disabled_event, egu_task);
    
    	nrf_ppi_channel_endpoint_setup(NRF_PPI, timer_compare1_radio_txen,
    		nrf_timer_event_address_get(ESB_NRF_TIMER_INSTANCE, NRF_TIMER_EVENT_COMPARE1),
    		nrf_radio_task_address_get(NRF_RADIO, NRF_RADIO_TASK_TXEN));
    
    	channels_mask = BIT(disabled_egu) | BIT(timer_compare1_radio_txen);
    
    	nrf_ppi_channels_enable(NRF_PPI, channels_mask);
    }
    
    void esb_ppi_for_retransmission_clear(void)
    {
    	uint32_t channels_mask;
    
    	channels_mask = (BIT(disabled_egu) |
    			 BIT(timer_compare1_radio_txen));
    
    	nrf_ppi_channels_disable(NRF_PPI, channels_mask);
    
    	nrf_ppi_channel_endpoint_setup(NRF_PPI, disabled_egu, 0, 0);
    	nrf_ppi_channel_endpoint_setup(NRF_PPI, timer_compare1_radio_txen, 0, 0);
    }
    
    void esb_ppi_for_wait_for_ack_set(void)
    {
    	uint32_t ppi_channels_mask;
    
    	nrf_ppi_channel_endpoint_setup(NRF_PPI, radio_address_timer_stop,
    		nrf_radio_event_address_get(NRF_RADIO, NRF_RADIO_EVENT_ADDRESS),
    		nrf_timer_task_address_get(ESB_NRF_TIMER_INSTANCE, NRF_TIMER_TASK_SHUTDOWN));
    
    	nrf_ppi_channel_endpoint_setup(NRF_PPI, timer_compare0_radio_disable,
    		nrf_timer_event_address_get(ESB_NRF_TIMER_INSTANCE, NRF_TIMER_EVENT_COMPARE0),
    		nrf_radio_task_address_get(NRF_RADIO, NRF_RADIO_TASK_DISABLE));
    
    	ppi_channels_mask = (BIT(radio_address_timer_stop) |
    			     BIT(timer_compare0_radio_disable));
    
    	nrf_ppi_channels_enable(NRF_PPI, ppi_channels_mask);
    }
    
    void esb_ppi_for_wait_for_ack_clear(void)
    {
    	uint32_t ppi_channels_mask;
    
    	ppi_channels_mask = (BIT(radio_address_timer_stop) |
    			     BIT(timer_compare0_radio_disable));
    
    	nrf_ppi_channels_disable(NRF_PPI, ppi_channels_mask);
    
    	nrf_ppi_channel_endpoint_setup(NRF_PPI, radio_address_timer_stop, 0, 0);
    	nrf_ppi_channel_endpoint_setup(NRF_PPI, timer_compare0_radio_disable, 0, 0);
    }
    
    void esb_ppi_for_wait_for_rx_set(void)
    {
    	uint32_t ppi_channels_mask;
    
    	nrf_ppi_channel_endpoint_setup(NRF_PPI, radio_end_timer_start,
    		nrf_radio_event_address_get(NRF_RADIO, NRF_RADIO_EVENT_END),
    		nrf_timer_task_address_get(ESB_NRF_TIMER_INSTANCE, NRF_TIMER_TASK_START));
    
    	ppi_channels_mask = (BIT(radio_end_timer_start));
    
    	nrf_ppi_channels_enable(NRF_PPI, ppi_channels_mask);
    }
    
    void esb_ppi_for_wait_for_rx_clear(void)
    {
    	uint32_t ppi_channels_mask;
    
    	ppi_channels_mask = (BIT(radio_end_timer_start));
    
    	nrf_ppi_channels_disable(NRF_PPI, ppi_channels_mask);
    
    	nrf_ppi_channel_endpoint_setup(NRF_PPI, radio_end_timer_start, 0, 0);
    }
    
    int esb_ppi_init(void)
    {
    	int ch;
    	int err = -ENODEV;
    	nrf_ppi_channel_t *const channels[] = {
    		&egu_ramp_up,
    		&disabled_egu,
    		&egu_timer_start,
    		&radio_address_timer_stop,
    		&timer_compare0_radio_disable,
    		&timer_compare1_radio_txen,
    #if defined(CONFIG_ESB_NEVER_DISABLE_TX)
    		&radio_end_timer_start,
    #endif
    	};
    	size_t allocated = 0;
    
    	for (allocated = 0; allocated < ARRAY_SIZE(channels); allocated++) {
    		ch = nrfx_gppi_channel_alloc(0);
    		if (ch < 0) {
    			LOG_ERR("gppi_channel_alloc failed with: %d\n", ch);
    			err = -ENODEV;
    			goto error;
    		}
    		*channels[allocated] = (nrf_ppi_channel_t)ch;
    	}
    
    	ch = nrfx_gppi_group_channel_alloc(0);
    	if (ch < 0) {
    		LOG_ERR("gppi_group_alloc failed with: %d\n", ch);
    		err = ch;
    		goto error;
    	}
    	ramp_up_ppi_group = (nrf_ppi_channel_group_t)ch;
    
    	return 0;
    
    error:
    	/* Free the channels already allocated. */
    	for (size_t i = 0; i < allocated; i++) {
    		nrfx_gppi_channel_free(0, (uint8_t)*channels[i]);
    	}
    
    	return err;
    }
    
    uint32_t esb_ppi_radio_disabled_get(void)
    {
    	return nrf_radio_event_address_get(NRF_RADIO, NRF_RADIO_EVENT_DISABLED);
    }
    
    void esb_ppi_disable_all(void)
    {
    	uint32_t channels_mask = (BIT(egu_ramp_up) |
    				  BIT(disabled_egu) |
    				  BIT(egu_timer_start) |
    				  BIT(radio_address_timer_stop) |
    				  BIT(timer_compare0_radio_disable) |
    				  BIT(timer_compare1_radio_txen) |
    				  (IS_ENABLED(CONFIG_ESB_NEVER_DISABLE_TX) ?
    					BIT(radio_end_timer_start) : 0));
    
    	nrf_ppi_channels_disable(NRF_PPI, channels_mask);
    
    	/* Clear all PPI endpoints to fully disconnect peripherals */
    	nrf_ppi_channel_and_fork_endpoint_setup(NRF_PPI, egu_ramp_up, 0, 0, 0);
    	nrf_ppi_channel_endpoint_setup(NRF_PPI, disabled_egu, 0, 0);
    	nrf_ppi_channel_and_fork_endpoint_setup(NRF_PPI, egu_timer_start, 0, 0, 0);
    	nrf_ppi_channel_endpoint_setup(NRF_PPI, radio_address_timer_stop, 0, 0);
    	nrf_ppi_channel_endpoint_setup(NRF_PPI, timer_compare0_radio_disable, 0, 0);
    	nrf_ppi_channel_endpoint_setup(NRF_PPI, radio_end_timer_start, 0, 0);
    
    	if (IS_ENABLED(CONFIG_ESB_NEVER_DISABLE_TX)) {
    		nrf_ppi_channel_endpoint_setup(NRF_PPI, timer_compare1_radio_txen, 0, 0);
    	}
    
    	/* Remove channel from group */
    	nrf_ppi_channel_remove_from_group(NRF_PPI, egu_ramp_up, ramp_up_ppi_group);
    }
    
    void esb_ppi_deinit(void)
    {
    	nrfx_gppi_channel_free(0, (uint8_t)egu_ramp_up);
    	nrfx_gppi_channel_free(0, (uint8_t)disabled_egu);
    	nrfx_gppi_channel_free(0, (uint8_t)egu_timer_start);
    	nrfx_gppi_channel_free(0, (uint8_t)radio_address_timer_stop);
    	nrfx_gppi_channel_free(0, (uint8_t)timer_compare0_radio_disable);
    	nrfx_gppi_channel_free(0, (uint8_t)timer_compare1_radio_txen);
    	if (IS_ENABLED(CONFIG_ESB_NEVER_DISABLE_TX)) {
    		nrfx_gppi_channel_free(0, (uint8_t)radio_end_timer_start);
    	}
    
    	nrfx_gppi_group_channel_free(0, (uint8_t)ramp_up_ppi_group);
    }


    Best regards,

    Leo

  • Hello Leo,

    Are you able to replicate this issue on 2x nRF52840 DKs? If so, is it possible to upload an application that can reproduce the issue without any external components attached?

    Best regards,

    Edvin

Reply Children
Related