AnsweredAssumed Answered

STM32L4 - SMBus and Melexis MLX90614

Question asked by Miguel Antunes on May 23, 2018
Latest reply on May 24, 2018 by Miguel Antunes



I'm trying to read temperature values from a Melexis MLX90614 sensor with SMBus but something seems to be wrong.

I used the HAL_SMBUS_IsDeviceReady to see if I can connect to the sensor and I can.


#define MLX90614_ADDRESS (0x5A << 1)
#define MLX90614_TA 0x06




return_value = HAL_SMBUS_Master_Transmit_IT(&hsmbus1,MLX90614_ADDRESS,(uint8_t*)MLX90614_TA,1,SMBUS_FIRST_FRAME);
while(HAL_SMBUS_GetState(&hsmbus1) != HAL_SMBUS_STATE_READY);

if (return_value != HAL_OK)
   return return_value;

return_value = HAL_SMBUS_Master_Receive_IT(&hsmbus1,MLX90614_ADDRESS,(uint8_t*)data_read,2,SMBUS_LAST_FRAME_NO_PEC);
while(HAL_SMBUS_GetState(&hsmbus1) != HAL_SMBUS_STATE_READY);

if(return_value != HAL_OK)
   return return_value;

This is the code I'm using to read to bytes from that sensor.

The code seems to stop in the first while.


The SMBus peripheral is configured in SMBus-Two-Wire-Interface in CubeMX.


I don't understand what should I put in the XferOptions field in either one of those functions and I don't know if that's the problem.




Thank you in advance.


Miguel Antunes