cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G4 DAC white noise

oeliks
Senior

How to set up white noise in stm32g431kb DAC?

DAC works, I can produce sine wave but cant generate white noise.​

​I set DAC->CR WAVE1 to 01 (noise), DAC->CR TEN1 to 1 (trigger enable) and DAC->CR EN to 1 (enable). Tried to set also DAC->CR MAMP1 from 0 to 10 but without a success.

How to generate white noise and how to change it DC offset?

I checked with cube programmer and bits in DAC->CR are actually set as expected. But no white noise on output.​

Thank You​

1 ACCEPTED SOLUTION

Accepted Solutions

> Is it software trigger? ​So do I have to change it to some timer trigger than?

Yes. And you have to run that trigger and set it up so that it outputs given TRGO or whatever signal the DAC needs.

You *can* use "software trigger" (i.e. TSEL1=0b0000), but then you'd need to supply that software trigger, i.e. write 1 into DAC_SWTRGR in a loop. Not very practical, though.

> Still not sure what this MAMP1 will do to this noise (is it amplitude like in triangle wave?) and how to add DC offset.

Yes. You need to set it to 0b1011 for maximum amplitude, or lower value for less than maximum.

DC offset is given by value you write into the "normal" DAC data register. This is added to the "noise". Note, that "noise" is unsigned, i.e. you want to keep the offset at 0 for the maximum amplitude.

All this is easy to test using debugger, directly manipulating values in the DAC register and observing result on oscilloscope - once you set up the timer to trigger.

> I dont really need a real white noise, I want to use it to check the response of low pass filter with FFT on my oscilloscope.

That's exactly where you do need white noise.

JW

View solution in original post

3 REPLIES 3

What is the trigger source? Is it running and generating the triggers?

The output definitively won't be *white* noise, though. Offset is given by content of DAC_DHR register?

JW

oeliks
Senior

DAC->CR TSEL1 set to 0000 (SWTRIG1).

Is it software trigger? ​So do I have to change it to some timer trigger than?

Im sorry, I dont really understand this section in RM.

I dont really need a real white noise, I want to use it to check the response of low pass filter with FFT on my oscilloscope.

Thank You​

Edit: OK ... I think I got it, have to set DAC->SWTRG SWTRG1 bit by software and wait when it will be cleared by hardware in a loop ?

Still not sure what this MAMP1 will do to this noise (is it amplitude like in triangle wave?) and how to add DC offset.

> Is it software trigger? ​So do I have to change it to some timer trigger than?

Yes. And you have to run that trigger and set it up so that it outputs given TRGO or whatever signal the DAC needs.

You *can* use "software trigger" (i.e. TSEL1=0b0000), but then you'd need to supply that software trigger, i.e. write 1 into DAC_SWTRGR in a loop. Not very practical, though.

> Still not sure what this MAMP1 will do to this noise (is it amplitude like in triangle wave?) and how to add DC offset.

Yes. You need to set it to 0b1011 for maximum amplitude, or lower value for less than maximum.

DC offset is given by value you write into the "normal" DAC data register. This is added to the "noise". Note, that "noise" is unsigned, i.e. you want to keep the offset at 0 for the maximum amplitude.

All this is easy to test using debugger, directly manipulating values in the DAC register and observing result on oscilloscope - once you set up the timer to trigger.

> I dont really need a real white noise, I want to use it to check the response of low pass filter with FFT on my oscilloscope.

That's exactly where you do need white noise.

JW