Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed inconsistent documentation, added Tinyx313 pin map #155

Merged
merged 1 commit into from
Nov 25, 2015

Conversation

zador-blood-stained
Copy link
Contributor

This finishes Tiny2313/4313 support by adding pin configuration documentation. Also fixed some incorrect pin names and numbers in other ATtinys doc.

@TMRh20
Copy link
Member

TMRh20 commented Nov 13, 2015

The ATTiny is a bit confusing, I think because of the labeling of the MISO/MOSI pins. Technically the Master-In-Slave-Out (MISO) pin on one device should be connected to the Master-Out-Slave-In (MOSI) pin on the other device.

It seems the labeling standards generally dictate that this is actually reversed on one device, so users can simply connect MISO to MISO and MOSI to MOSI.

If you take a look at this pinout you will see it lists the pins differently than in this updated documentation.

The other part of this is that this document has been changed a couple of times due to the information posted above. I have some ATTiny devices, but can't remember the answer off-hand, so if anybody can add some info or opinions here, it would probably help.

@zador-blood-stained
Copy link
Contributor Author

It is confusing because MOSI and MISO are swapped in tiny datasheets (as if tiny is a slave device), but DI (Data In) and DO (Data Out) labels tell actual pin functions.
image
I have one device based on Tiny45 in 3 pin mode and one device based on Tiny4313, and they both work with pinout in this pull request.
For Tinyx4, nRF24 MOSI and MISO names were swapped, other than that pin numbers should be right (I checked 24/44/84 datasheet too).
Edit: Technically, only one device should be master on SPI bus, and MISO is connected to MISO and MOSI is connected to MOSI. But here we have an MCU, that can be master or slave depending on software configuration, and MOSI and MISO names here are not absolute.
Edit 2: Datasheet, pages 108-110, pins are referenced by DI and DO names.

@TMRh20
Copy link
Member

TMRh20 commented Nov 13, 2015

Lol. Thanks for the info, I think the DI/DO labels pretty much give us the answer but I'm still a bit confused over the labeling, so I'll try to show my work/thinking.

On Uno, MISO (DI) is pin 12, and is listed as connecting to nrf pin 7 (MISO). This leads me to believe that the nrf is following the standard, and the nrf MISO labeled pin is the DO pin.

If you look at this nrf24l01 pinout it lists the nrf24l01 pin6 as MOSI (DI) and nrf pin 7 as MISO (DO).

So if we compare the UNO to the ATtiny, and use the same standard, the DI pin of the tiny (MOSI above) should connect to nrf pin 7 (MISO/DO).

Using the same logic, and looking at the existing documentation for the ATtiny24/44/84, it looks like pin8 is DO so it should be connected to nrf pin 6 (MOSI/DI).

In the end however, if my logic is flawed, you can simply trace the wiring from the ATtiny to the nrf24l01 and tell me which pin numbers are actually connected when it is working, and I will do the same as soon as I can.

@zador-blood-stained
Copy link
Contributor Author

Well, NRF can only be a slave device, and it will output data to its Master In Slave Out pin and input it from Master Out Slave In.
ATMega328 (and 2560 on Arduino Mega) has separate SPI and I2C controllers instead of USI, SPI controller is more complex, and MOSI and MISO pin functions (input or output) are changed in Master or Slave modes (if I understand datasheet right), so here we don't have DI and DO logic. Datasheet, page 160.
On Tiny, however, one of USI data pins is always input (Edit: In SPI mode) and another is always output, it is a hardware limitation to make simpler and cheaper device, I guess.
I double checked my notes and actual wirings before making a pull request, but it's OK if you want to test it yourself or wait for comfirmation from other users.

@TMRh20
Copy link
Member

TMRh20 commented Nov 13, 2015

With the Arduino SPI library, the MCU is always SPI master. The MISO and MOSI functionality remains static, while the slave is selected using the SS/CS pin.

Double checking my work, it looks like I was referencing your updated document the whole time, which means we are in agreement.

ATtiny 2313:
pb5 is DI which would connect to nrf pin 7 (MISO)

ATtiny 45:
pb0 is DI which would connect to nrf pin 7 (MISO)

Attiny 44:
pa6 is DI which would connect to nrf pin 7 (MISO)

I still do want to double check the wiring myself, just because I know this has changed a couple times, and I want this to be the last. 🍺

TMRh20 added a commit to nRF24/RF24Network that referenced this pull request Nov 25, 2015
Dynamic payloads were left disabled by default on ATtiny while being
enabled by default for everything else.

Confirm ATtiny pins for documentation per
nRF24/RF24#155
TMRh20 added a commit that referenced this pull request Nov 25, 2015
Fixed inconsistent documentation, added Tinyx313 pin map
@TMRh20 TMRh20 merged commit 4554f73 into nRF24:master Nov 25, 2015
@TMRh20
Copy link
Member

TMRh20 commented Nov 25, 2015

@zador-blood-stained Thanks for taking the time to not only point this out, but to fix the documentation also!

TMRh20 added a commit to TMRh20/tmrh20.github.io that referenced this pull request Nov 25, 2015
@TMRh20 TMRh20 mentioned this pull request Mar 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants