PaulStoffregen / Encoder

Quadrature Encoder Library for Arduino
http://www.pjrc.com/teensy/td_libs_Encoder.html
561 stars 243 forks source link

Added support for ATtiny44 & ATtiny84 #52

Closed wvmarle closed 2 years ago

wvmarle commented 4 years ago

Added support for the ATtiny44 & ATtiny84

Changed interrupt pin definition of the ATtiny441 and ATtiny841 to match the pin number as used by ATTinyCore.

PaulStoffregen commented 4 years ago

Which pin is correct for CORE_INT0_PIN?

@SkullKill send the PR that defined CORE_INT0_PIN as pin 1

@olimexsmart has a pending PR that defines CORE_INT0_PIN as pin 8

This PR changes CORE_INT0_PIN to pin 9.

wvmarle commented 4 years ago

You're mixing up PRs :-) The current CORE_INT0_PIN for the ATtiny441/841 in your master branch is 9. No definition for the ATtiny44/84 there.

The comment at the ATtiny45/85 points to http://hlt.media.mit.edu/?p=1229, which redirects to http://highlowtech.org/?p=1229, that page in turn says it's obsolete and points to yet another page: http://highlowtech.org/?p=1695. This page, which is also old, refers to the old attiny core by damellis (https://github.com/damellis/attiny), where the INT0 pin (physical pin 3) was indeed Arduino pin 9. So that's where the pin 9 comes from.

I don't know if anyone still uses the damellis core; it's basically been superseded by the ATTinyCore by SpenceKonde (https://github.com/SpenceKonde/ATTinyCore). That core uses different pin numbering, now INT0 is pin 1. So that's what I used.

Of note, this pin 9 is in a definition for the ATtiny441/841, which are not supported by the Damellis core at all (the ATtiny44 and ATtiny84 are). So it's definitely wrong.

I have no idea where that pin 8 would come from.

The PR as I submitted is what I use on an ATtiny84 project. It reads my encoder just fine.

olimexsmart commented 4 years ago

Hi to everyone, yes for some reason there was a change in pin numbering for the ATtiny84.

But IMO @wvmarle you are wrong saying that there was a change from Damellis to SpenceKonde, simply because the menu selection "Pin Mapping" from the IDE says so :sweat_smile: But this doesn't matter much.

Conclusion: take a look to the nice pinout schemes in the README of the SpenceKonde repo. Considering that the Pin Mapping used now one is Clockwise:

ATtiny441 CORE_INT0_PIN 9 ATtiny84 CORE_INT0_PIN 8

What I don't understand is that in the master branch the ATtiny441 definition is already there, at line 120 of interrupt_pins.h and is correctly defined at 9. So I'm not understanding what is going on :confused:

PaulStoffregen commented 2 years ago

other pull requests already made this change, closing this old one