当前位置:网站首页>STM 32 uses cube to generate Tim to trigger ADC and transmit through DMA

STM 32 uses cube to generate Tim to trigger ADC and transmit through DMA

2022-06-26 06:34:00 Test dog 2010

STM 32 Use cube Generate TIM Trigger ADC And pass DMA Transmission problems

I am trying to use these days freerots, A battery management task is planned , Need to use TIM Trigger ADC And pass DMA transmission
Because it's the first time cube and freerots, I'm still not sure .
The process is basically to configure according to Baidu method , It is not difficult to configure ,
The problem is that after the configuration is completed , The direct phenomenon is ADC No data
The overall logic is to configure first TIM and ADC, To configure ADC from TIM Trigger , Then there are three channel scans , Data is sent to an internally defined array
After inspection , Find the first TIM It's not even running ( Open when debugging TIM3 The register of ), It turned out cube The generated code is actually just configured , But to start, the user needs to start it in the user code area , like this
 Insert picture description here
Then I changed it ,ADC It can be triggered normally , But found DMA No reaction ,
So the debug interface opens DMA The register of , It is found that all the registers inside are empty . That is to say, there is no configuration .
This is very strange , Because I have the statement to start it
 Insert picture description here
Finally found , The reason is that the generated code ,ADC The initialization of is in DMA Caused before initialization .....
because DMA There is a function to turn on the clock in initialization , If ADC stay DMA Previous configuration ,DMA The clock is not on , in other words ADC The initialized configuration cannot be written in ....
 Insert picture description here
later , Change the two initialization positions , take DMA On the front , You can receive data normally .

原网站

版权声明
本文为[Test dog 2010]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/177/202206260618302405.html