Reduce PIO clock speed, remove CLOCKS_PER_DATA workaround

we now understand why the fudge factor was needed to achieve a
plausible brightness ramp.
This commit is contained in:
Jeff Epler 2025-01-24 10:23:55 -06:00
parent 8fb5ba4339
commit a532a9105e
2 changed files with 9 additions and 4 deletions

View file

@ -114,7 +114,14 @@ struct piomatter : piomatter_base {
sm_config_set_out_shift(&c, /* shift_right= */ false, sm_config_set_out_shift(&c, /* shift_right= */ false,
/* auto_pull = */ true, 32); /* auto_pull = */ true, 32);
sm_config_set_fifo_join(&c, PIO_FIFO_JOIN_TX); sm_config_set_fifo_join(&c, PIO_FIFO_JOIN_TX);
sm_config_set_clkdiv(&c, 1.0); // Due to https://github.com/raspberrypi/utils/issues/116 it's not
// possible to keep the RP1 state machine fed at high rates. This target
// frequency is approximately the best sustainable clock with current
// FW & kernel.
constexpr double target_freq =
2700000; // 2.7MHz PIO clock -> 1.35MHz pixel clock
double div = clock_get_hz(clk_sys) / target_freq;
sm_config_set_clkdiv(&c, div);
sm_config_set_out_pins(&c, 0, 28); sm_config_set_out_pins(&c, 0, 28);
pio_sm_init(pio, sm, offset, &c); pio_sm_init(pio, sm, offset, &c);
pio_sm_set_enabled(pio, sm, true); pio_sm_set_enabled(pio, sm, true);

View file

@ -8,9 +8,7 @@
namespace piomatter { namespace piomatter {
constexpr unsigned DATA_OVERHEAD = 3; constexpr unsigned DATA_OVERHEAD = 3;
// this is ... flatly wrong!? but it's the number that makes the ramp intensity constexpr unsigned CLOCKS_PER_DATA = 2;
// correct to my eye
constexpr unsigned CLOCKS_PER_DATA = 128;
constexpr unsigned DELAY_OVERHEAD = 5; constexpr unsigned DELAY_OVERHEAD = 5;
constexpr unsigned CLOCKS_PER_DELAY = 1; constexpr unsigned CLOCKS_PER_DELAY = 1;