Question
How can create a tone with timer ?
Posted on February 05, 2014 at 03:04
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