cancel
Showing results for 
Search instead for 
Did you mean: 

Timer setting for Sound Player

Giuseppe Giglio
Associate
Posted on July 25, 2017 at 19:20

I want to use the DAC peripheral on my stm32L073RZT to play a waveform at a given sampling frequency, 8KHz in my case.

I'm trying to set a timer to set a value on the dac peripheral but im struggling with the configuration.

Prescaler:

uwPrescalerValue = (

uint32_t

)(SystemCoreClock / 8000) - 1;

SystemCoreClock is at 32MHz

Timer Setting:

TimHandle.

Init

.

Period

           

= 0;

TimHandle.

Init

.

Prescaler

       

= uwPrescalerValue;

TimHandle.

Init

.

ClockDivision

   

= 0;

TimHandle.

Init

.

CounterMode

     

= TIM_COUNTERMODE_UP;

Am i doing something wrong? I used Period = 0 to enter the callback at a frequency of 8KHz, is this design correct?

Thank you for your help!

#timer #sound #stm32l0 #dac
2 REPLIES 2
Posted on July 26, 2017 at 11:42

Hello

must not use period 0 because the counter is blocked

8 Khz has 125 microsecond period.

presc=31 and period 124

Presc=0 and period 3999

TimHandle.

Init

.

ClockDivision

=0;

or other combinations..

Posted on July 26, 2017 at 12:20

I will try this solution and give you feedback! Thank you!