Skip to main content
sameh_ghobashi
Visitor II
December 5, 2012
Question

Help with ADC DAC with DMA

  • December 5, 2012
  • 5 replies
  • 1133 views
Posted on December 05, 2012 at 14:06

Hello everyone, I'm trying to generate sine wave using DAC from the STM32F0 discovery kit from 1hz to 10khz, and use ADC to read back the signal, TIM2 is used to clock the sine_table>>DMA>>DAC, by changing TIM2.Period I can have the required frequencies but I noticed distorted sine wave at lower frequencies, anyway the difficult problem is to read the signal back by ADC1.

how to maintain like a 200-300 sample/frame for that range,

I tried to use TIM2 to trigger both DMA for DAC and ADC but at lower frequencies, ADC will see only a part of the signal, while at higher frequncy will capture many cycles of the sine wave, my question is how to sync both DAC and ADC through DMA so ADC will just cover one cycle of the sine wave throuth the frequency range?

any help or clue is appreciated
    This topic has been closed for replies.

    5 replies

    raptorhal2
    Lead
    December 10, 2012
    Posted on December 11, 2012 at 00:34

    One problem may be that the DAC, even with the internal buffer on does not have enough drive current for the ADC input at short sample times. Read the F0 data sheet for DAC output and ADC sampling time and input impedance characteristics. An external buffer amplifier may be needed.

    Consider not using DMA. At each Timer2 interrupt, DAC output the next sine table entry, then ADC input the DAC value. With a bit of logic on the ADC value, you can save one cycle in a buffer for later inspection. Then exit the interrupt.

    Cheers, Hal

    gibba
    Associate II
    December 16, 2013
    Posted on December 16, 2013 at 01:03

    Hi gho.sam,

    I'm trying to develop the same application. Could you help me with the code?

    Thanks,

    Gilberto

    Tesla DeLorean
    Guru
    December 16, 2013
    Posted on December 16, 2013 at 01:19

    Someone who posted once on the forum over a year ago is not going to help you with this.

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    Tesla DeLorean
    Guru
    December 16, 2013
    Posted on December 16, 2013 at 01:35

    [DEAD LINK /public/STe2ecommunities/mcu/Lists/STM32Discovery/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/STM32Discovery/ADC%20and%20DMA%2c%20again&FolderCTID=0x01200200770978C69A1141439FE559EB459D75800084C20D8867EAD444A5987D47BE638E0F&currentviews=237]https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Discovery/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/STM32Discovery/ADC%20and%20DMA%2c%20again&FolderCTID=0x01200200770978C69A1141439FE559EB459D75800084C20D8867EAD444A5987D47BE638E0F¤tviews=237

    [DEAD LINK /public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Help%20with%20simple%20ADC%20on%20STM32F4&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=593]https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2Fcortex_mx_stm32%2FHelp%20with%20simple%20ADC%20on%20STM32F4&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B¤tviews=593
    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    gibba
    Associate II
    December 16, 2013
    Posted on December 16, 2013 at 14:33

    Thanks a lot, clive1.

    Gilberto