cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_BUSY from LM75 via I2C on STM32L0538-Discovery

curiae
Associate II

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

4 REPLIES 4
curiae
Associate II

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();
	}
}

 

 

 


@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:

AndrewNeil_0-1729588998181.png

https://www.st.com/resource/en/schematic_pack/mb1143-l053c8t6-b03_schematic.pdf#page=5 

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()?

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:

https://www.good-display.com/public/html/pdfjs/viewer/viewernew.html?file=https://v4.cecdn.yun300.cn/100001_1909185148/GDEY0213B74.pdf

It does, indeed, say that it can read an external temperature sensor:

AndrewNeil_1-1729589635783.png

AndrewNeil_2-1729589689384.png

It seems you can access the temperature sensors via the display's command interface:

AndrewNeil_3-1729589993611.png