Skip to main content
sagar
Associate II
Nov 15, 2018 10:01 AM UTC
Question

Hello, Can anybody tell me how to generate sine waveform using STM32F334R8T6 MCU? It has 3 channels (12 bits) DAC.

I am using STM32CubeMX to generate source code and Keil 5 for compiling the code.

Please help.

Thanks & Regards.

Sagar.

    This topic has been closed for replies.

    11 replies

    AvaTar
    Senior III
    Nov 15, 2018 10:55 AM UTC

    Create a sine value table, and push it out periodically.

    sagar
    sagarAuthor
    Associate II
    Nov 26, 2018 7:14 AM UTC

    Hey Thanks, I got the output.

    Now, when I am generating sinewave triggered at 50% (90 degree and 270 degree) I am not getting precise voltage levels at zero level.

    Please guide me.

    thanks

    Sagar.

    Jeroen3
    Senior
    Nov 26, 2018 8:07 AM UTC

    This does not look like a sine at all.

    sagar
    sagarAuthor
    Associate II
    Nov 26, 2018 7:17 AM UTC

    At zero level some offset voltage gets added (Vmax & Vmin). How to minimize it to zero?

    I am using STM32F334R8T6 based STM32F3 Series board by configuring DAC1 of it.

    Jeroen3
    Senior
    Nov 26, 2018 8:06 AM UTC

    There will always be offset in the DAC. Refer to the datasheet to see how much.

    sagar
    sagarAuthor
    Associate II
    Nov 26, 2018 11:26 AM UTC

    Thank you..

    AvaTar
    Senior III
    Nov 26, 2018 9:51 AM UTC

    The DAC outputs voltages from 0V to Vref (usually 3.3V). There can't be negative voltages on the DAC.

    With the output buffer enabled, the the offset of max. 200mV limits the output span.

    I use to leave that buffer off, and have an external buffer amplifier instead.

    I hope you have an idea on how to create a sine table, and output it continuously to the DAC.

    Jeroen3
    Senior
    Nov 26, 2018 10:28 AM UTC

    Outputting a sine table to the DAC provides a fixed frequency. To variate the frequency you can use a NCO.

    https://en.wikipedia.org/wiki/Numerically_controlled_oscillator