Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update GPOUTx fractional divider to work with RP2350 in clock_gpio_init_int_frac() and clock_gpio_init() #1924

Open
melberi opened this issue Sep 11, 2024 · 0 comments
Assignees
Milestone

Comments

@melberi
Copy link

melberi commented Sep 11, 2024

As per the datasheet for RP2350, it has a 16-bit integer and 16-bit fractional divider for the GPIO clock outputs. However, function clock_gpio_init_int_frac() only allow 8-bit fractional part. As a result, using clock_gpio_init_int_frac() the maximum fractional divider is 255/65536.

void clock_gpio_init_int_frac(uint gpio, uint src, uint32_t div_int, uint8_t div_frac)

Moreover, in clock_gpio_init() the fractional part calculated from floating point input value is cast to 8-bit unsigned integer from an input value ranging up to 65535, resulting in overflow for requested fractional part greater than approximately 0.00389.

uint8_t frac = (uint8_t)((div - (float)div_int) * (1u << CLOCKS_CLK_GPOUT0_DIV_INT_LSB));

In RP2350, CLOCKS_CLK_GPOUT0_DIV_INT_LSB is 16.

Version SDK 2.0.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants