Introduce functions that configures Timer 1 with Fast PWM.

This commit is contained in:
Marco 2022-05-29 16:47:15 +02:00
parent 96ac9f1507
commit a3192fc431
2 changed files with 23 additions and 0 deletions

View File

@ -1,3 +1,4 @@
void initPwmTimer1(void);
void initCtcTimer0(void);
void initOverflowTimer0(void);
void initOverflowTimer1(void);

View File

@ -6,6 +6,28 @@
#include "include/timer.h"
void initPwmTimer1(void)
{
/* Enable Fast PWM with TOP in OCR1A */
TCCR1A |= (1 << WGM11) | (1 << WGM10);
TCCR1B |= (1 << WGM13) | (1 << WGM12);
/* Clock prescaler of 8 */
TCCR1B |= (1 << CS11);
/* Set OC1B on compare match, clear OC1B at TOP */
TCCR1A |= (1 << COM1B1);
/* Enable Counter1 Compare Match B Interrupt */
TIMSK1 |= (1 << OCIE1B);
/* TOP value */
OCR1A = 1000;
/* Compare Match with OCR1B */
OCR1B = 900;
}
void initCtcTimer0(void)
{
/* Initialize counter 0 */