2018-06-19 03:32 PM
Hello,
I have an application where I am using the DAC output to generate a signal which runs through a circuit and is read back on the ADC. The issue I am struggling with is how to control the ADC sampling so that it does not occur at the same moment as the DAC output change. So I think ideally I would like to stagger these two events so that the ADC sample has stabilized before I sample it. Say start sampling the ADC half way through the DAC period. Currently I have two timers and I used an open loop delay (call to HAL_Delay) to create some separation as I measured on a scope. That worked as a temporary prototype but I am now trying to make this more robust.
I've been thinking that timer synchronization may be the solution. I looked through some of the modes described in the reference manual but didn't think any of them fit my situation. Could anyone give me some advice on what mode I might want to accomplish this or recommend an alternative method?
Background: Both the DAC and ADC are being driven at the same sampling rate by two separate timers started at different times. I am using DMA to copy between the memory and peripherals on these same timers. I am using the STM32L432KC microcontroller (Nucleo eval board). I am using the HAL/LL and CubeMx application.
Thank you in advance for any help.
Mike
2018-06-19 03:44 PM
The method workable on other STM32 is to use the same TIM to trigger ADC and DAC, and controlling the phase angle via the UPDATE (CNT==0), CH1 (CNT==CCR1), CH2 (CNT==CCR2), etc
2018-06-19 06:33 PM
Thank you for your reply Clive. I wonder if this would work for me since I am using the timer to trigger DMA and the peripherals.
Do you have an example that you might be able to point me to?
2018-06-19 07:26 PM
Connect the Adc and Dac trigger pins to two channels output compate coming from the same timer. Run the timer faster than the adc sampling frequency in free run mode and skew the compare pulses to get started. Using channel 3 and 4 leaves the more versatile channels 1 and 2 for other purposes. In my case, i used them to generate burst pulses through dma to control integrators analog switches around the op amp... No usuablr sample code available as it was std lib on stm32f437.
2018-06-19 07:52 PM
>>I wonder if this would work for me since I am using the timer to trigger DMA and the peripherals.
Period vs Phase, the pulses can occur at a defined rate, and separation from each other.