Cohabitation between BLE and Proprietary/ShockBurst on SD140

Hello,

I've a working application on nRF52811 SDK / S140 running BLE. I need to extend it so that from time to time BLE switches off temporarily, to send a simple and short packet using the legacy Nordic protocol. This is to emulate a good old nRF24L01. After the packet has been transmitted, the system should back to BLE. The legacy packet needs no acknowledgement and there is no need to receive anything. So it should be very simple but I struggle having this packet emitted.

I had a look at the following posts without success so far:

-  How to time-share switch between BLE and 2.4G private protocol 

-  Using BLE and ESB (Enhanced Shockburst) simultaneously 

Here is a strip-down version of my code:

#include "nrf_esb.h"
...
#define TX_PWR                           RADIO_TXPOWER_TXPOWER_Pos4dBm
...
static nrf_esb_config_t nrf_esb_config = NRF_ESB_LEGACY_CONFIG;

...


advertising_stop();
NRF_LOG_INFO("Advertising stop")
// Disable SoftDevice
err_code = nrf_sdh_disable_request();
APP_ERROR_CHECK(err_code);

// Initialize ESB module or perform other tasks here
nrf_esb_config.retransmit_delay = 0;
nrf_esb_config.retransmit_count = 1;
nrf_esb_config.tx_output_power = TX_PWR;
nrf_esb_config.tx_mode = NRF_ESB_TXMODE_MANUAL_START;          
nrf_esb_config.selective_auto_ack = true;


err_code = nrf_esb_init(&nrf_esb_config);
APP_ERROR_CHECK(err_code);
NRF_LOG_INFO("ESB initialized")

err_code = nrf_esb_set_address_length(0x05);
APP_ERROR_CHECK(err_code);
NRF_LOG_INFO("Adr length set")

uint8_t base_addr_0[5] = {0x00, 0x00, 0x00, 0x00, 0x00};
APP_ERROR_CHECK(err_code);
err_code = nrf_esb_set_base_address_0(base_addr_0);
APP_ERROR_CHECK(err_code);
NRF_LOG_INFO("Base address set")

static nrf_esb_payload_t tx_payload = NRF_ESB_CREATE_PAYLOAD(0, 0x11, 0x22, 0x33, 0x44, 0x55);
tx_payload.noack = true;
//Protocol 0d51=0x33,
NRF_LOG_INFO("Payload prepared")

err_code = nrf_esb_set_rf_channel(0x05);
APP_ERROR_CHECK(err_code);
NRF_LOG_INFO("RF channel set to 0x05. Check...")

uint32_t channelreadout;
nrf_esb_get_rf_channel(&channelreadout);
NRF_LOG_INFO("read channel %d", channelreadout);

err_code = nrf_esb_write_payload(&tx_payload);
APP_ERROR_CHECK(err_code);
NRF_LOG_INFO("Payload set")

err_code = nrf_esb_start_tx();
APP_ERROR_CHECK(err_code);
NRF_LOG_INFO("TX started")
while (!nrf_esb_is_idle())
{
     // You can perform other tasks here while waiting for transmission to complete
}

The code runs down without error until the last line where it gets stuck in the while loop. I see no activity on a spectrum analyzer, meaning the packet is not emitted. (The hardware is good for sure, because the BLE part of the application works well)

With the debugger, I see that the status checked by nrf_esb_is_idle() is NRF_ESB_STATE_PTX_RX_ACK. This is strange because tx_payload.noack = true means that no acknowledge is expected.

My feeling is that the radio is not totally free to be used by the ESB library, the BLE stack still access it somehow, or that the ESB initialization is not complete.

Would it be mandatory to setup the pipes? It looks very complicated for what I need. Indeed I don't need all the bells and whistles of the ShockBurst. A very simple packet at fixed address, with fixed payload is sufficient.

Any help will be appreciated.

Parents
  • Hi Yves

    Most likely the issue here is that the external HF crystal is not enabled when you are using the ESB library. 

    The SoftDevice will start the HF crystal automatically, but you have to do this manually when using ESB (ideally the library should have handled this for you, but this was never implemented). 

    If you look at the ESB examples you can see how this is done. 

    If this is not the issue, and you start the HF crystal as needed, then just let me know and I will take a closer look. 

    Best regards
    Torbjørn

  • Hi Torbjorn,

    thanks a lot for the excellent support. That was it! I copy-pasted the clock_initialization() from "SDK\examples\peripheral\radio\transmitter\main.c" and called it after the nrf_sdh_disable_request(). Now I see the packet on the spectrum analyser!

    I just have an issue to restart the SoftDevice after the transmission: I tried both those line in different order wihout success:

    err_code = nrf_sdh_enable_request();
    APP_ERROR_CHECK(err_code);
    err_code = nrf_esb_disable();
    APP_ERROR_CHECK(err_code);

    I've this error: app: ERROR 4097 [Unknown error code]

    Maybe a full re-initialization is needed, setting device name, address and advertising init + start isn't it?

    Could you roughly describe the sequence needed to :

    - Switch off ESB

    - Re-enable the ble stack.

    Is there something particular that is needed to be done around the clock management in this sequence?

    Have a nice day

    Yves

Reply
  • Hi Torbjorn,

    thanks a lot for the excellent support. That was it! I copy-pasted the clock_initialization() from "SDK\examples\peripheral\radio\transmitter\main.c" and called it after the nrf_sdh_disable_request(). Now I see the packet on the spectrum analyser!

    I just have an issue to restart the SoftDevice after the transmission: I tried both those line in different order wihout success:

    err_code = nrf_sdh_enable_request();
    APP_ERROR_CHECK(err_code);
    err_code = nrf_esb_disable();
    APP_ERROR_CHECK(err_code);

    I've this error: app: ERROR 4097 [Unknown error code]

    Maybe a full re-initialization is needed, setting device name, address and advertising init + start isn't it?

    Could you roughly describe the sequence needed to :

    - Switch off ESB

    - Re-enable the ble stack.

    Is there something particular that is needed to be done around the clock management in this sequence?

    Have a nice day

    Yves

Children
Related