STM32H7 I2C with DMA, no ACK after last byte
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-04-01 7:56 AM
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 ?
Solved! Go to Solution.
- Labels:
-
DMA
-
I2C
-
STM32H7 Series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-04-08 2:47 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-04-02 12:17 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-04-02 12:18 AM
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;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-04-02 2:12 AM
And what's wrong ? It is desirable behavior.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-04-02 3:12 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-04-06 11:36 PM
Thank you, I already found this FAQ. I disabled ther D-Cache as a quick fix.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-04-06 11:36 PM
Perhaps I have to map the memory directly in the .ld file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-04-08 2:47 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-04-08 3:30 AM
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];
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-04-08 6:11 AM
Hi CKörn.2,
It really depends on the exact MCU you are using. STM32H7 devices are not all having the same architecture. You can refer to the reference manual that corresponds to your device, under section System Architecture. You have to find the memories that are accessible by DMA (in your case you are probably using DTCM, which is the default memory range used in most of ST projects), choose one of these memories and open your STM32H743XIHX_FLASH.ld file (which is the file used for build) and change the line in Specify the memory areas as described in the following figure:
Best Regards,
Ons.
