cancel
Showing results for 
Search instead for 
Did you mean: 

Signal Pass through using ADC and DAC

JEscu.2
Associate II

The equipment I am using is the following: Nucleo-Board L476RG, STM32CubeIde 1.10.1. I am attempting to design a simple dsp system that uses an ADC to send the data it receives from a function waveform generator to a DAC, and the DAC output will then be connected to an oscilloscope. I am trying to figure out how to use the TIM2 interrupt to drive sampling from PC2 with ADC1, and then immediately send the ADC data to DAC for output from PA4.

The function generator will generate a sin signal with a frequency of 100Hz.

1 ACCEPTED SOLUTION

Accepted Solutions
itsrabbit
Associate II

You should set the timer interrrupt with the frequency you wish. It is calculated by:

TIM Interrup Frequency (Hz) = SYSCLK Freq / (ARR+1)*(PSC+1)

Then, in your interrupt callback function, you can just read the value of ADC:(HAL_ADC_GetValue(&hadcX);

After that, you can generate your DAC signal by writing the value you get. You can increase the interrupt frequency if you want a smoother DAC output signal. Do not forget to check the resolution values of ADC and DAC.

AC

View solution in original post

5 REPLIES 5
itsrabbit
Associate II

You should set the timer interrrupt with the frequency you wish. It is calculated by:

TIM Interrup Frequency (Hz) = SYSCLK Freq / (ARR+1)*(PSC+1)

Then, in your interrupt callback function, you can just read the value of ADC:(HAL_ADC_GetValue(&hadcX);

After that, you can generate your DAC signal by writing the value you get. You can increase the interrupt frequency if you want a smoother DAC output signal. Do not forget to check the resolution values of ADC and DAC.

AC

Javier1
Principal

0693W00000UoVlwQAF.pnghttps://community.st.com/s/question/0D50X0000AnrIsfSQE/stm32f0-peripheral-to-peripheral-dma-transfer

Specifics:

  • ADC in continous mode.
  • Tim2 triggering a DMA (peripheral-to-peripheral transfer) from the ADC result register to the DAC output register.

This way you could get very fast data transfers and your Core is almost free to do whatever you want.

I just checked RM0351 and your MCU should support peripheral to peripheral DMA transfers

0693W00000UoVqcQAF.png0693W00000UoVobQAF.png

we dont need to firmware by ourselves, lets talk

I really appreciate the time you took to reply, your response provided very valuable information :)​

Thank you for explaining how I can incorporate DMA, it helps clear up some questions I had about it. Although I asked for timer interrupt because I had an assignment that specifically asked to use that method.​

Acecream
Associate II

Hello, I am just trying to do the same thing as you, could you please share a little more details about how I can read DAC from internal ADC.

I am using a voltage source and I can read the analog input from that on my screen. But how to transfer that into DAC and how to read the DAC value using a simple oscilloscope(like the hardware connection)?

Thank you for the help in advance!