Skip to content

Instantly share code, notes, and snippets.

@avr-programmierung
Last active May 14, 2019 11:25
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/d04dc3fb80b3b691458951d1a888ae05 to your computer and use it in GitHub Desktop.
Save avr-programmierung/d04dc3fb80b3b691458951d1a888ae05 to your computer and use it in GitHub Desktop.
Fast PWM Pulsweitenmodulation
/* fast_pwm_01.c ATmega88 @ 8MHz */
#include <avr/io.h>
int main(void)
{
DDRB |= (1<<PB1); // OC1A = output
OCR1A = 307; // Compare match bei 307 = 30% Duty Cycle
TCCR1A = (1 << COM1A1) + (1 << WGM11) + (1 << WGM10); // Lösche OC1A @ Compare Match
TCCR1B = (1 << WGM12) + (1 << CS11); // Mode 7, Fast PWM 10-bit, Prescaler = 8
while(1)
{
asm ("NOP"); // Nichts tun
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment