Other Parts Discussed in Thread: TDC7201
I'm seeing some weird SPI behavior in my Raspberry Pi 3B + TDC7201-ZAX-EVM system.. Taking the first measurement seems to work perfectly; I get pulses or a timeout, calibration gets run (I have CONFIG1/FORCE_CAL turned on so I can test calibration), I can read all the registers, the numbers look reasonable, I can do TOF calculation. But when I try to run a second measurement using the exact same code, the SPI interface isn't working right. Trying to read CONFIG1 and CONFIG2 gets me the CONFIG1 value for both reads, trying to read INT_STATUS and INT_MASK gets me the CONFIG2 value for both reads, etc. It is behaving as if the address byte was shifted 1 bit to the right, so that addresses 0 and 1 both count as 0, addresses 2 and 3 both count as 1, etc..
There could be many possible causes for this. Something in the Raspberry Pi 3 hardware. Something in the kernel driver. Something in the spidev library. Something in my own code. Something in the tdc7201 or the EVM. But before I go diving down the rabbit hole into kernel space, could someone explain EXACTLY what steps are required to clean up the tdc7201 state after a measurement and before starting another measurement? The documentation is a little vague on this point. I tried writing 1s to the appropriate INT_STATUS bits to clear them, but it didn't work, probably due to the address-shift mangling.
Power cycling the whole system (including rebooting the RPi) fixes the problem enough to get one more measurement, but then it goes wonky again.
Changing the SPI clock speed has absolutely no effect. The same thing happens from 50 kHz to 16 MHz.
I'm not doing any SPI operations during the measurement. I'm just sitting and waiting for INTB1 to drop like a good boy.
Thanks,
Howard