3 years, 3 months ago.

Why does the SPI clock end up in an uncertain state?

Hi, in my code here:

https://os.mbed.com/users/summers/code/MS5611/

On my teensy 3.2 I get very odd behaviour.

Its test code, for reading the ROM off an MS5611 pressure sensor via SPI.

I reset the device, wait for it to reset. Then read each ROM address 0-7 (which fails - but ignore that). I pause for 1s between each read - just to see whats happening ...

Now the SPI CLK is also the pin with the Teensy LED is on.

The reset, and prom reads 0-6 and the clock seems fine (as much as you can wat a 1MHz clock!) and during the 1s pause, is low as expected for mode 0 SPI.

Whats odd though, is after prom 7, the clock ends up in an on state, e.g. the LED is illuminated.

Isn't this incorrect behaviour for Mode 0 SPI? So what is going wrong?

David

Just to add information. Now I've completed my code, it is set to loop and repeat every second. With this the led only blips very brief once a second as I'd expect. With the code that had problem, the code exited soon after the last SPI command, so what I suspect was happening is it exited before that had compeleted - and this left the SPI clock in the wrong state. Does this make sense?

posted by David Summers 20 Mar 2018
Be the first to answer this question.