Skip to main content
jhasa.2
Associate III
Question

I use HAL_DAC_SetValue(&hdac, DAC_CHANNEL_1, DAC_ALIGN_12B_R, sinArray[m]); for produce SinWave and the sinArray is setting by for(int i=0;i<360;i++){ sinArray[i]=(2047*sin((i*3.14)/180))+2047; } but the Analog wave is clipping why?

..

This topic has been closed for replies.

6 replies

jhasa.2
jhasa.2Author
Associate III

0693W00000WJZXpQAP.png

waclawek.jan
Super User

Do you use DAC's output buffer? That does not go rail to rail.

​

JW​

jhasa.2
jhasa.2Author
Associate III

yes

I have been enabled it.

S.Ma
Principal

Learn embedded debugging.

Put a breakpoint in your loop, view the dac register, write 0x0fff and check on your scope first. Then if it look ok, watch your sintable values. Last, check errata sheet as sanity check. DAC usually has hardcoded sawtooth waves for testing. Normal wave gemeration uses dma cycling through a buffer, the dac being triggered by a timer pwm which tells the sample out tempo.

S.Ma
Principal

And make sure the dac pin is only going to the scope probe to factor out vdda and protection diods.