STM32L4 - DAC triggering using timer example
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-01-28 11:54 AM
Hi, guys. I'm using the STM32L4 discovery (MB1184C) board to test DAC (Pin PA5).
I use Keil uVision 5 to debug the code.
I noticed the Timer trigger option and I want to use this.
I want to put this MCU to sleep at the main function's while loop.
Periodically, like every 20 microseconds, I want to wake the MCU via a timer and change the DAC value.
So the questions are;
- What's the difference between "Connect to external pin / on chip-peripheral options"
- Is that timer trigger the feature I was looking for - change the DAC value periodically?
- Or do I have to use a timer interrupt (Slave mode disabled, Clock source internal, set prescaler, etc) to change the DAC?
I wish to see an example code, please.
Thanks for the help!
Solved! Go to Solution.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-01-29 2:13 PM
- What's the difference between "Connect to external pin / on chip-peripheral options"
I recommend you to choose a Timer, generate pwm or output compare periodic signal on a timer output channel. with a jumper wire, connect it to the DAC trigger pin. Once things looks working well, use internal signals to avoid using 2 GPIOs.
Each timer rise edge for example will trigger a dac update. Typically, you can have a waveform put in Flash or RAM and use a DMA to sweep through all the DAC values to update sequentially and periodically. This is a simple way to make a sinewave. If the Timer generates 1 MHz PWM and the table is made of 1000 samples, the DAC waveform will be 1 kHz period.
My code was using STL on STM32F437, so a bit outdated....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-01-29 2:13 PM
- What's the difference between "Connect to external pin / on chip-peripheral options"
I recommend you to choose a Timer, generate pwm or output compare periodic signal on a timer output channel. with a jumper wire, connect it to the DAC trigger pin. Once things looks working well, use internal signals to avoid using 2 GPIOs.
Each timer rise edge for example will trigger a dac update. Typically, you can have a waveform put in Flash or RAM and use a DMA to sweep through all the DAC values to update sequentially and periodically. This is a simple way to make a sinewave. If the Timer generates 1 MHz PWM and the table is made of 1000 samples, the DAC waveform will be 1 kHz period.
My code was using STL on STM32F437, so a bit outdated....
