Request: Variant of clocks_init() that allows selectively enabling PLLs (and/or clocks) #1746
Labels
No labels
bazel
bluetooth
board settings
boot_stage2
bug
build
c++
can't reproduce
clang
clib-interface
cmsis
code cleanliness
code size
compiler version issues
cyw43_driver
debug
discussion
documentation
duplicate
dynamic_clock
elf2uf2
enhancement
errata
filesystem
flash layout
floating point
FreeRTOS
hardware_adc
hardware_claim
hardware_clocks
hardware_dma
hardware_exception
hardware_flash
hardware_gpio
hardware_i2c
hardware_irq
hardware_pio
hardware_pwm
hardware_rcp
hardware_rtc
hardware_spi
hardware_sync
hardware_uart
hardware_vreg
hardware_watchdog
hardware_xosc
help wanted
host
IAR
installation
invalid
linker scripts
lto
lwip
mbedtls
missing API
needs reporter detail
networking
newlib
newlib-multicore
non-c
non-cmake
non-gcc
openocd
orphan PR
OS integration
pico_async_context
pico_base
pico_binary_info
pico_flash
picolibc
pico_lwip
pico_malloc
pico_multicore
pico_printf
pico_runtime
pico_stdio
pico_stdio_usb
pico_sync
pico_time
pico_util
pioasm
port
question
review
review2
rtos interop
runtime init
static library
svd
test
tinyusb
vscode
wifi integration
wontfix
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-raspberrypi/pico-sdk#1746
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This is a use case we found in MicroPython, as we added support for retaining the USB peripheral clock in SLEEP mode.
The mp_machine_lightsleep function selectively disables a range of clocks and PLLs, goes to SLEEP mode, and then calls pico-sdk
clocks_init()on wake to restore them. Calling the init function again is useful as it saves a bunch of binary size and removes the potential for a mismatch between the clock config "on init" and "on wake".However, we recently added support for keeping the USB peripheral clock and PLL enabled in sleep (XOSC also enabled). This works most of the time, but intermittently the USB peripheral would hang on wake as
clocks_init()is re-enabling the USB PLL and presumably this can glitch the USB clock.Our solution for now has been to copy
clocks_init()as void clocks_init_optional_usb(bool init_usb). The new argument can be false if the USB PLL is already running. See https://github.com/micropython/micropython/pull/15301 for more details.However, wanted to raise it here as a request. Perhaps there is a broader use for pico-sdk API to have something like
clocks_init_flags(unsigned PLL_FLAGS)function where the defaultclocks_init()becomesclocks_init_flags(ALL_PLL_FLAGS)(or similar).Sounds like this might be related to #1668 and #1672 ?
@lurch It is, I'm sorry I should have searched first. Feel free to close in favour of either of those.
EDIT: Actually, not quite - that patch as-written doesn't meet our immediate needs as it doesn't cover PLL_USB (only PLL_SYS). But I think that approach could be extended pretty easily to also cover PLL_USB.