cancel
Showing results for 
Search instead for 
Did you mean: 

STM32U3 SPI+GPDMA can be enabled after sending IIC

OrionJ
Associate
HAL_I2C_Mem_Write(&hi2c1,0x80,HDC2080_DI_REG,1,data1,1,100);
 
while (HAL_I2C_GetState(&hi2c1) != HAL_I2C_STATE_READY);
 
 
if (HAL_SPI_GetState(&hspi2) != HAL_SPI_STATE_READY) {
// SPI ???,?????????
Error_Handler();
}
HAL_SPI_Transmit_DMA(&hspi2, new_wave, sizeof(new_wave));
 
when data1 =0x00, SPI +GPDMA can work; but when data1 ≠ 0x00, such as 0x01 and so on ,GPDMA can be enabled and USEF = 1. When I remove "
HAL_I2C_Mem_Write(&hi2c1,0x80,HDC2080_DI_REG,1,data1,1,100);
",SPI + GPDMA can work. Why? 
5 REPLIES 5
TDK
Guru

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

 

If you feel a post has answered your question, please click "Accept as Solution".

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.

I2C communication can work well

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.

If you feel a post has answered your question, please click "Accept as Solution".

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.