Closed endail closed 2 years ago
pull noblock side 1 ; clk high
out x, 2 ; use as T3 delay
mov y, x side 0 ; clk low
jmp !y wrap_target ; jump back to start (wrap_target is a label here) if y is 0
gainloop:
set pins, 1 [T3 - 1] ; clk high + delay
jmp y-- gainloop side 0 ; loop if postdec y > 0 and also set clk low
If I've done this correctly, the only downside is an extra cycle when the gain is not 128 (0 in the pio program).
The nature of the HX711 is that it requires at least one clock pulse each time a read takes place to set the gain. It may be possible to side-set the clock pin for at least one clock pulse on the
pull
,out
, ormov
instructions to avoid looping.https://github.com/endail/hx711-pico-c/blob/e0fe5bc2b11b1f14b6ad9226d9e9f8881925f44a/src/hx711_noblock.pio#L97-L115