Add cyw43_spi_set_clock_divisor() to allow CYW43 to work with over/underclocked RP2040 #1521
No reviewers
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!1521
Loading…
Reference in a new issue
No description provided.
Delete branch "20231012_ai6aj_cyw43_spi_patch"
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?
Fixes issues #1297 and #1392
This is a straightforward patch to allow the Pico W to work with the WiFi/BT module when heavily over- or underclocked. The previous code had the SPI clock divisor hardcoded to a value of 2, this allows the programmer to explicitly set it to any value they'd like.
In both instances, simply set the desired clock divisor PRIOR to initializing the WiFi module:
or
I guess this is similar-but-different to #1499 ?
It's similar to #1499, but having an actual SDK call means that Micropython users (and Lua, JS, etc.) aren't stuck with whatever SPI clock speed was chosen at compile time. That patch looks like it's entirely compatible with this one and I rather like the option to do it either way.
@ -84,6 +84,16 @@ typedef struct {coudn't these be static const?
@ -84,6 +84,16 @@ typedef struct {I wonder if that's the right name for the function. Maybe cyw43_set_pio_clock_divisor?
@ -84,6 +84,16 @@ typedef struct {They are set by cyw43_spi_set_clock_divisor() so they can't be const, but they should be static. I've made the changes in the latest commit.
@ -84,6 +84,16 @@ typedef struct {Good call, done
Any updates on this? Has anyone found an alternative I could use so users don't have to edit the SDK when they want to overclock their pi pico w?
@FrankLaterza does this change work for you?
After overclocking to 400MHZ this change worked perfect for me.
Is this something that needs to be dynamic? I'd vote for making this a PICO_ define which defaults to the old values
If the system clock wasn't dynamically adjustable I'd agree that it should be a simple #define, but Micropython and other VMs expose set_system_clock_mhz to the user and need to be able to adjust the SPI clock at runtime. Otherwise you end up with weird cases like "the Pico W works fine in Micropython when under- or overclocked, unless you want to use WiFi, in which case you'll have to rebuild the entire VM from scratch."
Your change has more or less been implemented. You need to define CYW43_PIO_CLOCK_DIV_DYNAMIC and then cyw43_set_pio_clock_divisor is available. Or else at build time you can use CYW43_PIO_CLOCK_DIV_INT and CYW43_PIO_CLOCK_DIV_FRAC. This is all in pico_cyw43_driver. There's an example here https://github.com/raspberrypi/pico-examples/blob/master/pico_w/wifi/blink/picow_blink_slow_clock.c
Pull request closed