cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F303 ADC Dual Mode DMA Halfcomplete Interrupt

alexander2
Associate II
Posted on August 11, 2014 at 10:21

Hi All,

i have a strange Problem with my Application using TIM1 CCR4 as TRGO Signal to trigger ADC1/2 (seems to work). The ADCs are in Regular and Injected Simultanous mode. (Dual Mode bits = 0x01). The ADCs are clocked directly from AHB. MDMA is Halfword.

DMAEN is set, CONT is set. In CCR DMACFG is set to Circular Mode. 

My Problem now is when i start the ADCs and they get triggered i am not able to reset the DMA int flags for DMA1 channel 1 which i use. I read 3 from DMA1->ISR, for General, Half, and Full Interrupt. And want to reset the flags by writing 3 back to DMA1->ICFR but the Flags stay 1. In non Circular Mode every thin is fine, but then i need to trigger the adc by software and do not get timer synchonous sampling.

Has anyone an idea what i am doing wrong in circular mode?

Regards 

Alex

#adc #dma #adc_dual
5 REPLIES 5
Posted on August 11, 2014 at 10:47

Has anyone an idea what i am doing wrong in circular mode?

Hard to say from the description, perhaps your observation window is very large compared to the rate at which the data is being sampled in the background? Circular mode isn't going to stop and play dead like Normal mode would.

Not sure I'd be mixing in injected data with constant rate samples, can you not use other ADC to do that?
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
alexander2
Associate II
Posted on August 11, 2014 at 12:57

Hi Clive,

ok, lets try the other way around. I want to sample 4 Signals (DC Bus + 3 Phase Currents) in sync with TIM1 simultanusly. 

So i thought of sampling in Regular simultanus dual mode with both adc units.  I set up seqences sampling each channel two times. and i set up an buffer for each adc unit with space for 2 times * 2 samples * 2 channels => 8 samples. With the DMA set up on reading ADC_CDR on each dma request it should read the values to my buffer in linear mode this is fully functional. but when i set this to circular mode by setting DMA in circular and ADC DMA requests in circular (CCR DMACFG =1) .

With tis setting i want to use the DMA halfcomplete interrupt to trigger my control calculations. 

So i want to get every two measurements a Interrupt (ever in when DMA is in the middle of the buffer.) 

But my Problem now is when i hit the interrupt from the DMA i can not reset the Flags GIF1

TCIF1 and HTIF1. Which are set in ISR regsiter. And by writing these same bits to IFCR Register does not clear them. Which it does in normal mode.

With the Flags not cleared i get the Interrupt in an endless loop. My triggering is slow with 5kHz trigger event clock and the ADCs at full clock with 7.5Cycles sample time.

But this could not be a timing issue. Because when i single step through my interrupt:

flags = DMA1->ISR;     // reads 0x00000003

DMA1->ICFR = flags; // writes 0x00000003

After this line the Flags should be cleared, which they are in linear mode, but not in circular mode. 

Is there a setting which can prevent the flag reset in dma hardware? In my understanding this should reset the flags even if my configuration is complettly non sense.

I hope my problem gets more clear now.

Thanks in advance.

Regards 

Alex

Posted on August 11, 2014 at 14:15

Ok, but when you single step, aren't thousands of DMA operations occurring?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
alexander2
Associate II
Posted on August 11, 2014 at 16:34

when i look at the DMA data counter there is no change, when i stop at the line reading ISR and than step to the line writing ICFR and then another step. Nothing changes in the registers of ADC or DMA according to my IDE (Rowley Crossworks 3.2). The same handler works in linear mode. Nothing was changed here, i only changed the init of dma and adc to do circular mode. 

Is there an Bit in the Debug registers disabling DMA while break in debugger as for the timers?

Posted on August 11, 2014 at 17:06

There might be, but understand the clock doesn't stop because you've ground code execution to a halt in the debugger, the peripherals operate autonomously.

In Normal mode you have to reconfigure each DMA transfer, using code you must run, whereas in Circular mode the DMA controller automatically restarts and continues what it's doing, with no code or interaction from you.

Change your paradigm, observe the behaviour indirectly, by say toggling a GPIO and view that on a scope, or outputting some diagnostic/telemetry via a serial, or SWV channel. Such techniques will serve you well because the debugger is invasive, and gives you a distorted view of what is happening inside your device.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..