2020-07-06 07:27 AM
I am trying to generate a trapezoidal waveform with slew rate 45V / us that is triggered every 50ms by an interruption generated by a timer. I am using the microcontroller stm32g474, which has 2 DAC with 15MPS. I am using DAC3 with DMA (circular mode) and Timer6.
My main question is:
I am using the DAC interrupt HAL_DAC_ConvHalfCpltCallbackCh1 to detect the end of reading the DAC's array of values and thus disable Timer6 preventing the waveform from repeating itself.
I can generate a waveform as it is supposed to (as can be seen in the figure), however if I increase the frequency to timer6 for example above 10MHz in order to increase the slewrate, the output wave starts to have a lag or repeat (as seen in the figure).
Somehow the interrupt is not generated at the end of the reading of the array of values for the DAC.
How can I solve this problem? Is it a hardware limitation? Is the interruption not fast enough even though it is a high priority?
This is my array values:
const uint16_t Waveform_Ramp_12bits [18] = {0.819,1638,2457,3276,4095,4095,4095,4095,4095,4095,4095,4095,3276,2457,1638,819,0};
2020-07-12 03:39 AM
Could you share the full code for this? I´m struggling to get any signal at all doing the same as you are doing, using STM32CubeMX with HAL, with exactly the stm32g474. It worked for me in the past with other MCUs, so I think I have the correct configuration but somehow the DMA is not transfering the data.
For you question though, the DAC in the STM32G474 as far as I know can only provide 1MPS when connected to external pins. You can get up to 15MSP if you routed internally to other peripherals.
2020-07-12 04:18 AM
I think you forgot that the dac itself has a slew rate. 1msps doesn t mean square wave at half this rate... and the dac output has certain drive, which also has limits and sometime require opamp which can magnify boost dac voltage