2024-10-21 11:46 PM
Hello,
I tried to get temperature data from LM75 via I2C on STM32L0538-Discovery.
But in following test program, HAL_I2C_Master_Transmit() and HAL_I2C_Master_Receive() returned HAL_BUSY.
What's wrong with it?
And I couldn't check from the schematic diagram on UM1775 if LM75 is connected with the STM32L0538.
Please show me how to solve it.
Thanks
Solved! Go to Solution.
2024-12-18 01:57 AM
@curiae has that resolved your issue?
If so, please mark the solution:
https://community.st.com/t5/community-guidelines/help-others-to-solve-their-issues/ta-p/575256
2024-10-22 02:10 AM
Hello,
Now I found source codes in my post was deleted so I'll post again.
I tried to get temperature data from LM75 via I2C on STM32L0538-Discovery.
In following test program, HAL_I2C_Master_Transmit() and HAL_I2C_Master_Receive() returned HAL_BUSY.
Though in MX_I2C1_Init() hi2c->State was HAL_OK, but entering to HAL_I2C_Master_Transmit(), hi2c->State was changed to HAL_BUSY.
I thought LM75 is not connected with MCU, I couldn't check from the schematic diagram on UM1775 if LM75 is connected with the STM32L0538 or not.
Please show me how to solve it.
Thanks
#define LM75_ADDR (0x90 << 1)
#define LM75_REG_TEMP 0x00 // Temperature
int main(void)
{
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
MX_RTC_Init();
MX_I2C1_Init();
// I2C test
uint8_t data_write[2];
uint8_t data_read[2];
HAL_StatusTypeDef ret, ret_rec;
I2C_HandleTypeDef *handle;
data_write[0] = LM75_REG_TEMP;
ret = HAL_I2C_Master_Transmit(handle, LM75_ADDR, data_write, 1, MAX_DELAY);
HAL_Delay(100);
ret_rec = HAL_I2C_Master_Receive(handle, 0xb9, data_read, 2, MAX_DELAY);
while(1)
{
}
}
void MX_I2C1_Init(void)
{
hi2c1.Instance = I2C1;
hi2c1.Init.Timing = 0x10A13E56; // 100KHz
hi2c1.Init.OwnAddress1 = 0;
hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
hi2c1.Init.OwnAddress2 = 0;
hi2c1.Init.OwnAddress2Masks = I2C_OA2_NOMASK;
hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
if(HAL_I2C_Init(&hi2c1) != HAL_OK)
{
Error_Handler();
}
// Configure Analog filter
if(HAL_I2CEx_ConfigAnalogFilter(&hi2c1, I2C_ANALOGFILTER_ENABLE) != HAL_OK)
{
Error_Handler();
}
// Configure Digital filter
if(HAL_I2CEx_ConfigDigitalFilter(&hi2c1, 0) != HAL_OK)
{
Error_Handler();
}
}
2024-10-22 02:23 AM - edited 2024-10-22 02:40 AM
@curiae wrote:Now I found source codes in my post was deleted so I'll post again.
No need to start a separate thread - you could have just edited the original, or added a reply.
Merged with the original.
@curiae wrote:I couldn't check from the schematic diagram on UM1775 if LM75 is connected with the STM32L0538 or not.
I don't see any mention of an LM75 in any of this board's documentation:
https://www.st.com/en/evaluation-tools/32l0538discovery.html
But it does appear on the schematic:
https://www.st.com/resource/en/schematic_pack/mb1143-l053c8t6-b03_schematic.pdf#page=5
2024-10-22 02:33 AM
Sorry, I should have written formal name STLM75.
Could you tell me why HAL_I2C_Master_Transmit() and HAL_I2C_Master_Receive() returned HAL_BUSY.
There are something wrong in MX_I2C1_Init()?
2024-10-22 02:40 AM
So it does look like the LM75 is not connected to the STM32; looks like it's just connected to the display - presumably used "internally" by that display?
Here's a datasheet for the display:
It does, indeed, say that it can read an external temperature sensor:
It seems you can access the temperature sensors via the display's command interface:
2024-12-18 01:57 AM
@curiae has that resolved your issue?
If so, please mark the solution:
https://community.st.com/t5/community-guidelines/help-others-to-solve-their-issues/ta-p/575256