Radio (BLE 1MBit mode) not receiving frames right after HFXO startup and stabilization

I am implementing a port for nRF52832 for our custom communication stack. Devices are time-synchronized, radio operates in destined time slots. During the radio inactivity period MCU should drain the lowest amount of energy possible.

Configuration overview:
A. LFXO always active, application is event-driven by RTC timer (perdiodic application tasks and stack maintenantce)
B. MCU and high frequency peripherals are clocked by HFRC internal oscillator (fast start-up and low power consumption, high accuracy not required)
C. HFXO is turned on only for the radio peripheral.
D. System ON, Low Power mode is active.

This scenario works fine:
1. MCU wakes up (RTC ISR), stack enables the HFXO, goes to sleep.
2. After a while MCU wakes up again (time neded for clock stabilization with sufficient margin). Stack makes sure the EVENTS_HFCLKSTARTED is set, which is always true. Otherwise it will wait.
3. Stack turns on radio transmisssion or listening. All works fine.

Here is the malfunctioning path -  MCU wake up, stack enables HFXO, waits for EVENTS_HFCLKSTARTED and immediately triggers TASK_RXEN.
Sample code snippet is provided below:

// turn on HFXO
if (!nrf_clock_hf_is_running(NRF_CLOCK_HFCLK_HIGH_ACCURACY)) {
     nrf_clock_task_trigger(NRF_CLOCK_TASK_HFCLKSTART);
}
// radio configuration by writing registers
// ....
// ....
// do something else (very fast routine)
// wait for clock
if (!nrf_clock_hf_is_running(NRF_CLOCK_HFCLK_HIGH_ACCURACY)) {
    nrf_clock_event_clear(NRF_CLOCK_EVENT_HFCLKSTARTED);
    nrf_clock_task_trigger(NRF_CLOCK_TASK_HFCLKSTART);
    while (!nrf_clock_event_check(NRF_CLOCK_EVENT_HFCLKSTARTED))
        ;
    // without this delay, radio does not receive packets (maybe clock is nor ready even if is indicated as started)
    for (volatile int i = 0; i < 1000; ++i) {
    }
}
nrf_radio_task_trigger(NRF_RADIO_TASK_RXEN);

Parents Reply Children
No Data
Related