Interrupts problem (Int0-Int1)

Hello,

I'm using an Arduino Nano board, but I program it in Assembler.

I know this is not the usual way, but I should be a little crazy... I like assembler, and I understand nothing with C, C++ !

I'm using an excellent software "XLOADER" to upload my hex files (from AVR Studio) througt the Arduino bootloader.

But I have a problem with Into and Int1 interrupts, nothing !

I suspect that the bootloader take over interrupt's vectors, Reset and INT0-1 and swap adresses.

Timer's interrupts are ok.

Does anybody know how to get interrupts (Int0-Int1) working, while using Arduino bootloader ?

Thanks for your answers.

I think that there is no correlation between INT0-1 and bootloader. Whenever bootloader finished it jumps to zero address and MCU starts executing your program code. Since this moment bootloader has nothing with. It is up to you to program interrupt vectors and routines correctly.

Hello,

Thanks for your reply.

I agree with what you wrote, but I have checked and checked again,

I can find any reason why this interrupt is not responding in this very basis mode.

To use Int0, I have set :

  • DDRD with 0b11111011 to set PortD.2 as an input

  • EICRA with 0b00000001 (any state change >>> interrupt)

  • EIMSK with 0b00000001 ( Int0)

and instruction "sei" to validate all interrupts,

Does I have forgotten something ?

You haven't stated what the interrupt source is, but you may require pull up or pull down resistors. To set the internal pull up on pin 2 PORTD with 0b00000100

Hello,

I have tested with and without pullup, no change.

My source, an RC receiver (with an other mega328p inside) seems to drive properly the INT0 pin.

If the bootloader is not the perturbator, there is a small error in my program, not detected by AvrStudio

assembler, I check again ....

Thanks,

Time to post your code, buddy. The boot loader does not take over interrupts

What address are you specifying as your ISR?

Hello,

For Int0, it is $0002, just after Reset.

I was confused with that :

(Datasheet Page 67)
When the BOOTRST Fuse is unprogrammed, the Boot section size set to 2K bytes and the
IVSEL bit in the MCUCR Register is set before any interrupts are enabled, the most typical and
general program setup for the Reset and Interrupt Vector Addresses in ATmega328P is:
Address Labels Code Comments
0x0000 RESET: ldi r16,high(RAMEND); Main program start
0x0001 out SPH,r16 ; Set Stack Pointer to top of RAM
0x0002 ldi r16,low(RAMEND)
0x0003 out SPL,r16
0x0004 sei ; Enable interrupts
0x0005 xxx
;
.org 0x3C02
0x3C02 jmp EXT_INT0 ; IRQ0 Handler
0x3C04 jmp EXT_INT1 ; IRQ1 Handler
... ... ... ;
0x3C32 jmp SPM_RDY ; Store Program Memory Ready Handler

But, the problem it is not here, it is located in my code ...... I will find it !