cancel
Showing results for 
Search instead for 
Did you mean: 

How to get external signal through ADC and send through DAC on a Nucleo-64 STM32F446RE

JRatt.2
Associate II

Hello guys.

I am using an nucleo-64 STM32f446RE development board and I am trying to sample a sine wave (532.2Hz/1.4Vpp) from a function generator. I am new to stm32 devices so I though I would use polling method for ADC, I know is usually the worse method and Interrupts or DMAs are better but I wanted to started with polling as it is the easiest. My code below compiles evrything fine, but when I connect to a oscilloscope, I don't get any signal. Can anyone help understand what is wrong with my code in general? thanks

System configurations

PA5 - DAC-Out1

PA0 -ADC2_IN0

sampling time 15 cycles

resolution 12bits

in the figure below, note that variable "adc_val" is assigned to uint32_t

0693W00000YAc4bQAD.png

2 REPLIES 2
Javier1
Principal

>> I know is usually the worse method and Interrupts or DMAs are better

There is no a better or worse solution, but yes DMA is faster.

What are you getting in adc_val?

For speed:

You should try first only the DAC outputting values from a lookuptable.

The speed of the DAC is what is going to limit your project.

we dont need to firmware by ourselves, lets talk
S.Ma
Principal

I guess you have in mind to do some SW filterming down the road, and now trying to use an MCU as a "jumper wire".

Use a Timer to output a PWM which will be connected to the ADC trigger input pin.

This will be the ADC sample rate. it has to be slower than the ADC conversion time to avoid aborted conversions. Real world has physical limits.

Now use DMA in cyclic mode to fill a buffer over and over again.

Set your DAC with a trigger pin which is connected externally to the same PWM.

Use another DMA channel reading through the same buffer in cyclic mode.

And it should work. Once you want to modify your analog, you'll manipulate the buffers half content while the other half is read/written. Something like this. Interrupt will let you know which half buffer is now available for "processing".