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;
I wish to see an example code, please.
Thanks for the help!
Solved! Go to Solution.
2019-01-29 02:13 PM
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....
2019-01-29 02:13 PM
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....