Last active
May 16, 2019 11:00
-
-
Save avr-programmierung/167ff4f63439dd4e031047386563417d to your computer and use it in GitHub Desktop.
ATmega88 @ 1MHz Pulsweitenmodulation 1kHz 01
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_1khz_01.c ATmega88 @ 1MHz */ | |
#include <avr/io.h> | |
int main(void) | |
{ | |
DDRB |= (1<<PB2); // OC1B = output | |
OCR1A = 999; // Top value = 999 | |
OCR1B = 300; // Compare Match bei 300 | |
// Clear OC1B on Compare Match | |
TCCR1A = (1 << COM1B1) + (1 << WGM11) + (1 << WGM10); | |
// Mode 15, 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