Hello,
I have a question about SPI communication sequence of LM74 Temperature Sensor, which is controlled by Microcontroller.
To test SPI read/write communication, I programmed code based on page 11 of LM74 datasheet.
<< Page 11 of Datasheet >>
The following communication can be used to determine the Manufacturer's/Device ID and then immediately place the part into continuous conversion mode. With CS continuously low:
• Read 16 bits of temperature data
• Write 16 bits of data commanding shutdown
• Read 16 bits of Manufacture's/Device ID data
• Write 8 to 16 bits of data commanding Conversion Mode
• Take CS HIGH.
<< my pseudo-code >>
while(1)
{
SPI_CS_LOW; // set Chip Select Pin LOW
SPI_Read(2); // Read 16 bits of temperature data - seems to valid temperature data
SPI_Write(0x00, 0xFF); // Write 16 bits of data commanding shutdown
SPI_Read(2); // Read 16 bits of Device ID data - expected : 0b 1000 0000 0000 00XX / actual : completely different value
SPI_Write(0x00, 0x00); // Write 8 to 16 bits of data commanding Conversion Mode
SPI_CS_HIGH; // set Chip Select Pin HIGH
delay_ms(1000) // delay 1 second
}
As described in comment of my pseudo-code, i can't get proper Device ID.
when try to read Device ID, the read data is seems to temperature data from previous read cycle.
According to <figure 16. c) Writing Shutdown Control> of datasheet,
Chip Select Pin is HIGH after write shutdown command. (Data from the controller)
Which is correct about this sequence? the paragraph of page 11 or figure 16 ?
Should I set the Chip Select pin to HIGH every time I change the shutdown/conversion mode?
Please tell me the right sequence.
Best Regards,