DMA not working in CubeMX generated code - order of initialization
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-12-07 4:37 AM
Here is a (possibly incomplete) list of threads affected by this CubeMX issue:
https://community.st.com/s/feed/0D50X0000BZFWRISQ5
https://community.st.com/s/question/0D50X0000BbKaA5SQK/haluarttransmitdma-doesnt
https://community.st.com/s/question/0D50X0000BbMcnpSQC/dma-adc-doesnt-work
https://community.st.com/s/question/0D50X0000BWqGdtSQF/haladcstartdma-init-msp-bug
https://community.st.com/s/question/0D50X0000Bfs7MvSQI/stm32f3-adc-with-dma-bug
https://community.st.com/s/question/0D50X0000BcPXk2SQG/32f746-usart-dma-with-stemwin-not-working
This is just in case somebody would like to put up a sticky post with this...
JW
[EDIT] Further development with CubeMX5.5
[EDIT] Problem reappeared 6.3.0 https://community.st.com/s/question/0D53W000011uIPgSAM/adc-dmahandle-is-0
[EDIT] Official method to fix the incorrect order, if project was generated in "incorrect" version of CubeMX: https://community.st.com/s/question/0D53W00001EzCmCSAV/mxdmainit-order-in-the-mainc-file-generated-by-stm32cubemx-how-to-fix
Solved! Go to Solution.
- Labels:
-
Bug-report
-
DMA
-
STM32CubeIDE
-
STM32CubeMX
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-04-02 6:15 AM
Any place where I can see if this is fixed in the newest CubeMX?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-04-03 6:33 AM
Hi @Community member​ ,
Did you downloaded latest CubeMX version (5.6)? The issue is already fixed.
-Amel
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-04-03 9:34 AM
Thanks for the reply. I did not download it because of data usage concerns. I'll download it now that I know it is fixed.
For future reference, do you have a place where we can see the status of publicly-reported bugs? It would be very useful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-04-07 2:27 AM
Hi @Community member​ ,
Generally, when a new STM32CubeMX version is released, we make a post listing known limitations and some fixed issues, like https://community.st.com/s/question/0D50X0000CBkdCTSQZ/stm32cubemx-560-released.
-Amel
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-04-07 3:32 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-04-08 3:37 PM
Hi Amel,
this thread https://community.st.com/s/question/0D53W000004HgujSAC/the-stm32g484cetx-initialization-code-generated-by-stm32cubemx-has-a-bug appears to say that the problem persists in CubeMX v5.6.0 ?
JW
@Amel NASRI​
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-10-08 3:22 AM
Can confirm that this is (still) a problem with recent STM32CubeIDE versions. I've run into this problem on STM32CubeIDE 1.7.0 (which has STM32CubeMX 6.3.0)
To reproduce:
- Start a new STM32 Project in STM32CubeIDE
- Enable an I2C peripheral in the Device Configuration Tool
- Generate code
- Add DMA channels to the I2C peripheral
- Generate code again
- Observe in `main.c` that `MX_I2C1_Init()` is called before `MX_DMA_Init()`
- Observe that the HAL_I2C_*_DMA() functions don't work
I tried both `HAL_I2C_Master_Transmit_DMA()` and `HAL_I2C_Master_Receive_DMA()`. Swapping the initialization order in the genrated code (calling `MX_DMA_Init()` before `MX_I2C1_Init()`) causes the functions to work.
Note that the following sequence leads to code that's generated in the correct order:
- Start a new STM32 Project
- Enable an I2C peripheral in the Device Configuration Tool
- Add DMA channels to the I2C peripheral
- Generate code
This implies that it's a bug in the "Updating Code" step.
I was able to fix the problem by manually moving `MX_DMA_Init()` before `MX_I2C1_Init()`. The code remained working even when the code was re-generated. It also meant that I didn't have to create a new .ioc file, or disable/re-enable peripherals, to fix the problem.
It also appears that similar problems exist with other DMA-enabled peripherals -- I repeated the same steps above with the I2C, SPI and USART peripherals, and observed the same behaviour for each of the peripherals.
For completeness, I was using STM32Cube FW_F0, targetting an STM32F042K6Tx (but I don't think this information is particularly relevant)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-10-08 3:41 AM
Can't edit, so just to note that manually changing the order in `main.c` actually didn't fix the issue. The correct fix is to re-order in the Device Configuration Tool -- as noted in https://community.st.com/s/question/0D50X0000Boy3eVSQQ/cubemx-540-generates-broken-code-for-stm32h7-stm32h7432-sai-dma
Use the buttons (3) to move `MX_DMA_Init()` above the peripheral init
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-10-08 4:15 AM
Hi @JStor.2​ ,
Unfortunately this is a regression issue introduced wit STM32CubeMX 6.3 and STM32CubeIDE 1.7.0.
This is tracked internally and should be fixed on coming release of the tool. @Khouloud OTHMAN​ can confirm about fix availability.
Internal ticket 112040 : This is an internal tracking number and is not accessible or usable by customers.
-Amel
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-10-11 5:10 PM
Funny how all my googling about "STM32 Can not set DMA configuration register" "DMA CR not writing with ADC" etc. etc. did not bring me here. I had to figure out the bug myself, wasting half a day. This is very annoying given it is a known issue. Part of the problem is that nowhere in any of the examples or documentation for DMA does it mention the fact the one must enable the clock to the DMA before doing anything. Can someone from STM please make a note to add to the DMA documentation a tip to enable it first up??
