cancel
Showing results for 
Search instead for 
Did you mean: 

Timer

ted korczak
Associate III
Posted on January 18, 2018 at 06:12

Hello

This is a timer code for arduino Atmel can someone help me to convert for using it in STM32F103, please.

// Set up timer 1.

// Prescaler = 1, phase correct PWM mode, TOP = ICR1A

TCCR1A = (1 << COM1A1) | (1 << WGM11);

TCCR1B = (1 << WGM12) | (1 << WGM13) | (1 << CS10); // CTC mode, prescaler = 1

TCCR1C = 0;

OCR1AH = (TIMER1_TOP/2 >> 8);

OCR1AL = (TIMER1_TOP/2 & 0xFF);

ICR1H = (TIMER1_TOP >> 8);

ICR1L = (TIMER1_TOP & 0xFF);

TCNT1H = 0;

TCNT1L = 0;

TIFR1 = 0x07; // clear any pending interrupt

TIMSK1 = (1 << TOIE1);
0 REPLIES 0