Other Parts Discussed in Thread: LM71
Hi team,
My customer is using LM95071 for temperature measurement over SPI. They find that after a day or two of run time it can become stuck sending out the same two bytes, sometimes it’s the device ID as though it were in sleep mode, most recently it was reading 14.6degC and not reacting to heat.
The read function is being called once per second. I'm also attaching a scope shot of 16 clock pulses to get the two bytes the use. The scope is slow (50MHz) so the clock looks rounded. In the first attachment the output is the device ID. Chip select is green, LM95 output is blue, clock is purple. In the second attachment is is a normal output after reboot showing room temp of 21.21 deg C.
A reboot always fixes it. He is running at 10MHz from the STM32L431 using the following code-
float LM95071_get_degC(void)
{
int16_t MSB,LSB;
int16_t count;
// let pending transmissions complete
while (!LL_SPI_IsActiveFlag_TXE(LM95071_SPI_PORT) || LL_SPI_IsActiveFlag_BSY(LM95071_SPI_PORT)); // wait for transmission to complete
while(LL_SPI_IsActiveFlag_RXNE (LM95071_SPI_PORT))
{// make sure FIFO buffer is empty
LL_SPI_ReceiveData8(LM95071_SPI_PORT); // read data
}
LL_SPI_Disable(LM95071_SPI_PORT);// port must be disabled to change phase and polarity
LL_SPI_SetClockPolarity(LM95071_SPI_PORT,LL_SPI_POLARITY_LOW);
LL_SPI_SetClockPhase(LM95071_SPI_PORT,LL_SPI_PHASE_2EDGE);
LL_SPI_Enable(LM95071_SPI_PORT);// Enable SPI port
LL_GPIO_ResetOutputPin(LM95071_CS_PORT, LM95071_CS_PIN);// pull LM95071 /cs pin low
LL_SPI_TransmitData8(LM95071_SPI_PORT,0); // dummy tx
LL_SPI_TransmitData8(LM95071_SPI_PORT,0); // dummy tx
while (!LL_SPI_IsActiveFlag_TXE(LM95071_SPI_PORT)|| LL_SPI_IsActiveFlag_BSY(LM95071_SPI_PORT)); // wait for transmission to complete
LL_GPIO_SetOutputPin(LM95071_CS_PORT, LM95071_CS_PIN);// pull LM95071 /cs pin high
MSB=LL_SPI_ReceiveData8(LM95071_SPI_PORT); // read data
LSB=LL_SPI_ReceiveData8(LM95071_SPI_PORT) & 0xFC; // read data and clear 2 LSBs
count=LSB+(MSB<<8); // convert to 2's complement integer
return((float)count*LM95071_DEGC_PER_LSB); // return degC
}
Any idea of what could be going wrong?