You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Make all float->int/frac conversions round to nearest by default (#2065)
* making pio_calculate_clkdiv8_from_float round to the neareset 1/256 (not lower 1/256)
* chage rounding of all float clkdivs to round to neareset; default to nearest (which is a backwards incompatible change, but I think OK), and add ability to turn it off
* fix copy/paste errors in PICO_CONFIG
* Calculate size of FRAC field using its own MSB and LSB, rather than hoping that INT_LSB is in the right place
* Add a new REG_FIELD_WIDTH macro, and make the calculation of the clock-dividers more consistent
---------
Co-authored-by: Andrew Scheller <[email protected]>
// PICO_CONFIG: PICO_CLKDIV_ROUND_NEAREST, True if floating point clock divisors should be rounded to the nearest possible clock divisor by default rather than rounding down, type=bool, default=1, group=pico_platform
74
+
#ifndefPICO_CLKDIV_ROUND_NEAREST
75
+
#definePICO_CLKDIV_ROUND_NEAREST 1
76
+
#endif
77
+
73
78
#ifndef__ASSEMBLER__
74
79
75
80
/*! \brief No-op function for the body of tight loops
Copy file name to clipboardExpand all lines: src/rp2350/pico_platform/include/pico/platform.h
+5Lines changed: 5 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -63,6 +63,11 @@
63
63
#definePICO_USE_STACK_GUARDS 0
64
64
#endif
65
65
66
+
// PICO_CONFIG: PICO_CLKDIV_ROUND_NEAREST, True if floating point clock divisors should be rounded to the nearest possible clock divisor by default rather than rounding down, type=bool, default=1, group=pico_platform
67
+
#ifndefPICO_CLKDIV_ROUND_NEAREST
68
+
#definePICO_CLKDIV_ROUND_NEAREST 1
69
+
#endif
70
+
66
71
#ifndef__ASSEMBLER__
67
72
68
73
/*! \brief No-op function for the body of tight loops
// PICO_CONFIG: PICO_ADC_CLKDIV_ROUND_NEAREST, True if floating point ADC clock divisors should be rounded to the nearest possible clock divisor rather than rounding down, type=bool, default=PICO_CLKDIV_ROUND_NEAREST, group=hardware_adc
Copy file name to clipboardExpand all lines: src/rp2_common/hardware_clocks/include/hardware/clocks.h
+13-4Lines changed: 13 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -253,6 +253,11 @@ extern "C" {
253
253
#else
254
254
#definePARAM_ASSERTIONS_ENABLED_HARDWARE_CLOCKS 0
255
255
#endif
256
+
#endif
257
+
258
+
// PICO_CONFIG: PICO_CLOCK_GPIO_CLKDIV_ROUND_NEAREST, True if floating point GPIO clock divisors should be rounded to the nearest possible clock divisor rather than rounding down, type=bool, default=PICO_CLKDIV_ROUND_NEAREST, group=hardware_clocks
Copy file name to clipboardExpand all lines: src/rp2_common/hardware_pio/include/hardware/pio.h
+16-6Lines changed: 16 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -31,6 +31,12 @@
31
31
#definePICO_PIO_VERSION 0
32
32
#endif
33
33
#endif
34
+
35
+
// PICO_CONFIG: PICO_PIO_CLKDIV_ROUND_NEAREST, True if floating point PIO clock divisors should be rounded to the nearest possible clock divisor rather than rounding down, type=bool, default=PICO_CLKDIV_ROUND_NEAREST, group=hardware_pio
// PICO_CONFIG: PICO_PWM_CLKDIV_ROUND_NEAREST, True if floating point PWM clock divisors should be rounded to the nearest possible clock divisor rather than rounding down, type=bool, default=PICO_CLKDIV_ROUND_NEAREST, group=hardware_pwm
0 commit comments