Advertisement
Guest User

Untitled

a guest
Feb 16th, 2019
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.55 KB | None | 0 0
  1. #include <avr/io.h>
  2. #include <avr/interrupt.h>
  3.  
  4. //#define SAMPLE_RATE_DIVISOR 4
  5.  
  6. // F_CPU - 8000000UL
  7.  
  8. int main(void)
  9. {
  10.  
  11.     TCCR0A |= (1 << COM0A1) | (1 << WGM01) | (1 << WGM00); // pwm, oc0a channel, clear on compare/non-inverted
  12.     TCCR0B |= (1 << CS00); // timer0 no prescaling
  13.     TIMSK0 |= (1 << TOIE0); // timer0 ovf int
  14.     OCR0A = 0;
  15.     DDRD |= (1 << PD6);
  16.     sei();
  17.     while(1)
  18.     {
  19.  
  20.     }
  21.  
  22.     return 0;
  23. }
  24.  
  25. ISR(TIMER0_OVF_vect)
  26. {
  27.     static uint64_t t = 0;
  28.     OCR0A = (t*9&t>>4|t*5&t>>7|t*3&t/1024)-1;
  29.     t++;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement