endail / hx711-pico-c

Implementation of single and multiple HX711 use via RP2040's state machine
https://endail.github.io/hx711-pico-c/
MIT License
32 stars 7 forks source link

Investigate autopull instead of manual pull #44

Closed endail closed 1 year ago

endail commented 1 year ago

https://github.com/endail/hx711-pico-c/blob/1b634c3bd4e65b52ca3437721fa77f1268befcc8/src/hx711_noblock.pio#L111

endail commented 1 year ago

The current PIO program requires that, if the OSR is empty, the previously obtained value - the gain - is loaded into the x register. pull noblock does this.

A nonblocking PULL on an empty FIFO has the same effect as MOV OSR, X. - Pico C/C++ SDK pg. 64

If autopull is enabled it must similarly accomplish loading into the x register. The correct timing/delays must also be preserved.

endail commented 1 year ago

sm_config_set_out_shift() would need to be used to enable autopull. The fourth parameter, pull_threshold, is interesting. Only 2 bits are needed by the state machine (ie. out x, 2).

pio_sm_put takes a 32 bit word to put data into the OSR. So, pull_threshold may not be too relevant unless perhaps the RX FIFO is accessed directly in C?

endail commented 1 year ago

The RX FIFO cannot be directly accessed.