2022-10-20 10:53 PM
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.
Solved! Go to Solution.
2022-10-21 01:35 AM
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
2022-10-21 01:35 AM
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
2022-10-21 01:54 AM
https://community.st.com/s/question/0D50X0000AnrIsfSQE/stm32f0-peripheral-to-peripheral-dma-transfer
Specifics:
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
2022-10-25 12:22 PM
I really appreciate the time you took to reply, your response provided very valuable information :)
2022-10-25 12:23 PM
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.
2023-02-24 02:35 AM
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!