cancel
Showing results for 
Search instead for 
Did you mean: 

stm32f207 ADC+TIMER+DMA / Poor Peripheral Library Examples

adrian
Associate III
Posted on April 24, 2013 at 11:19

Hi,

I'm looking to sample a signal (well, 2 actually - quadrature analog signals) at a fixed sample rate, but I'm baffled by the lack of any example in the Standard Peripheral Library on how to achieve this.

I would have thought that this would be a pretty standard example, i.e sample x points of a signal at y kHz and store result in memory location z.

Can anyone from ST comment on why such a basic (and imo fundamental) example is missing from the Standard Peripheral Library?

Does anybody else have an basic example of how this is achieved?  There are various incomplete snippets of code if you search in this forum, but elsewhere on the internet I've been able to find zilch.

I suspect I'm going to have to go read the manual in depth to figure this lot out...oh joy!

Many thanks.

Adrian
34 REPLIES 34
Posted on October 22, 2013 at 16:25

Is this C++ and your samples are inside an object (structure)?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
denis
Associate II
Posted on October 23, 2013 at 16:08

Turns out my asm 'skills' are even more absent than I thought..

(And basic understanding of C arrays too ... urgh :\   dumb ass on my  part)

Posted on October 23, 2013 at 16:53

Please don't delete posts it damages the integrity of the thread.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
denis
Associate II
Posted on October 23, 2013 at 18:09

sry , wanted to remove my stupid stuff

Amel NASRI
ST Employee
Posted on October 25, 2013 at 18:03

Hello,

Empty & repeated posts were removed to clean-up the whole discussion.

-Mayla-

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.

Gulev.Borislav
Associate II
Posted on January 12, 2014 at 18:20

A fine example.

My question is: Is it possible frequency of ADC module to connect to the pin for synchronization to an external device.

For example

T2_TRGO

 -> pin...

Posted on January 12, 2014 at 19:11

You can get a TIM to clock from an external source, both edges I think, by there is some resynchronization latency. Set a Period = 1

The DCMI does permit some parallel input clocking
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
tanguanzhong
Associate II
Posted on March 06, 2015 at 16:52

void DMA2_Stream0_IRQHandler(void) // Called at 1 KHz for 200 KHz sample rate, LED Toggles at 500 Hz
{
/* Test on DMA Stream Half Transfer interrupt */
if(DMA_GetITStatus(DMA2_Stream0, DMA_IT_HTIF0))
{
/* Clear DMA Stream Half Transfer interrupt pending bit */
DMA_ClearITPendingBit(DMA2_Stream0, DMA_IT_HTIF0);
/* Turn LED3 off: Half Transfer */
STM_EVAL_LEDOff(LED3);
// Add code here to process first half of buffer (ping)
}
/* Test on DMA Stream Transfer Complete interrupt */
if(DMA_GetITStatus(DMA2_Stream0, DMA_IT_TCIF0))
{
/* Clear DMA Stream Transfer Complete interrupt pending bit */
DMA_ClearITPendingBit(DMA2_Stream0, DMA_IT_TCIF0);
/* Turn LED3 on: End of Transfer */
STM_EVAL_LEDOn(LED3);
// Add code here to process second half of buffer (pong)
}
}

I used this code as above. I set a breakpoint in function

DMA2_Stream0_IRQHandler. It seems to be called. but cannot get into this statement and the condition.

if(DMA_GetITStatus(DMA2_Stream0, DMA_IT_TCIF0))

 Can you give some possiable problems?

Posted on March 06, 2015 at 17:32

Can you give some possible problems?

Your debugger is interfering with the DMA registers/flags?

Your reaction time is below 500 Hz?

The timer stops, the DMA errors? Or neither actually stop?

If you don't use a debugger, and you put a scope on the LED, do you see it toggle continuously?
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
tanguanzhong
Associate II
Posted on March 07, 2015 at 07:08

Thanks your advice. So I make a test. If I set the breakpoint here for

TM_ADC_DMA_IRQHandler();

.

void DMA2_Stream0_IRQHandler (void) {

  uint32_t events;

  events = (DMA2->LISR >>  0) & DMA_STREAM_FLAGS;

  DMA2->LIFCR = events <<  0;

  DMA2_Stream0_Event(events);

 

  //tgz

 

TM_ADC_DMA_IRQHandler();

  //tgz

 

} It can go into the ''if(DMA_GetITStatus(DMA2_Stream0, DMA_IT_TCIF0))'' statement. And output information on LCD.