Introduce functions that configures Timer 1 with Fast PWM.
This commit is contained in:
parent
96ac9f1507
commit
a3192fc431
@ -1,3 +1,4 @@
|
||||
void initPwmTimer1(void);
|
||||
void initCtcTimer0(void);
|
||||
void initOverflowTimer0(void);
|
||||
void initOverflowTimer1(void);
|
22
src/timer.c
22
src/timer.c
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user