Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic 071 with v0.2.54 when Bluetooth is enabled #331

Closed
martinwork opened this issue May 22, 2023 · 4 comments · Fixed by #334
Closed

Panic 071 with v0.2.54 when Bluetooth is enabled #331

martinwork opened this issue May 22, 2023 · 4 comments · Fixed by #334
Milestone

Comments

@martinwork
Copy link
Collaborator

To reproduce panic 071, download https://github.com/lancaster-university/microbit-v2-samples and unzip. Rename codal.json as codal.noble.json, and codal.ble.json as codal.json, then build. Drag MICROBIT.hex to micro:bit and see panic 071. Panic still appears after changing main.cpp so it only does uBit.init().

There is no panic if I checkout the 0.2.51 commits, or if MICROBIT_BLE_ENABLED is zero.

int main()
{
    uBit.init();
    release_fiber();
    return 0;
}
cd libraries\codal-microbit-v2
git fetch --tags
git checkout v0.2.51

cd ..\codal-core
git fetch --tags
git checkout 4b2b35e3b0db84d62a4cf3d3b582da66974793fb

cd ..\codal-nrf52
git fetch --tags
git checkout 5fa1d16d6de6bd2848ae776e3039ce6bcad4e3e1

cd ..\codal-microbit-nrf5sdk
git fetch --tags
git checkout ef4662e13875a7b03e7296d7ac24a2b4d231f323

cd ..\..

@martinwork martinwork changed the title Panic 071 with v0.2.52 when Bluetooth is enabled Panic 071 with v0.2.54 when Bluetooth is enabled May 22, 2023
@martinwork
Copy link
Collaborator Author

I'll try 0.2.52 and 0.2.53. I was thinking 0.2.52 was latest.

@martinwork
Copy link
Collaborator Author

v0.2.52 is OK, v0.2.53 sees panic 071.

@martinwork
Copy link
Collaborator Author

Removing this change gets rid of the panic in v0.2.53.

// Bring up the 64MHz external oscillator.

@martinwork
Copy link
Collaborator Author

martinwork commented May 23, 2023

@JohnVidler @finneyj
This avoids panic 071.

#if CONFIG_ENABLED(DEVICE_BLE) && CONFIG_ENABLED(MICROBIT_BLE_ENABLED)
    sd_clock_hfclk_request();
#else
    NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
    NRF_CLOCK->TASKS_HFCLKSTART = 1;
    while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0);
#endif

Not sure if it should wait on sd_clock_hfclk_is_running. Or if it should be inside bleManager.init, between enabling softdevice and starting advertising.

Note that HFCLK increases power consumption.

https://devzone.nordicsemi.com/f/nordic-q-a/46640/hfclk-start-and-usage
"The Softdevice will always start the HFXO before a RADIO event, and release it afterward to reduce the base current (e.g., advertisement event). The reason for this is that the RADIO requires an accurate clock source to transmit at the correct frequency. If you want the HFXO always on you can call sd_clock_hfclk_request() after enabling the Softdevice, but this will most likely increase the average power consumption."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants