2023-05-10 07:59 AM
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);
}
Solved! Go to Solution.
2023-05-10 08:38 AM
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.
2023-05-10 08:38 AM
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.
2023-05-11 12:16 AM
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
2023-05-11 12:43 AM
2023-05-11 03:59 AM
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
2023-05-13 12:23 AM
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.