|
24 | 24 | #include "hardware/pio.h" |
25 | 25 |
|
26 | 26 | // Derive divider from current clock so PIO runs at ~125 MHz reference |
27 | | -uint32_t sys_hz = clock_get_hz(clk_sys); // e.g. 125/200/266 MHz |
28 | | -float target_hz = 125000000.0f; // PIO code designed for 125 MHz |
29 | | -float divider = (float)sys_hz / target_hz; // scales automatically |
| 27 | +float dmd_interface_clk_divider = |
| 28 | + (float)(clock_get_hz(clk_sys)) / 125000000.0f; // scales automatically |
30 | 29 |
|
31 | 30 | // Init the DMD reader (dots) PIO program, common for all DMD types. |
32 | 31 | void dmd_reader_program_init(PIO pio, uint sm, uint offset, pio_sm_config c, |
@@ -65,7 +64,7 @@ void dmd_reader_program_init(PIO pio, uint sm, uint offset, pio_sm_config c, |
65 | 64 | ); |
66 | 65 |
|
67 | 66 | // Make sure we run this sm with a 125MHz clk |
68 | | - sm_config_set_clkdiv(&c, divider); |
| 67 | + sm_config_set_clkdiv(&c, dmd_interface_clk_divider); |
69 | 68 |
|
70 | 69 | // Load our configuration, do not yet start the program |
71 | 70 | pio_sm_init(pio, sm, offset, &c); |
@@ -93,7 +92,7 @@ void dmd_framedetect_program_init(PIO pio, uint sm, uint offset, |
93 | 92 | 0); |
94 | 93 |
|
95 | 94 | // Make sure we run this sm with a 125MHz clk |
96 | | - sm_config_set_clkdiv(&c, divider); |
| 95 | + sm_config_set_clkdiv(&c, dmd_interface_clk_divider); |
97 | 96 |
|
98 | 97 | // Load our configuration, do not yet start the program |
99 | 98 | pio_sm_init(pio, sm, offset, &c); |
|
0 commit comments