AnsweredAssumed Answered

How can create a tone with timer ?

Question asked by H.Rick on Feb 5, 2014
Latest reply on Feb 12, 2014 by H.Rick
Guys

How can create a tone with timer on STM32 ?

This code is the way I made it on AVR, how can I mimic it on STM32 ?
timer1_ctc_init()
{
    TCCR1A =  // Mode 4 CTC 1:64 Prescaler
    _BV(COM1A0);   // set OC1A on compare match, clear them at top
    //| _BV(COM1A1);   // set OC1A on compare match, clear them at top
     
    //TCCR1B |= _BV(CS11) | _BV(CS10) | _BV(WGM12);
    TCCR1B |= _BV(CS11) | _BV(WGM12); //1:8 pre scaler
 
}
 
void tone(int freq)
{
    timer1_ctc_init();
    OCR1A=freq;
 
}
thanks

Outcomes