STM32 Tutorial #15 - Sine wave on DAC with DMA

Поділитися
Вставка
  • Опубліковано 12 лис 2024

КОМЕНТАРІ • 10

  • @niclash
    @niclash 2 місяці тому +1

    Instead of double defining things like SAMPLE_FREQ, you can create "User Constants" in CubeMX, assign a value there and then use that constant in both generated initialization code as well as any custom code. Those "User Constants" show up (IIRC) as #defines in main.h

    • @stm32world
      @stm32world  2 місяці тому

      I did that in the last video #14. In this case however, it is a bit more complicated. I guess I _could_ calculate the value from the prescaler and counter values of the timer. But put that down as pure laziness ;)

  • @IsaacFraser-y4x
    @IsaacFraser-y4x 26 днів тому

    great vid, ta

    • @stm32world
      @stm32world  25 днів тому

      Thanks, glad you liked it.

  • @capistor1
    @capistor1 2 місяці тому

    This couldn't have been uploaded at a better time. Been having some issues with DAC. I was hoping to trigger the DAC1 that will output triangle wave and look for the completed flag and then increment the DAC2 by value of 1. I was hoping to do this continuously in the background without interfering with processor.. most i have managed to do till now is normal mode and circular mode examples by changing the frequency of triggering but i can't yet do that combination without involving processor too much. Any advice would be appreciated

    • @stm32world
      @stm32world  2 місяці тому

      Well, the DAC of the STM32F4xx MCU I was using in this example can actually do triangle wave without any calculation at all - you just need to feed the frequencies. Let me know if you can make that work - if not I could do a short video on it.

    • @capistor1
      @capistor1 Місяць тому

      ​@@stm32world actually that sounds awesome.. i'll try that today.. i'm more worried about triggering the 2nd dac after the completion of the triangule wave.. i'm hoping that i can stop the wave generation somehow with the complete callback and then switching to generation of it again once the 2nd dac is incremented? i'm not sure, i'll give it a go... also i'll record a video of what i'm trying to do. i'm sure you'll love it..

    • @capistor1
      @capistor1 Місяць тому

      ​@@stm32world I tried but am unable to work with dma interrupts specifically i'm not sure how to look for interrupt when dac is finished outputting a triangle wave. Also i'm trying to start the triangle wave through built in settings but i'ts not working.. i would appreciate it if you could create a video on how how to enable and look out for transfercomplete interrupts and do some work in the callback.

    • @stm32world
      @stm32world  Місяць тому

      @@capistor1 I am not sure I understand what it is you want to achieve. If you look at my DAC example I calculate a sine wave. Nothing would prevent you from doing a triangle wave instead - in fact the math is simpler. Then you can trigger whatever you want in that callback once the wave is completed. I can have a look at the triangle generation later, there's quite a lot about it in the reference manual. But right now I am preparing some I2C videos and I need to get them out of the way first ;)

    • @stm32world
      @stm32world  Місяць тому

      @@capistor1 you might want to have a look at AN3126 here: www.st.com/resource/en/application_note/an3126-audio-and-waveform-generation-using-the-dac-in-stm32-products-stmicroelectronics.pdf