Synchronous Shift In with External Clock - Is there a SIMPLE example?
Hi,
to interface P2 with a HM01B0 camera with 1bit interface, I need to shift in from a serial line with an external clock frequency PCLKO of 24MHz. P2 is running at 200MHz. Data has to be written to a buffer in HUB.
https://www.uctronics.com/download/Datasheet/HM01B0-MWA-image-sensor-datasheet.pdf
The whole procedure to receive a picture can be seen here as a PIO program for Pico, starting from line 148:
https://github.com/ArmDeveloperEcosystem/hm01b0-library-for-pico/blob/main/src/hm01b0.c
I don't think, that I have a chance to do this shifting bit-banging??? Right? Or do I? That would be something like:
wait for HSYNC LO
wait for HSYNC HI
Repeat for all pixels/4:
Repeat 32 times:
wait for CLK HI
wait for CLK LO
read DATAPIN
shift DATA
wrfast DATA to HUB
So my question is, if there is a really SIMPLE example for the %11101 = synchronous serial receive smart mode?
Thanks very much for some hints!
Christof

Comments
Hi Christof,
While I don’t pretend to be an expert on the Pico’s PIO, after reviewing the code and the data sheet it looks to me like you are setting up to read on the wrong clock edge.
I don’t have time to analyze the PIO program fully at the moment, but I think it is possible to produce the simple example you are looking for.
Give this a try -- seems to work.
In this demo I start up a background Spin2 cog and use smart pin sync_tx to simulate sending one 32-bit value (see screenshot from LA). used a set of jumpers on my Eval board to route signals.
Note: the sync_rx function defaults to LSBFIRST so you may have to reverse your data bits before saving to the hub.