cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with the ADC/DAC

Endika Caño de Miguel
Associate II
Posted on November 22, 2017 at 11:45

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)

0690X0000060PEMQA2.jpg

Here is the program I write, but it doesn�t work. Could someone help me please???

Thank you in advance

0690X00000604AyQAI.jpg0690X0000060PFYQA2.jpg

#dac #signal #adc #stm32 #stm32l432
6 REPLIES 6
S.Ma
Principal
Posted on November 22, 2017 at 13:11

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.

Posted on November 22, 2017 at 13:30

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.

Posted on November 23, 2017 at 12:07

.

Posted on November 23, 2017 at 12:07

thank you, I don´t know how to do it, but gonna try it.

Posted on November 23, 2017 at 12:09

Thank you, I don´t know how to do it, but will try to figure it out.

Posted on November 23, 2017 at 12:47

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