Skip to main content
sdura
Visitor II
February 10, 2019
Question

Playing wav file using internal dac

  • February 10, 2019
  • 1 reply
  • 800 views

Can you explain how to play wav file using internal DAC and how to set the frequency for wav file using timer.Since I am a beginner any help from you guys will be a great boon for me guys

    This topic has been closed for replies.

    1 reply

    Tesla DeLorean
    Guru
    February 10, 2019

    Perhaps start by outputting a wave form, say a sine wave via the DAC. Create a table containing samples.

    The TIM divides down an APB clock

    OUTCLK = (TIMCLK / P) / Q; where Prescaler = P-1, and Period = Q-1

    You should be able to factor this where the APB clock is say 40 MHz and you want 8 KHz sample clock.

    40,000,000 / 8,000 = 5,000

    P = 1, Q= 5000

    Prescaler = 0, Period = 4999

    If you sine table has 20 samples, a DAC triggered at 8000 Hz would give you a 400 Hz sine wave

    Learn to do the simpler tasks, and then combine into more complicated ones.

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..