Interrupt handling without "attachInterrupt" causes reset

Hey there!
I was just playing around with my Arduino UNO and for various reasons i'd like to use interrupts without using the "attachInterrupt" function.
But when I do, triggering the interrupt causes the UNO to reset.

I've read the datasheet section 17 (External Interrupts), but didn't find a hint.

Here's my code:
(I stripped away as much as possible)
Thanks in advance for any hint.

#define pinButtonLow 2    // Button pulls pin to LOW

volatile int IntButtonCalled = 0;

// the setup function runs once when you press reset or power the board
void setup() {
    Serial.begin(9600);
    Serial.println("Interrupt Demo");
    
    pinMode(pinButtonLow, INPUT_PULLUP);

//    EICRA |= (1 << ISC00);    // set INT0 to trigger on ANY logic change
    // for testign I leave EICRA on 0, so INT0 triggers on LOW - same as above
    EIMSK |= (1 << INT0);     // Turns on INT0
}

int count = 0;

// the loop function runs over and over again forever
void loop() {
    Serial.println(count++);

    if (IntButtonCalled) {
        Serial.print("Interrupt ");
        Serial.println(IntButtonCalled);
        IntButtonCalled=0;
    }

    delay(2000);
}

ISR(PCINT0_vect) {
    IntButtonCalled = 2;
}

i'd like to sue interrupts

It seems in the U.S.A. you can try and sue anything.

In machine code you just need to set the interrupt vector to the address of the ISR function, something I can't see your code doing. But in C it is a bit more complex than this as internal registers need to be saved and restored.

for various reasons i'd like to sue use interrupts without using the "attachInterrupt" function.

Can you name just one please? I am sure it will not be valid.

I believe this is because the default interrupt vector is WDT so resetting is the expected behavior.

Grumpy_Mike:
In machine code you just need to set the interrupt vector to the address of the ISR function, something I can't see your code doing. But in C it is a bit more complex than this as internal registers need to be saved and restored.

I thought that is done by declaring the function as ISR and the mapping is done via the name.
If not, how do code samples like that
https://playground.arduino.cc/Main/PinChangeInterrupt
work at all?

SO, how do I set the vector then?

Can you name just one please? I am sure it will not be valid.

The most simple one: I want to understand how it's done without having the arduino-framework do it for me.
Just in case I need to do the same thing without the arduinoIDE, let's say using AtmelStudio.

Aaaaah!

I think I found it.

I used
ISR(PCINT0_vect) {
but I should use
ISR(INT0_vect) {

Thanks for hints.

Ralf

Yes, pinchange interrupts are another set of interrupts..

The most simple one: I want to understand how it's done without having the arduino-framework do it for me.
Just in case I need to do the same thing without the arduinoIDE, let's say using AtmelStudio.

Not very valid. The Arduino code is open source, you already have the source code for that function in the IDE already. If you want to know what happens then look at the code you already have.

Grumpy_Mike:
Not very valid. The Arduino code is open source, you already have the source code for that function in the IDE already. If you want to know what happens then look at the code you already have.

That's what I did, but I did a copy-paste error.
And things like that happen easily, as you have to work through heaps of pin-mapping and other stuff.
There there are tons of initialization code, I thought my code didn't work because of some stuff from there.

But I am sure you have never made a mistake like that, so I apologize for my stupid behaviour.
I am only human and I thought, the purpose of this forum is to ask questions.
Now I understand, it's here to praise you.

Grumpy-Mike, you are the best!

That's what I did, but I did a copy-paste error...... .. so I apologize for my stupid behaviour.

No your stupid behavior is in not mentioning that fact in your post.

Grumpy-Mike, you are the best!

Maybe, but I am not any good at being a mind reader. How good are you at that?

:slight_smile:
Mike, it's a forum - get used to people who are asking questions.

And always be glad about people who try to dig deeper and try to understand how things work.
That's just my option on that.

However, thanks for pushing me in the right direction.