SVD contains clear-on-write fields that aren't actually clear-on-write #1466
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#1466
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?
As encouraged by https://github.com/raspberrypi/pico-sdk/pull/1063#issuecomment-1279954374, please let me forward an issue @9names found: The SVD file uses
modifiedWriteValues: clearto annotate some fields which are not actually cleared by the register write, but where writing a 1 triggers some action and then the hardware automatically resets the register value back to 0: https://github.com/rp-rs/rp2040-pac/issues/69The example given are the fields PH_ADV and PH_RET in the PWM registers. The datasheet lists them as clear type
SC("This is a single bit that is written to by the processor and then cleared on the next clock cycle."). I agree with the mentioned issue that this shouldn't be translated tomodifiedWriteValues: clearin the SVD.As I understand it,
SCshould translate to the default behavior,modifiedWriteValues: modify: The write doesn't do anything special, it just sets the bit. That the hardware clears the bit automatically on the next clock cycle isn't a side effect of the write itself, which doesn't have a special representation inmodifiedWriteValues.Also please note that
SCis probably not correct for PH_ADV and PH_RET, asSCmeans "cleared on the next clock cycle". But those two bits don't work like that, according to further explanations in the data sheet: "To advance or retard the phase by one count, software writes 1 to PH_ADV or PH_RET. Once an enable pulse has been inserted or deleted, the PH_ADV or PH_RET register bit will return to 0, and software can poll the CSR until this happens." That wouldn't make sense of those bits would always be cleared on the next clock cycle. So those register fields should have the default typeRWinstead.I'm not a hardware-engineer, so I'm not aware of the full intricacies, but (in this particular example) IMHO a regular
RWfield wouldn't be appropriate either, as you (probably) wouldn't expect a RW field to be "changed behind your back by hardware" when you aren't looking? 🤷♂️There are a lot of registers which can be written by the user but which are also modified by the hardware, and they are usually marked as
RW. So aRWfield being "changed behind your back by hardware" isn't unusual at all.