Skip to main content
MJouv
Associate
May 14, 2019
Question

How to generate a white noise with the DAC on STM32L1

  • May 14, 2019
  • 1 reply
  • 2661 views

Hi everyone,

I am currently trying to generate a white noise using my Nucleo STM32L152RE but I do not reach to achieve it.

I used CubeMX to create the init functions.

You can see attached the settings for the DAC ( using the OUT1 configuration) in cubeMX.

I initialized the TIM6 as a timebase, enabled the interrupt, started it with HAL_TIM_Base_Start_IT(&htim6) and in the callback ( it goes in) I call HAL_DAC_Start(&hdac,DAC_CHANNEL_1) to start the DAC, but it does not ouput any noise on A2 it only outputs a DC value such as if I used it to generate a constant voltage.

May be I am totally wrong with the use of the DAC but it seemed correct to me.

If someone could help me, I would be very thankful.

Mathias

This topic has been closed for replies.

1 reply

S.Ma
Principal
May 15, 2019

You'll never get perfect white noise.

DAC has a slew rate and max output rate which will tell you the fastest triagular wave that can be generated.

I would fill an array with random values (uint16_t DAC_Wave[1024]) and use DMA cyclic mode on it.

Generate the sample rate from a timer and use a channel GPIO pin so you can make sure the signal looks good.

Connect the channel clock to the DAC GPIO trigger pin and use it to control the DAC sample rate.

It should generate a kind of pin noise.

MJouv
MJouvAuthor
Associate
May 16, 2019

Hi,

Thanks for your reply, I thought about it, of course it would be easier.

But it is so frustating to bypass this functionality.

Regards