Pretty much every time I tried to work with some sort of digital interface I run into some kind of trouble where a logic analyzer would have saved me hours of blind debugging and posting to various forums. Same thing happened when I decided to try the TMP121 temperature sensor from TI which has an SPI interface. It was the first time I worked with SPI on a pic32 and as expected nothing worked for the first try. The code for setting the SPI interface and reading from it seemed correct, I took it from the “32 bit peripheral lib user guide” from Microchip.
So what else could be wrong ? Well at this point it could be a faulty sensor or incorrect use of the SPI interface maybe I wasn’t generating the clock correctly or maybe some wiring issue. This is the point where you need to have a logic analyzer.
Logic Analyzer on PicKit2 – [Link]