Skip to main content
CKörn.2
Associate II
April 1, 2021
Solved

STM32H7 I2C with DMA, no ACK after last byte

  • April 1, 2021
  • 6 replies
  • 2385 views

When reading the I2C bus with DMA it is followed by a NACK.

Do i have to clear it somehow in the DMA1_Stream0_IRQHandler ?

This topic has been closed for replies.
Best answer by Ons KOOLI

Hi, CKörn.2,

Yes you have, DMA can not access DTCM.

After changing memory allocation, please inform if your problem is fixed.

You can also refer to this FAQ to see how you change memory in .ld file.

Best Regards,

Ons.

6 replies

CKörn.2
CKörn.2Author
Associate II
April 2, 2021

0693W000008yZiyQAE.png

CKörn.2
CKörn.2Author
Associate II
April 2, 2021
HAL_StatusTypeDef I2Cx_ReadBuffer(I2C_HandleTypeDef i2c_handler,
		uint8_t i2c_dev_address, uint8_t *pBuffer,
		uint16_t length) {
	HAL_StatusTypeDef status = HAL_BUSY;
 
	while (HAL_I2C_GetState(&i2c_handler) != HAL_I2C_STATE_READY) {
	}
 
	status = HAL_I2C_Master_Receive_DMA(&i2c_handler, i2c_dev_address,(uint8_t*) &pBuffer[0], length);
 
	/* Check the communication status */
	if (status != HAL_OK) {
		ERROR_VERBOSE_PRINT
		printf("** Reading error i2c device: 0x%x.** \n", i2c_dev_address);
		reset_bus(I2C1_RESET);
	}
 
	return status;
}

Michal Dudka
Lead
April 2, 2021

And what's wrong ? It is desirable behavior.

Ons KOOLI
Associate
April 2, 2021

Hi CKörn.2,

Can you please refer to this FAQ. Maybe your problem is related to the use of DMA with STM32H7 devices.

Best Regards,

Ons.

CKörn.2
CKörn.2Author
Associate II
April 7, 2021

Thank you, I already found this FAQ. I disabled ther D-Cache as a quick fix.

CKörn.2
CKörn.2Author
Associate II
April 7, 2021

Perhaps I have to map the memory directly in the .ld file.

Ons KOOLI
Ons KOOLIBest answer
Associate
April 8, 2021

Hi, CKörn.2,

Yes you have, DMA can not access DTCM.

After changing memory allocation, please inform if your problem is fixed.

You can also refer to this FAQ to see how you change memory in .ld file.

Best Regards,

Ons.

CKörn.2
CKörn.2Author
Associate II
April 8, 2021

Hello,

thank you. Which SRAM section should I use? SRAM with start address 0x38000000 for 64KB?

__attribute__((section(".dma_buffer"))) uint8_t i2c1_TxBuffer[1];