I'm learning to control a MCP4131 digital potentiometer with the RPi. I've successfully used the MCP4131 by sending my data to the SDI pin, and then a HIGH value to the CLK followed by sending a LOW value on the same CLK. This indicates data is ready to be read.
My code for sending a bit to the MCP4131 looks like this, where
bit_value contains either a 0 or a 1:
GPIO.output(SPI_SDI_PIN, bit_value) GPIO.output(SPI_CLK_PIN, True) GPIO.output(SPI_CLK_PIN, False)
You can notice that I'm not sleeping between setting the clock HIGH and LOW, so how can I be sure that the MCP4131 will notice that change? Maybe the RPi is too fast and the MCP4131 will not be able to see the HIGH value.
From what I've researched, the RPi SPI interface goes at 250MHz and the MCP4131 just at 10MHz, so I was expecting that without a time:sleep() in between the two clock signals this would not work.
Why does it work and what are better practices to avoid putting time.sleep() with hard-coded delays?
(My RPi is running Raspbian if that matters)