Skip to content

Instantly share code, notes, and snippets.

@avr-programmierung
Last active May 16, 2019 11:00
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/7be82970fbc6fcb00090625398102f3f to your computer and use it in GitHub Desktop.
Save avr-programmierung/7be82970fbc6fcb00090625398102f3f to your computer and use it in GitHub Desktop.
ATmega88 @ 1MHz Pulsweitenmodulation 1kHz 02
/* pwm_1khz_02.c ATmega88 @ 1MHz */
#include <avr/io.h>
int main(void)
{
DDRB |= (1<<PB1); // OC1A = output
ICR1 = 1000; // Top Value = 1000
OCR1A = 700; // Compare Match bei 700
// Clear OC1A on Compare Match
TCCR1A = (1 << COM1A1) + (1 << WGM11);
// Mode 14, Fast PWM, OCR1A = TOP, Prescaler = 8
TCCR1B = (1 << WGM13) + (1 << WGM12) + (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