cancel
Showing results for 
Search instead for 
Did you mean: 

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?

jhasa.2
Associate III
 
6 REPLIES 6
jhasa.2
Associate III

0693W00000WJZXpQAP.png

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

JW​

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.

thank you I disable buffer and problem has been solved!

@Community member​