Weird (for me) problem(s) with ADC and DMA on STM32F3348
- June 19, 2020
- 7 replies
- 3716 views
First, I have done this before successfully on the STM32F446re with all 3 ADCs and DMAs but I need some guidance or ideas... STM32F3348 Disco OR my target PCB with same processor. ADC1 (and maybe ADC2) using DMA to convert 7 channels on ADC1 and 4 channels on ADC2 and place them in the arrays. Regular sequence (not injected, etc). It's easier to sit in the easy chair and use the Disco board... I have done another project on the STM32F446Re with similar setup with 3 ADCs and DMA and it works perfectly so this one is really weird. This 3348 processor appears to use DMA in a slightly different way though. For instance, channels instead of streams etc.
I DO get ADC results on both targets and the correct amount of array fills (7 and 4 locations). Using IAR EWARM 6.5 and ST-Link.
One thing that appears to be going wrong is that for ADC1 anyway, every time I stop the debugging, the order of the A2D results appear to be shifted in the array. I can't tell which one is correct either. One of the ADC1 channels is looking at the internal temp sensor and I was able to see that it does change with temperature but things do not stay put in their same spots in the array. But as far as I can tell, the values are spaced correctly. But there are more weird issues. Sometimes when hitting F5 to "GO" and then stop, I don't get any numbers changing but usually do. And it WAS that I had to read the ADC1->DR register or it would NOT run more than a couple of times, I think, due to the OVR flag being set. When I would go off of looking at ADC1_2 registers (ADC1 and common ADC regs I think that is for) it would stop running. Then I put a line in code in main() to just read the DR register and it kept ADC1 running. Very strange. I do not have any interrupts set to go for ADC or DMA. Same with my other STM32F446re project which works.
ADC2 appears to work but it may be having the same issue of not putting conversion results in the right places but the numbers are so close to each other it is hard to tell.
This is really strange. Hardware appears to run great otherwise.
Any ideas to troubleshoot this ?
Much appreciated !
PS. Both ADC and DMA have the same number for sequence and NDT respectively... i.e. number of conversions and transfers are both 7 for ADC1 and CH1 of DMA1 and both 4 for ADC2 and DMA1 channel 2. I had hoped it was just something stupid like that.
Attaching some captures of the debug registers to help illustrate some conditions.
First pic (AD1.png) is of watch registers on the right side showing one run-stop of debugging. Notice the numbers in ADC1DMA[] array and then a pic of another run-stop with very similar ADC1 conversion numbers but in a different spot. In this debug capture, I had to be watching the ADC1_2 registers. What ADC1_2 is is evidently the ADC1 registers AND the ADC1 and ADC2 COMMON registers. I am running these two ADCs in independent mode and not linked or synced together.
AD2.png is another run-stop of the debugging. You can also see some of the ADC1 registers on the left side as well as some of the hadc1 handle settings for ADC1. Notice how the ADC1DMA array values are shifted here.
Next is a pic of DMA register capture on the right including some of the DMA1 registers on the left in yellow as they were when I stopped the debugging...
And one more pic of the DMA1 HAL handle register values because they don't all fit on one screen.
Thanks for having a look guys !
boB
