Skip to content

Commit 6eab2ec

Browse files
committed
fix off-by-one in ADC sample rate divisor
1 parent a037491 commit 6eab2ec

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

ports/raspberrypi/common-hal/analogbufio/BufferedIn.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ void common_hal_analogbufio_bufferedin_construct(analogbufio_bufferedin_obj_t *s
5353
// sample rate determines divisor, not zero.
5454

5555
// sample_rate is forced to be >= 1 in shared-bindings
56-
float clk_div = (float)ADC_CLOCK_INPUT / (float)sample_rate;
56+
float clk_div = (float)ADC_CLOCK_INPUT / (float)sample_rate - 1;
5757
adc_set_clkdiv(clk_div);
5858

5959
// Set up the DMA to start transferring data as soon as it appears in FIFO

0 commit comments

Comments
 (0)