Skip to main content
Visitor II
Oct 22, 2025 9:12 PM UTC
Question

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

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

TDK
Oct 22, 2025 9:41 PM UTC

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.

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