2017-11-22 02:45 AM
Hello:
I�m using my STM32L432 to input a signal from the Signal Generator and I�m trying to get the same signal, after
using the ADC and DAC (photo below)
Here is the program I write, but it doesn�t work. Could someone help me please???
Thank you in advance
#dac #signal #adc #stm32 #stm32l4322017-11-22 04:11 AM
A very crude way is to start ADC in free running mode (keeping scanning over and over) and activate DAC once.
In the while loop, you read the ADC.DR (with the proper bit formatting, 8 bit, 12 bit, left or right aligned), format it to the DAC output (unless programmed to be the same) with its buffer enabled.
A cleaner way: Program a timer with 2 output channels, one channel gpio output will go to the ADC trigger (and you can monitor on a oscilloscope before using an internal signal routing later), use the other channel gpio to trigger the DAC output. Then use DMA to push the ADC value to a cyclic RAM buffer, and DMA from cyclic RAM buffer to DAC.
You'll be able to run this pass through, control the sampling and skew rate, and it will work without running SW... the HW will oblige.
2017-11-22 05:30 AM
I would suggest to use the ADC interrupt instead of DMA, and copy the value manually.
I think I see where it's going - manipulating the value before output.
At least for low update rates, this is easier achieved via interrupts.
2017-11-23 04:07 AM
.
2017-11-23 04:07 AM
thank you, I don´t know how to do it, but gonna try it.
2017-11-23 04:09 AM
Thank you, I don´t know how to do it, but will try to figure it out.
2017-11-23 04:47 AM
I used to get the 'inspiration' from SPL examples for the ADC and the DAC - different ones, to make this clear.
First step would be to change the 'continuous mode' setting of the ADC to single conversion, and a timer as trigger.
I would then set up the EOC/EOS interrupt for the ADC (single channel), and implement the DAC output in the ADC interrupt.
That would be the place for manipulating the output value later on.
I use the ADC->DMA mechanism only for multichannel conversions (EOS).
But if you are fine with one-to-one output, the DMA mechanism is better (less code and core load).