Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <avr/io.h>
- #include <avr/interrupt.h>
- volatile unsigned char i;
- // pretečenie počítadla TCNT0 - nastane každých 128us*256 = 32,768ms
- ISR (TIM0_OVF_vect){
- // 15*32.768 = 491,52ms
- if(i == 15){
- PORTD ^= (1 << PD7); // finta s log. operáciou XOR - neguje len pin PD7
- i=0;
- }
- i++;
- }
- int main(){
- DDRD |= (1 << PD7); // PD7 ako výstupný
- TCCR0 |= (1 << CS02) | (1 << CS00); // preddelicka /1024 (128us)
- TIMSK |= (1 << TOIE0); // prerušenie pri pretečení TCNT0
- sei(); //povol globálne prerušenia
- while(1); //nekonenčná slučka
- return 0;
- }
Add Comment
Please, Sign In to add comment