Skip to main content
CKörn.2
Associate II
Apr 1, 2021 2:56 PM UTC
Solved

STM32H7 I2C with DMA, no ACK after last byte

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.
Ons KOOLI
Ons KOOLIBest answer
Visitor II
Apr 8, 2021 9:47 AM UTC

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.

11 replies

CKörn.2
CKörn.2Author
Associate II
Apr 2, 2021 7:17 AM UTC

0693W000008yZiyQAE.png

CKörn.2
CKörn.2Author
Associate II
Apr 2, 2021 7:18 AM UTC
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
Apr 2, 2021 9:12 AM UTC

And what's wrong ? It is desirable behavior.

Ons KOOLI
Visitor II
Apr 2, 2021 10:12 AM UTC

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
Apr 7, 2021 6:36 AM UTC

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

CKörn.2
CKörn.2Author
Associate II
Apr 7, 2021 6:36 AM UTC

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

Ons KOOLI
Ons KOOLIBest answer
Visitor II
Apr 8, 2021 9:47 AM UTC

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
Apr 8, 2021 10:30 AM UTC

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