Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * main.c
- *
- * Created on: 01-04-2013
- * 15:05:56
- * Author: miszczo
- */
- #include <avr/io.h>
- #include <avr/interrupt.h>
- #include <util/delay.h>
- volatile uint8_t pwm;
- int main(void)
- {
- //wyłączenie komparatora
- ADCSRB |= (1<<ACME);
- // wyłączenie adc;
- PRR |= (1<<PRADC);
- // ustawienia portow
- DDRB |= (1<<PB0) | (1<<PB1) | (1<<PB2) | (1<<PB3);
- //konfiguracja timera
- TCCR0B |= (1<<CS00); //preskaler 1
- TIMSK0 |= (1<<TOIE0); //zezwolenie na przerwanie przy przepelnieniu
- sei();
- //char i;
- while(1)
- {
- for(pwm=0;pwm<=255;pwm++) _delay_ms(20);
- for(pwm=255;pwm>=0;pwm--) _delay_ms(20);
- }
- }
- ISR ( TIM0_OVF_vect )
- {
- static uint8_t licznik;
- if(licznik>=pwm) PORTB |= (1<<PB3); else PORTB &= ~(1<<PB3);
- licznik++;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement