Skip to main content
Visitor II
October 22, 2025
Question

How to handle the difference size in I2C DMA slave receiving.

  • October 22, 2025
  • 1 reply
  • 139 views

the sample code I2C_TwoBoards_ComDMA for the STM32H563 EVB.

On the host side, if the command length is unknown and may vary from one to three bytes, how can I modify the following function to handle a variable-length transfer based on I2C received size of bytes instead of a fixed size?

HAL_StatusTypeDef HAL_I2C_Slave_Receive_DMA(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size)

Thanks

 

 

 

    This topic has been closed for replies.

    1 reply

    Super User
    October 22, 2025

    Use the largest size you will support and process/ignore the AF error when it happens if you receive fewer than that amount. The rest of the data will still be there.