Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <avr/io.h>
- #include <avr/interrupt.h>
- #define czas 130
- unsigned char a;
- int main(void)
- {
- DDRA=0xFF;
- a=20;
- TCCR0=(1<<CS02)|(1<<CS00)|(1<<WGM01); //preskaler 1024 tryb CTC
- OCR0=czas; // przypisanie stałej do rejestru OCR0
- TIMSK|=(1<<OCIE0); // odblokowanie przerwania od zrównania rejestrów TCNT0 i OCR0
- sei(); // globalne zezwolenie na przerwania
- while(1);
- }
- ISR(TIMER0_COMP_vect)
- {
- a--;
- if(a==0)
- {
- a=20;
- PORTA^=0xFF; // negacja bitowa
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement