2

I am a newbie to using arduino.

I am using an arduino NG (using an atmega8). One of the pins is a button that triggers an interrupt.

The problem I am trying to solve is that I want an arduino NG to store the timestamp (we are using mills as a timer -no need to consider the 50 day rollover error here) when the interrupt pin is pressed.

The timer of the interrupts in milliseconds is stored in an array and there are up to 100 such interrupt button presses.

After searching around I didnt find any information for using interrupts with atmega8 on arduino NG (though there is information of how to use interrupts on atmega168 with arduino NG ).

So my question is: Is this problem solvable with an atmega8 arduino NG? Does the atmega8 arduino NG have interrupts? Just need one interrupt. And what would be the code to read an interrupt on atmega8 version of arduino NG?

  • Why do you believe that the ATmega8 is that different from the ATmega168 given that the Arduino libraries are designed to abstract away details? – Ignacio Vazquez-Abrams Dec 28 '16 at 1:44
  • @IgnacioVazquez-Abrams regarding interrupts atmega8 is different168 there-so that may imply the the same code wont work -and I couldnt find any examples when searching – Pete Dec 28 '16 at 1:50
1

Does the atmega8 arduino NG have interrupts?-

Page 1 of the datasheet:

Atmega8 datasheet

Yes, it has interrupts.


just need one interrupt.

Page 46 of the datasheet:

Atmega8 interrupts

It looks like you have 19 of them.


regarding interrupts atmega8 is different168 there-so that may imply the the same code wont work -and I couldnt find any examples when searching

Try using the Arduino libraries. If that doesn't work post your code.

0

ATmega8-family chips have 19 interrupt vectors, vs 26 in ATmega48/88/168/328-family chips. (See Table 16.1, Interrupt Vectors in ATmega8A, in chapter 16 of ATmega8 documentation; and see Table 12.1, Interrupt Vectors in ATmega48A and ATmega48PA; Table 12.2, Interrupt Vectors in ATmega88A and ATmega88PA; and Table 12-4, Reset and Interrupt Vectors in ATmega168A and ATmega168PA, in chapter 12 of the ATmega48/88/168/328-family datasheet.)

Both families have INT0 and INT1 External Interrupt Request pins, so if either of those is the pin your application depends on, it should work ok on an ATmega8 system.

I don't see any mention of pin-change-interrupts in ATmega8 documentation so an application depending on PCI's probably wouldn't work.

-1

You should check against the datasheet;

Does the atmega8 arduino NG have interrupts?-just need one interrupt.

It has two external interrupts.

And what would be the code to read an interrupt on atmega8 version of arduino NG?

google or read the datasheet. It is fairly simple to set up and use.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.