Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <avr/interrupt.h>
- #include <avr/io.h>
- uint8_t stanje=0xff;
- int main(void)
- {
- DDRA=0xff;
- PORTA=0xff;
- MCUCR=1<<ISC01 | 1<<ISC00;
- GICR=1<<INT0;
- // ~2ms interval
- TCCR0= 1<<WGM01 | 1<<CS02 | 1<<CS00;
- OCR0=15;
- sei();
- while(1)
- {
- //TODO:: Please write your application code
- }
- }
- ISR(INT0_vect) {
- GICR=0;
- TIMSK=1<<OCIE0;
- stanje=~stanje;
- PORTA=stanje;
- }
- ISR(TIMER0_COMP_vect) {
- static uint8_t y_old=0, flag=0;
- uint8_t temp;
- temp=y_old>>2;
- y_old=y_old-temp;
- if(bit_is_clear(PIND, PD2)) {
- y_old=y_old+0x3f;
- }
- if(y_old>0xF0 && flag==0) {
- flag=1;
- GIFR|=0b10000000;
- TIMSK=0;
- GICR=1<<INT0;
- }
- if(y_old>0xF0 && flag==1) {
- flag=0;
- TIMSK=0;
- GIFR|=0b10000000;
- GICR=1<<INT0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement