2025-04-13 5:32 AM
2025-04-13 6:41 AM
HAL_I2C_Mem_Write expects a pointer to data, not a value.
HAL_I2C_Mem_Write(&hi2c1,0x80,HDC2080_DI_REG,1,&data1,1,100);
2025-04-13 6:43 AM
yes, data1 is a array so I put into data1. Before I define data1 as a value and put &data1into it just like you .It did not work.
2025-04-13 6:46 AM
I2C communication can work well
2025-04-13 6:57 AM
Well, I took a guess based on limited data. Might need to work through what "doesn't work" here means. Only way the values in the array could be relevant is if the chip NACKs or some other indirect action affecting program logic.
A state other than HAL_SPI_STATE_READY doesn't indicate an error. It may still be busy.
2025-04-13 7:25 AM
I used I2C to connect with my sensor. And it can receive information from sensor.
data1 = 0x00;
data2 = 0x01;
HAL_I2C_Mem_Write(&hi2c1,0x80,HDC2080_DI_REG,1,&data1,1,100);
HAL_I2C_Mem_Write(&hi2c1,0x80,0x07,1,&data1,1,100);
HAL_I2C_Mem_Write(&hi2c1,0x80,HDC2080_CONFIG_REG,1,&data2,1,100);
HAL_I2C_Mem_Write(&hi2c1,0x80,HDC2080_CONFIG_REG,1,&data2,1,100);
HAL_I2C_Mem_Read(&hi2c1,0x81,HDC2080_TEMP_REG,1,buffer,4,100);
But the SPI + GPDMA didn't work. From the register I find that GPDMA is not enabled and USEF = 1.
If I just use this
data1 = 0x00;
data2 = 0x01;
HAL_I2C_Mem_Write(&hi2c1,0x80,HDC2080_DI_REG,1,&data1,1,100);
HAL_I2C_Mem_Write(&hi2c1,0x80,0x07,1,&data1,1,100);
HAL_I2C_Mem_Write(&hi2c1,0x80,HDC2080_CONFIG_REG,1,&data1,1,100);
the SPI + GPDMA can work.
if I just use this
data1 = 0x00;
data2 = 0x01;
HAL_I2C_Mem_Write(&hi2c1,0x80,HDC2080_DI_REG,1,&data2,1,100);
the SPI + GPDMA didn't work. From the register I find that GPDMA is not enabled.
In fact, I move the code from my old version on stm32L4.it can work well include I2C and SPI+DMA.