Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* 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
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement