Skip to main content
Visitor II
April 13, 2025
Question

STM32U3 SPI+GPDMA can be enabled after sending IIC

  • April 13, 2025
  • 1 reply
  • 588 views
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? 
    This topic has been closed for replies.

    1 reply

    Super User
    April 13, 2025

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

     

    OrionJAuthor
    Visitor II
    April 13, 2025

    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.

    Super User
    April 13, 2025

    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.