example:ble_app_uart+ esb_timeslot
SDK17.1
Hi
Recently our product (PRX) received poor esb communication. I caught through sniffer that when PTX sends a message, our device keeps returning ack, which is why.
The following code deals with the initialization of the esb.
/** @brief Default legacy radio parameters. Identical to the nRF24Lxx defaults. */
#define NRF_ESB_LEGACY_CONFIG {.protocol = NRF_ESB_PROTOCOL_ESB, \
.mode = NRF_ESB_MODE_PTX, \
.event_handler = 0, \
.bitrate = NRF_ESB_BITRATE_2MBPS, \
.crc = NRF_ESB_CRC_8BIT, \
.tx_output_power = NRF_ESB_TX_POWER_0DBM, \
.retransmit_delay = 300, \
.retransmit_count = 1, \
.tx_mode = NRF_ESB_TXMODE_AUTO, \
.radio_irq_priority = 1, \
.event_irq_priority = 2, \
.payload_length = 32, \
.selective_auto_ack = false \
}
static nrf_esb_config_t nrf_esb_config = NRF_ESB_LEGACY_CONFIG;
uint32_t esb_timeslot_init(void)
{
void nrf_esb_event_handler(nrf_esb_evt_t const * p_event);
// m_evt_handler = evt_handler;
nrf_esb_config.protocol = NRF_ESB_PROTOCOL_ESB_DPL;
nrf_esb_config.selective_auto_ack = 0;
//nrf_esb_config.retransmit_delay = 250;
//nrf_esb_config.payload_length = 8;//6;
nrf_esb_config.bitrate = NRF_ESB_BITRATE_2MBPS;
nrf_esb_config.mode = NRF_ESB_MODE_PRX;
nrf_esb_config.event_handler = nrf_esb_event_handler;
nrf_esb_config.crc = NRF_ESB_CRC_16BIT;
nrf_esb_config.radio_irq_priority = 0;
nrf_esb_config.tx_output_power = NRF_ESB_TX_POWER_4DBM;
// Using three avilable interrupt handlers for interrupt level management
// These can be any available IRQ as we're not using any of the hardware,
// simply triggering them through software
NVIC_ClearPendingIRQ(TIMESLOT_END_IRQn);
NVIC_SetPriority(TIMESLOT_END_IRQn, 2);
NVIC_EnableIRQ(TIMESLOT_END_IRQn);
NVIC_ClearPendingIRQ(TIMESLOT_BEGIN_IRQn);
NVIC_SetPriority(TIMESLOT_BEGIN_IRQn, 2);
NVIC_EnableIRQ(TIMESLOT_BEGIN_IRQn);
return NRF_SUCCESS;
}
uint32_t esb_start_PRX(bool selective_auto_ack) { // need a return value due to "VERIFY_SUCCESS" did
uint32_t err_code;
if (m_state == LL_ESB_STATE_IDLE) {
#if 1 // suggestion from Nordic forum to fix "wrong pattern": power cycle RADIO before init
NRF_RADIO->POWER = 0;
NRF_RADIO->POWER;
NRF_RADIO->POWER = 1;
#endif
nrf_esb_config.mode = NRF_ESB_MODE_PRX;
nrf_esb_config.selective_auto_ack = false;
err_code = nrf_esb_init(&nrf_esb_config); APP_ERROR_CHECK(err_code);
LL_ESB__set_address();
err_code = nrf_esb_set_prefixes(addr_prefix, 8); APP_ERROR_CHECK(err_code);
}
nrf_esb_set_rf_channel(55);
CRITICAL_REGION_ENTER();
if (m_state != LL_ESB_STATE_RX)
{
/* No packets in the Tx FIFO: start reception */
err_code = nrf_esb_start_rx();
APP_ERROR_CHECK(err_code);
m_state = LL_ESB_STATE_RX;
}
CRITICAL_REGION_EXIT();
return NRF_SUCCESS;
}Best regard
Kenyon