damellis / attiny

ATtiny microcontroller support for the Arduino IDE

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Missing digitalPinToInterrupt definition

madmalkav opened this issue · comments

The core doesn't define digitalPinToInterrupt for attinys.

I think correct implementation for attiny8 is:

define digitalPinToInterrupt(p) ( (p) == 2 ? 0 : -1)

and for attiny14:

define digitalPinToInterrupt(p) ( (p) == 8 ? 0 : -1)

I though the sale but it seems all pins can be interrupt in the tiny85. Does anyone have a working interruptions code with damellis/attiny?

No this is wrong.

There are PinInterrupts (1 on Attiny I think) and PinChangeInterrupts (all pins on Attiny x5).

This code should work, but was never tested by me, at least not for Attinys, but for All other platforms:
https://github.com/NicoHood/PinChangeInterrupt

PinInterrupt issue still exist though, and should be added as well.

Thanks @NicoHood I'll try. I tried some other similar code but there was some incompatibility with SoftwareSerial.

It is incompatible too. Otherwise you have to code your own interrupt vectors. Then you are working on such a low level where the Arduino IDE doesnt suit your needs anymore or a 328 would be the better choice.

Yeah, I am going to use a 328. Too much hustle. The tiny85 is just lovely, but not this time

FWIW, I think the discussion above about supporting PCINT interrupts on all pins is orthogonal to the subject of this issue. The digitalPinToInterrupt() macro should apply for pins supported by the attachInterrupt() function, which I think the above proposals do. The PCINT interrupts are not supported by attachInterrupt(), but this applies equally to ATmega and ATtiny.