cancel
Showing results for 
Search instead for 
Did you mean: 

Hello Everyone, I am trying to interface MLX90614 sensor I2C with stm32F401 Discovery board and i have configured stm32 cube MX in standard mode. My sensor works fine and I am using logic analyser to analyse my SCL and SDA signals.

APand.7
Associate II

However, I am getting 0x3A(NACK) in stop condition of my logic analyser. Can anyone help me how i can convert this NACK to ACK. I am attaching my code snippet and my logic analyser signal as well . Thanks for help and support.

uint8_t I2C_ADDRESS = 0x00;

int main (void)

{

HAL_StatusTypeDef status = HAL_ERROR;

uint8_t buf[3] = {0,};

uint32_t temp_data_a;

uint32_t temp_data_o;

__IO float T;

__IO float To;

 status = HAL_I2C_IsDeviceReady(&hi2c1, I2C_ADDRESS, 3, 1000);

while(1)

{

HAL_I2C_Mem_Read(&hi2c1, 0x00, 0x06, 1, buf, 2, 1000); // Read Ambient temperature from Register 0x06

 temp_data_a = buf[1]*256 + buf[0];

 HAL_I2C_Mem_Read(&hi2c1, 0x00, 0x07, 1, buf, 2, 1000); // Read Object temperature from Register 0x07

 temp_data_o = buf[1]*256 + buf[0];

 To = temp_data_o*0.02;

 if(To >= 273.15)

  {

  To = To - 273.15;

  }

  else

  {

  To = -(273.15 - To);

  }

 T = temp_data_a*0.02;

if(T >= 273.15)

{

T = T - 273.15;

}

else

{

T = -(273.15 - T);

}

 HAL_Delay(500);

}

1 ACCEPTED SOLUTION

Accepted Solutions
Foued_KH
ST Employee

Hello @APand.7​ ,

The 0x3A means the value of the PEC according to the datasheet.

" The MLX90614 returns PEC after 16 bits data of which only 4 are meaningful and if the

MD wants it, it can stop the communication after the first byte. "

Foued

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

5 REPLIES 5
Foued_KH
ST Employee

Hello @APand.7​ ,

The 0x3A means the value of the PEC according to the datasheet.

" The MLX90614 returns PEC after 16 bits data of which only 4 are meaningful and if the

MD wants it, it can stop the communication after the first byte. "

Foued

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

APand.7
Associate II

Good Morning Foued

Thanks for your help. I do not want to stop the communication and I am more like a beginner, can you please help how i can do this and get ACK with 0x3A.

i want ACK with 0x3A, can you please suggest what should i do.

Thanks for your help and support

APand.7
Associate II

i have simulated this project using SMBUS and I got this siganls.

I want to achieve the same signals.

Can you please help. How i can get the same signals in I2C.

APand.7
Associate II

Hello Foued

Thanks for your reply. Sorry I misinterpret your answer. Actually 0x3A is error code.

Can you please look at my code and please tell me what i need to modify to get ACK

Sincerely Yours

Ashwani Pandey

Piranha
Chief II

Why did you create a duplicate topic? It is forbidden! And why the code is not in a Code Snippet?

Read the I2C specification and you will understand why there is a NACK on the last byte.