Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <avr/io.h>
- #include <avr/interrupt.h>
- //#define SAMPLE_RATE_DIVISOR 4
- // F_CPU - 8000000UL
- int main(void)
- {
- TCCR0A |= (1 << COM0A1) | (1 << WGM01) | (1 << WGM00); // pwm, oc0a channel, clear on compare/non-inverted
- TCCR0B |= (1 << CS00); // timer0 no prescaling
- TIMSK0 |= (1 << TOIE0); // timer0 ovf int
- OCR0A = 0;
- DDRD |= (1 << PD6);
- sei();
- while(1)
- {
- }
- return 0;
- }
- ISR(TIMER0_OVF_vect)
- {
- static uint64_t t = 0;
- OCR0A = (t*9&t>>4|t*5&t>>7|t*3&t/1024)-1;
- t++;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement