Skip to content

Commit 34c3ade

Browse files
urishkilograham
authored andcommitted
Fix pio_blink frequency calculation
Added missing parenthesis around the divisor. Verified using a logic analyzer and also in simulation: https://wokwi.com/arduino/projects/300911723685085709
1 parent cf2cd5a commit 34c3ade

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

pio/pio_blink/blink.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ void blink_pin_forever(PIO pio, uint sm, uint offset, uint pin, uint freq) {
3131
pio_sm_set_enabled(pio, sm, true);
3232

3333
printf("Blinking pin %d at %d Hz\n", pin, freq);
34-
pio->txf[sm] = clock_get_hz(clk_sys) / 2 * freq;
34+
pio->txf[sm] = clock_get_hz(clk_sys) / (2 * freq);
3535
}

0 commit comments

Comments
 (0)