cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F446RET6 DAC to generate "an ideal square wave"

Junzhe
Visitor

Hi,

 

I want to generate a bipolar square wave with a pulse width of 100us per phase using the DAC in STM32F446RET6. 

 

Junzhe_2-1747249767726.png

 

But when I measured the DAC output (PA4), I found that the DAC output was not an ideal square wave, but a trapezoidal shape with a long rise time. However, according to the STM32F446RET6 manual, the DAC conversion time should be only a few microseconds. I used the DMA function and triggered the DAC output via Timer 6, but there was no improvement. How can I make the DAC output as perfect as possible?

 

Best,

Junzhe

 

8 REPLIES 8
mƎALLEm
ST Employee

Hello @Junzhe and welcome to the ST community,

According to the datasheet, there is a tSETTTLING parameter: typical 3us / max 6us with the respect of the load characteritics (Buffer ON) as the following:

mALLEm_0-1747251521386.png

So "an ideal square wave" is something not reachable.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

Hmm,

if the diagram is to scale and the timing okay, the edges look much wider than 6µs. So the load may be to high.

hth

KnarfB

AScha.3
Chief III

Hi,

For a "perfect" square wave just use a timer, to put out any kind of square wave, pwm or 50:50 square.

The DAC is better for everything else than a square wave. 

If you feel a post has answered your question, please click "Accept as Solution".

a) DAC with onboard buffer has slew rate about 2V/us (with negligible capacitive load).

b) Clarify how did you made your "scope trace" - it looks distorted

c) Consider using external buffer, then your rising and falling times can be up to ten times shorter (can be seen on following scope trace)

d) If you need realy sharp edges, consider using another method. Like DAC + analog switch etc.

step2.png
Blue trace - Output directly from DAC (on board buffer) 
Yellow trace - output by external buffer (LMH6612 there)

There is also appnote:
https://www.st.com/resource/en/application_note/dm00129215.pdf

Hi,

 

Thank you for your reply. Yes, I understand what you mean. But in the result I got, the rise time is about 50us, which I think is too far from the theoretical value.

 

Best,

Junzhe

Hi KnarfB,

 

I did not put a load on the output of the DAC. I connected it directly to the Powerlab for the measurement.

 

Best,

Junzhe

Hi AScha.3,

 

Because I need the output of the DAC to drive other components. It's not just about generating a square wave. The DAC can output the value I want between 0-3.3V, but the Timer doesn't seem to be able to achieve this function?

 

Best,

Junzhe

 

Hi Michal,

 

Thank you for your reply and plot. I measured the output of the DAC through Powerlab, which is similar to an oscilloscope. I connected the output of the DAC directly to it for measurement. I use the built-in buffer of the DAC in the STM32, but can't it make the output waveform as sharp as possible? If I use an additional external buffer, do I need to disable the built-in buffer?

 

Best,

Junzhe