SHARE
TWEET

Untitled

a guest May 26th, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* pwm_1khz_01.c ATmega88 @ 1MHz */
  2. #include <avr/io.h>
  3.  
  4. int main(void)
  5. {
  6.     DDRB |= (1<<PB2); // OC1B = output
  7.     OCR1A = 999;        // Top value = 999
  8.     OCR1B = 300;        // Compare Match bei 300
  9.      
  10.     // Clear OC1B on Compare Match
  11.     TCCR1A = (1 << COM1B1) + (1 << WGM11) + (1 << WGM10);
  12.      
  13.     // Mode 15, Fast PWM, OCR1A = TOP, Prescaler = 8
  14.     TCCR1B = (1 << WGM13) + (1 << WGM12) + (1 << CS11);
  15.      
  16.     while(1)
  17.     {
  18.         asm ("NOP");    // Nichts tun
  19.     }
  20. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top