cancel
Showing results for 
Search instead for 
Did you mean: 

Timers options in STM32L

marek2399
Associate II
Posted on July 12, 2017 at 23:16

Hello engineers,

I would like to ask you about Timer possibilities. I do not have much experiences so please be patient. But back to my question, i want to trigger one Timer from external source, wait setted time (variable) and after reaching this time i need to start ADC in DMA mode (and after same procedure DAC in DMA mode bud DAC will work shorter than ADC) for setted time (probubly another Timer) .

Could you please help me?

Many thanks!

#dac #adc #timer
2 REPLIES 2
Posted on July 17, 2017 at 12:29

You should divide your problem to several tasks and tackle them separately. First, learn how to start the timer from an external trigger. Set up the timer's ARR, prescaler PSC if needed, any output compare as needed for starting the ADC, but don't enable the timer itself yet. You may want to set it to one-pulse mode, if one trigger has to start only one burst of conversions. Now for the external tirggering: set up the required input in GPIO_MODER to AF and then in AFR into the given timer; set the respective channel in timer to input capture, set up any filtering if needed, and then in TIMx_SMCR set TS to the given input channel and SMS to Trigger mode.

Then learn how to trigger the ADC from timer, again ADC should be already prepared together with DMA, the details are somewhat dependent on the particular STM32 model. An easier way to start with perhaps is to trigger the ADC/DMA conversion 'manually' from a timer-triggered interrupt.

To stop the AD conversion, you may use the DMA's Transfer Complete instead of using another timer.

JW

Amel NASRI
ST Employee
Posted on July 18, 2017 at 12:05

Hi

Petrinec.Marek.002

‌,

I join Jan in his proposal to split your project to some elementary tasks in order to understand the behavior of the peripherals you would like to use.

You can reveiw some examples provided in the Cube package for the peripherals you will need.

If your focus is on Timer user, I recommend you have a look to the

http://www.st.com/content/ccc/resource/technical/document/application_note/group0/91/01/84/3f/7c/67/41/3f/DM00236305/files/DM00236pdf/jcr:content/translations/en.DM00236pdf

: 'General-purpose timer cookbook'.

-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.