Attiny13a(Clean Embeded C) constantly triggers interupt/looping what's in ISR macro for no reason

I'm not sure if this forum is good place to ask questions about Embeded C but i saw somone doing this without problem so i guess it's fine(and i'm kinda to desperate to care).

WHenever i add ISR macro no matter what vector i use, or whatever interrupts are disabled or enabled Attiny13a is executing whatever is in {} brackets of that macro in a loop.(in this case it blinks LED connected trough transistor on PIN4 instead of turning this LED on until PINB3 is connected to ground)
i even tried SIGNAL macro and it's same.
I'm using avr-gcc with avr dude (Arduino UNO clone "Elego UNO R3" as ISP) on linux mint.

#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
// EMPTY_INTERRUPT(ADC_vect);
ISR(ADC_vect )
{
    _delay_ms(100);
    PORTB |= _BV(PORTB4);
    _delay_ms(100);
    PORTB &= ~_BV(PORTB4);
    reti 	( 		) 	;
}

int main(void)
{   
    cli (); 	

        while (1)
        {
            if (PINB & _BV(PINB3))
            {
                PORTB |= _BV(PORTB4);
            }
            else 
            {
                
                PORTB &= ~_BV(PORTB4);
            }
        }
}

Strangely enough behavior is same after i comment out #include <avr/interrupt.h> compiler only throws some warnings.

You should have no problem doing that with the Arduino IDE or Atmel Studio. Why bother with Embedded?

If you use Arduino, choose the proper core for the ATTiny.

What is wrong with this picture?

The only thing i can see is delay right after interrupt but this isn't causing the problem. Eventually space in

(ADC_vect    ) 

with look ugly (but obviously isn't culprit either)

Yup. That's the one.
200ms of thumb-twiddling in interrupt context.

I want to learn about embeded systems on lower level.(first part of me want to do it with hope that this knowledge will help me get a job as embedded system developer, second want to do it just for "fun" ....and.... third keep telling the first one to stop laying to myself)

whatever " thumb-twiddling" means (no native english speaker) delay is not issue, i put

    PORTB |= _BV(PORTB4);
    PORTB &= ~_BV(PORTB4);

in vector i see LED deeming and when i looked at my oscilloscope it switches really fast in loop.
PS. At least it seems like that but i guess my old made in USSR oscilloscope dosn't catchup.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.