bugfix: shut down nRF52820 and turn off LED when USB disconnected - #19
bugfix: shut down nRF52820 and turn off LED when USB disconnected#19m4rkw wants to merge 2 commits into
Conversation
|
wait there's a problem with this - closing for now |
|
The change fixes the sleep current issue but breaks ability to flash over USB. Investigating at the moment. |
|
Good to go now, was actually two issues:
The new enter_system_off() wrapper clears SEVONPEND before calling sys_poweroff(), letting WFE actually sleep. This is now tested and working, flashing still works and my sleep current is back at ~120 µA. |
Hi
I'm building an open-source vehicle tracker that uses the Connect Kit (see: https://l0destar.com) and believe I have identified a bug in the nRF52820 firmware.
My prototypes have a sleep current of 120 µA but I noticed that if I connect the USB interface and disconnect it again this jumps to around 2mA and the green LED on the Connect Kit stays on when it was off before. It seems that after VBUS removal the USB stack is disabled but the UART bridge peripheral keeps HFCLK running (~2mA), and the green status LED stays lit (~300µA). The chip stays in this state indefinitely.
This is a problem for my boards because they're intended to be hardwired into vehicles and so minimal sleep current is critical.
The patch adds set_all_leds_off() + sys_poweroff() to two paths in main.c: the USBD_MSG_VBUS_REMOVED callback, and a VBUS check at the top of main() for the case where the board boots without a USB cable. In SYSTEM OFF the nRF52820 draws ~0.3µA and wakes automatically on VBUS detect, rebooting with full functionality (CMSIS-DAP, UART bridge, shell, charger).
In my testing this completely resolves the issue, after unplugging the USB and letting the device go back to sleep its current is once again 120 µA. Reconnecting the cable still works normally.
Cheers,
Mark