raspberrypi / pico-sdk

BSD 3-Clause "New" or "Revised" License
3.75k stars 935 forks source link

I would say, that `CLOCKS_CLK_REF_CTRL_AUXSRC_VALUE_LPOSC_CLKSRC` definition is missing #2047

Open matsobdev opened 5 hours ago

matsobdev commented 5 hours ago

...inside https://github.com/raspberrypi/pico-sdk/blob/master/src/rp2350/hardware_regs/include/hardware/regs/clocks.h, according to https://www.raspberrypi.com/documentation/pico-sdk/hardware.html#group_hardware_clocks. It seems to me, but I'm not sure, tho.

lurch commented 3 hours ago

A bit more fully-fleshed info, after a bit of digging... I think the complaint is that this table in the documentation: Screenshot from 2024-11-16 22-30-58 which is in the RP2350 section of https://www.raspberrypi.com/documentation/pico-sdk/hardware.html#detailed-description-4 says that clk_ref can use the Aux Sources "GPIO in 0" (CLOCKS_CLK_REF_CTRL_AUXSRC_VALUE_CLKSRC_GPIN0), "GPIO in 1" (CLOCKS_CLK_REF_CTRL_AUXSRC_VALUE_CLKSRC_GPIN1), "USB PLL" (CLOCKS_CLK_REF_CTRL_AUXSRC_VALUE_CLKSRC_PLL_USB) or "LPOSC" (CLOCKS_CLK_REF_CTRL_AUXSRC_VALUE_LPOSC_CLKSRC). However https://github.com/raspberrypi/pico-sdk/blob/develop/src/rp2350/hardware_regs/include/hardware/regs/clocks.h#L543 only lists the values for CLOCKS_CLK_REF_CTRL_AUXSRC of CLOCKS_CLK_REF_CTRL_AUXSRC_VALUE_CLKSRC_PLL_USB, CLOCKS_CLK_REF_CTRL_AUXSRC_VALUE_CLKSRC_GPIN0, CLOCKS_CLK_REF_CTRL_AUXSRC_VALUE_CLKSRC_GPIN1 and CLOCKS_CLK_REF_CTRL_AUXSRC_VALUE_CLKSRC_PLL_USB_PRIMARY_REF_OPCG and therefore appears to be "missing" CLOCKS_CLK_REF_CTRL_AUXSRC_VALUE_LPOSC_CLKSRC.

However, if we look at the CLOCKS: CLK_REF_CTRL register on page 532 of https://datasheets.raspberrypi.com/rp2350/rp2350-datasheet.pdf we can see that it also only lists the possible values of AUXSRC as being CLKSRC_PLL_USB, CLKSRC_GPIN0, CLKSRC_GPIN1 and CLKSRC_PLL_USB_PRIMARY_REF_OPCG. (Also, as AUXSRC is only a 2-bit field, it can't have more than 4 different values.)

The table in the HTML documentation linked above is ultimately derived from https://github.com/raspberrypi/pico-sdk/blob/develop/src/rp2_common/hardware_clocks/include/hardware/clocks.h#L105 so I guess either the register descriptions for the CLOCKS: CLK_REF_CTRL.AUXSRC fields are mis-labeled, or that Doxygen table in clocks.h is wrong? :thinking: ping @liamfraser

lurch commented 3 hours ago

P.S. I didn't know what OPCG was, but after a bit of searching it seems to be "On-Product Clock Generator" and it seems to be related purely to the factory-testing of chips. https://www.youtube.com/watch?v=XUJVGjDfJJg (ATE = Automated Test Equipment)