Skip to content

Instantly share code, notes, and snippets.

@avr-programmierung
Created May 16, 2019 10:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save avr-programmierung/3af3f6afd15c4c241ec7e8ccbea9b608 to your computer and use it in GitHub Desktop.
Save avr-programmierung/3af3f6afd15c4c241ec7e8ccbea9b608 to your computer and use it in GitHub Desktop.
ATmega88 @ 8MHz Phasenkorrektur
/* 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