Created
May 16, 2019 10:59
-
-
Save avr-programmierung/3af3f6afd15c4c241ec7e8ccbea9b608 to your computer and use it in GitHub Desktop.
ATmega88 @ 8MHz Phasenkorrektur
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* pwm_phasecorrect_01.c ATmega88 @ 8MHz */ | |
#include <avr/io.h> | |
int main(void) | |
{ | |
DDRB |= (1<<PB1); // OC1A = Ausgang | |
ICR1 = 1000; // ICR = Top Wert bei 1000 | |
OCR1A = 750; // Compare Match für OC1A bei 500 | |
// Mode 10: PWM, Phase Correct, Prescaler = 8, Clear OC1A on compare match | |
TCCR1A = (1 << COM1A1) + (1 << WGM11); | |
TCCR1B = (1 << WGM13) + (1 << CS11); | |
while(1) | |
{ | |
asm ("NOP"); // Nichts tun | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment