Pages: [1] 2 3   Go Down
Author Topic: ATTiny 25/45/85/2313 Pin numbers  (Read 8634 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have successfully programmed ant ATTiny 45 with my Arduino UNO. Since I am new to the Arduino community I have a couple of questions to ask.

What I don't understand is why the chips physical pin numbers aren't used in the sketch ? When I programmed the Tiny 45, I used phydical pin 5 on the chip but in the sketch it's known as pin 0.

If I wanted to use the ATTINY 2313, ATTiny 84, ATTiny 85, what are the physical chip pins known as in the sketch ?

 
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 207
Posts: 12912
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


Which core(s) are you using?
Logged

Argentina
Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

first time posting smiley-grin

found this "cheatsheet" (akafugu.jp) with pinouts of some atmel micros (pin 5 in attiny x5 shows as pb0) hope you can use it.

please sorry for my english, it's not my main language.

 



* microcontroller-reference-sheet-1.png (281.1 KB, 570x786 - viewed 878 times.)
Logged

Denmark
Offline Offline
Edison Member
*
Karma: 35
Posts: 1072
Happy Hobbyist
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

If you are using this core:

http://code.google.com/p/arduino-tiny/
You can find the pin numbers in the file core_pins.h

Fx for Attiny 2313:

Code:
#define PIN_D0  ( 0)
#define PIN_D1  ( 1)
#define PIN_A1  ( 2)
#define PIN_A0  ( 3)
#define PIN_D2  ( 4)
#define PIN_D3  ( 5)
#define PIN_D4  ( 6)
#define PIN_D5  ( 7)
#define PIN_D6  ( 8)
#define PIN_B0  ( 9)
#define PIN_B1  (10)
#define PIN_B2  (11)
#define PIN_B3  (12)
#define PIN_B4  (13)
#define PIN_B5  (14)
#define PIN_B6  (15)
#define PIN_B7  (16)
#define PIN_A2  (17)  /* RESET */

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the replies.

However, I still don't understand why the physical pin numbers of these chips aren't used in the sketch like they are if you are using the 328 on the main Arduino board ?
Logged

Argentina
Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the replies.

However, I still don't understand why the physical pin numbers of these chips aren't used in the sketch like they are if you are using the 328 on the main Arduino board ?

look at the "cheatsheet" attached in my last reply, in the arduino board the pins are already labeled and traced to the headers so atmega328 physical pin 19 is Digital 13 in the board,  , (try looking at the front of the arduino pcb board and trace physical pin 28 to A5, that's the best way to "understand" the layout)....

p.d.: im a newbie too in this, sorry if i misunderstood something....
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 20
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks charlie_dream now I understand. We aren't using the actual pin numbers of the chip itself. We're using the pin 'function'. In the case of the ATTiny 45, physical pin 5 is PB0. Therefore we're referencing 0 (zero) like digitalWrite(0, HIGH); zero referring to PB0 of the chip.

Duh on me. I guess I need to read a little better.  LOL
Logged

Tokyo, Japan
Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

We've updated the cheat sheet that was mentioned earlier in this post to include Arduino-tiny pinouts for the ATTiny2314/4313 as well as ATTiny25/45/85.

If you are interested, it can be downloaded here:
http://fb.me/1sv07S3Pj
Logged


0
Offline Offline
Full Member
***
Karma: 0
Posts: 117
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks karl_b. Really useful cheatsheet.

BTW, there's another easy way to check the pin-out and logical pin numbers...

Go to "My Documents/Arduino/hardware/tiny/cores/tiny" and open the file "pins_arduino.c" and one can find nice ASCII text description of the pins, like this in comments...

Code:
// ATMEL ATTINY2313
//
//                   +-\/-+
//      (D 17) PA2  1|    |29  VCC
// RX   (D  0) PD0  2|    |19  PB7 (D  16)
// TX   (D  1) PD1  3|    |18  PB6 (D  15)
//      (D  2) PA1  4|    |17  PB5 (D  14)
//      (D  3) PA0  5|    |16  PB4 (D  13)*
// INT0 (D  4) PD2  6|    |15  PB3 (D  12)*
// INT1 (D  5) PD3  7|    |14  PB2 (D  11)*
//      (D  6) PD4  8|    |13  PB1 (D  10)
//     *(D  7) PD5  9|    |12  PB0 (D  9)
//             GND 10|    |11  PD6 (D  8)
//                   +----+
//
// * indicates PWM port

// these arrays map port names (e.g. port B) to the
// appropriate addresses for various functions (e.g. reading
// and writing)


In a browser, due to usage of proportional fonts, it might not look great, but in a text-editor with fixed-width fonts, it's just fine.
Logged

Tokyo, Japan
Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yeah, that's a very nice diagram too. In fact, we used it along with the description in core_pins.h as a reference when we updated the cheat sheet.

PS: D17 isn't directly usable, since it is the RESET pin and needs to be remapped by changing fuses to function as a normal digital port. The same goes for D5 in the ATTinyX5 (but we left it in the diagram, since it is also assigned to analog port A0).
Logged


Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 207
Posts: 12912
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


@karl_b: Asterisks indicate PWM pins?
Logged

Tokyo, Japan
Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

@karl_b: Asterisks indicate PWM pins?

Yes smiley

I see that it is not so clear in the cheat sheet, will update it with an additional note. Thanks!
Logged


Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 207
Posts: 12912
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


You have one too many for the X5 family and two too many for the 13.  Let's see... PB3 needs to be excluded for the X5 family.  PB3 and PB4 need to be excluded for the 13.
« Last Edit: February 03, 2012, 12:23:13 am by Coding Badly » Logged

Tokyo, Japan
Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

There is a note in the cheat sheet that says "ATTiny13 has PWM only on PB0 and PB1"

As for ATTinyX5, PB3 and PB4 can both output PWM, but they are not independent (see page 89 in the full datasheet: PB3 can be set to output the inverse of PB4). I suppose that information could be added to the note, if I can figure out a concise way of writing it smiley
Logged


Washington
Offline Offline
God Member
*****
Karma: 38
Posts: 790
Firefox & Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Check the diagram in the datasheet.
The "PB" numbers will be the correct ones, not the physical pin numbers.
Realistically, this makes sense, for example VCC and GND can not be I/O pins.
Logged

Avoid throwing electronics out as you or someone else might need them for parts or use.
Solid state rectifiers are the only REAL rectifiers.
Resistors for LEDS!

Pages: [1] 2 3   Go Up
Jump to: