2012-03-20 02:43 PM
Hi all,
Wondering if anyone can help me. I've got the example DAC and ADC programs working fine on the discovery board and am now trying to pass the values read in from the ADC to the DAC. Does anyone know how to do this? Do I have to set up two DMA? Any help / source code would be appreciated. Cheers,2012-03-20 06:51 PM
I presume this is an education excercise. Otherwise, a simple wire bypassing the processor would suffice.
The ADC and DAC are separate peripherals with separate DMA channels/streams. Its your choice - either move the ADC values to the DAC DMA buffer, or point the DAC DMA buffer to the ADC DMA buffer and don't start the DAC until ADC DMA is complete. The first choice is suitable for cases where processing is performed on the ADC values before DACing them. The code examples you have can be merged into one program, but check the DMA section in the reference manual for allowable channel/stream assignments. Cheers, Hal2012-03-21 01:07 PM
Ok, got it working, DMA setup for the DAC and a DMA set up for the ADC and then pass the ADC values to the DAC address.
Works fine but is extremely noisy, even if I put 1V into the ADC, the ADC value remains constant however,the output of the DAC is fluctuating a lot. Any idea why? Feel I might not have configured the DAC.....2012-03-21 01:23 PM
Don't worry, I have solved this problem. It was due to the buffer size.
2013-08-02 03:03 PM
2013-08-03 03:32 AM
Hi romain,
There is an example of ADC=>DAC loopback in STM32F0xx example but without DMA I copy the ADC IRQ handler if(ADC_GetITStatus(ADC1, ADC_IT_EOC) != RESET) { /* Get converted value */ ADCVal = ADC_GetConversionValue(ADC1); /* Output converted value on DAC_OUT1 */ DAC_SetChannel1Data(DAC_Align_12b_R, ADCVal); /* Clear EOC Flag */ ADC_ClearITPendingBit(ADC1, ADC_IT_EOC); } Hope that helps you2013-08-03 10:17 PM
Hey thanks lowpowermcu
This certainly gives me something else to consider.The reason im trying to use DMA is it seems like the perfect candidate for a signal processing application for this chip, as the DMA happens asynchronously, which gives me time to process the signal between transfer cycles.I guess i could use an OS lib for multitasking, but i suspect i will end up with a very noisy jittery conversion in that case. Im very surprised at the lack of examples for this case.As i am not firmware developer by vocation, im having trouble getting my head around this problem.