Add support for configuring XOSC FREQ_RANGE #3152
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!3152
Loading…
Reference in a new issue
No description provided.
Delete branch "xosc-range"
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?
Add PICO_XOSC_FREQ_RANGE_MAX config for non-RP2040 chips - defaults to XOSC_HZ / 1000000, but can be configured higher (e.g. to select the 40-100MHz range for a 50MHz crystal)
RP2040 only has one range, so this config is not defined for RP2040, as CMOS clock inputs >15MHz are still supported despite being out of the XOSC FREQ_RANGE value
Fixes #3074
@ -32,0 +37,4 @@xosc_hw->ctrl = XOSC_CTRL_FREQ_RANGE_VALUE_40_100MHZ;#else#error PICO_XOSC_FREQ_RANGE_MAX is too large, maximum is 100#endifThis might be a stupid question, but why does this allow
PICO_XOSC_FREQ_RANGE_MAXvalues up to 100 MHz, when the check on line 16 of this same file capsXOSC_HZat 50 MHz?It's very slightly OffTopic, but maybe this PR would also be a good place to edit
src/rp2040/hardware_regs/include/hardware/platform_defs.handsrc/rp2350/hardware_regs/include/hardware/platform_defs.hto addmin=1000000, max=50000000,to thePICO_CONFIG: XOSC_HZlines? 🙂@ -13,3 +15,4 @@// Allow lengthening startup delay to accommodate slow-starting oscillators?
@ -32,0 +37,4 @@xosc_hw->ctrl = XOSC_CTRL_FREQ_RANGE_VALUE_40_100MHZ;#else#error PICO_XOSC_FREQ_RANGE_MAX is too large, maximum is 100#endifBecause the ranges are:
so you need to be able to specify values above 50 to pick the final range, if you want that range instead of the 25-60 one
@ -13,3 +15,4 @@// Allow lengthening startup delay to accommodate slow-starting oscillatorsYes, this already links
hardware_clocks, so I can includehardware/clocks.hand useMHZThanks, added - I didn't add a note on RP2040 that values above 15MHz are only supported when using CMOS clock inputs, as that is very much a board design thing rather than an SDK thing
@ -32,0 +37,4 @@xosc_hw->ctrl = XOSC_CTRL_FREQ_RANGE_VALUE_40_100MHZ;#else#error PICO_XOSC_FREQ_RANGE_MAX is too large, maximum is 100#endifOkay, next stupid question: If using a 50 MHz frequency, is there any reason for choosing a range of 40-100 vs. choosing a range of 25-60?
EDIT: The reason I'm asking, is because I wonder if this could instead be calculated from the existing
XOSC_HZdefine, rather than requiring the addition of a newPICO_XOSC_FREQ_RANGE_MAXdefine?EDIT2: Although if we do need both a
XOSC_HZandPICO_XOSC_FREQ_RANGE_MAX, maybe there could / should also be a check thatXOSC_HZ <= (PICO_XOSC_FREQ_RANGE_MAX * MHZ)? 🤔@ -32,0 +37,4 @@xosc_hw->ctrl = XOSC_CTRL_FREQ_RANGE_VALUE_40_100MHZ;#else#error PICO_XOSC_FREQ_RANGE_MAX is too large, maximum is 100#endifI'm not sure, you would have to ask the ASIC team (@davidb990 might know?)
@ -32,0 +37,4 @@xosc_hw->ctrl = XOSC_CTRL_FREQ_RANGE_VALUE_40_100MHZ;#else#error PICO_XOSC_FREQ_RANGE_MAX is too large, maximum is 100#endifI can't spot anything in the datasheet to say you should pick one range over the other.
FWIW, the frequency ranges are used as a proxy for drive strength, so the choice ought to depend on how difficult the crystal is to drive - there could be a case where one 50 MHz crystal is better served by the 40-100 range, and another is better served by the 25-60 range (so perhaps leaving the choice up to the user to select based on their implementation is marginally preferable?)
@ -32,0 +37,4 @@xosc_hw->ctrl = XOSC_CTRL_FREQ_RANGE_VALUE_40_100MHZ;#else#error PICO_XOSC_FREQ_RANGE_MAX is too large, maximum is 100#endifHuh, fair enough 👍
But that still leaves my EDIT2 question above un-answered 😉
@ -32,0 +37,4 @@xosc_hw->ctrl = XOSC_CTRL_FREQ_RANGE_VALUE_40_100MHZ;#else#error PICO_XOSC_FREQ_RANGE_MAX is too large, maximum is 100#endifI think it’s fine to not check it, because if you’re explicitly setting it lower than your XOSC_HZ you may have a reason (eg wanting lower drive strengths because your crystal works with them, or you’re using a CMOS clock input and want a lower setting, or something)