JPawww / arduino-tiny

Automatically exported from code.google.com/p/arduino-tiny
Other
0 stars 0 forks source link

Issue with Attiny84 #125

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Mapping of pins for Attiny84 in core_pins.h and pins_arduino.c is incorrect.

It should be 

#if defined( __AVR_ATtinyX4__ )

#define PIN_A0  (0)
#define PIN_A1  (1)
#define PIN_A2  (2)
#define PIN_A3  ( 3)
#define PIN_A4  ( 4)
#define PIN_A5  ( 5)
#define PIN_A6  ( 6)
#define PIN_A7  ( 7)
#define PIN_B0  ( 0)
#define PIN_B1  ( 1)
#define PIN_B2  ( 2)
#define PIN_B3  (11)  /* RESET */
....

This have to be adopted to pins_arduino.c 
in section 

#if defined( __AVR_ATtinyX4__ )
....

const uint8_t PROGMEM digital_pin_to_port_PGM[] = 
{
  PORT_B_ID, /* 0 */
  PORT_B_ID,
  PORT_B_ID,
  PORT_A_ID,
  PORT_A_ID,
  PORT_A_ID,
  PORT_A_ID,
  PORT_A_ID,
  PORT_A_ID, /* 8 */
  PORT_A_ID,
  PORT_A_ID,
};

const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = 
{
  _BV(0), /* 0, port B */
  _BV(1),
  _BV(2),
  _BV(7), /* 3 port B */
  _BV(6),
  _BV(5),
  _BV(4),
  _BV(3),
  _BV(2), 
  _BV(1),
  _BV(0),
};

.....

What is the expected output? What do you see instead?

Code compile and work properly using Arduino 1.0.5. 

Pins have to be changed in source code and don't fit to the physical logic 
without changes above. 

Correct files attached. 

What version of the product are you using? On what operating system?
Arduino 1.5.8 with attiny core 1.5 

Please provide any additional information below.

Original issue reported on code.google.com by f41...@googlemail.com on 11 Dec 2014 at 7:54

Attachments:

GoogleCodeExporter commented 9 years ago
> Mapping of pins for Attiny84 in core_pins.h and pins_arduino.c is incorrect.

Explain why.

Provide a test case.

Original comment by arduino....@gmail.com on 11 Dec 2014 at 9:14

GoogleCodeExporter commented 9 years ago
That is somehow difficult. The result is that the code working well while built 
with Arduino 1.0.5 and ATtiny master.zip from Dave Mellis. 
See pin layout from master.zip below. 

// ATMEL ATTINY84 / ARDUINO
//
//                           +-\/-+
//                     VCC  1|    |14  GND
//             (D 10)  PB0  2|    |13  AREF (D  0)
//             (D  9)  PB1  3|    |12  PA1  (D  1) 
//                     PB3  4|    |11  PA2  (D  2) 
//  PWM  INT0  (D  8)  PB2  5|    |10  PA3  (D  3) 
//  PWM        (D  7)  PA7  6|    |9   PA4  (D  4) 
//  PWM        (D  6)  PA6  7|    |8   PA5  (D  5)        PWM
//                           +----+
This is according the original description as shown in the Atmel Data sheet for 
the Attiny84 on page 2 (PIN layout) 

LED led[3] ={ LED(PA6), LED(PA7), LED(PA5)};
LED is my own class and LEDs are connected to PA6, PA7 and PA5. 
According the Arduino concept I can use 6,7 and 5, too. 

Compiling the same code using an unmodified attiny core 1.5 only 
LED connected to PA5 is working. I have to reconnect teh LEDs to PA3 and PA4. 

In tiny core the mapping P -> D has changed. For what reason? 
See below. So to be compiant with software developped using 1.0.5 I have to 
modify attiny core. 

// ATMEL ATTINY84 / ARDUINO
//
//                           +-\/-+
//                     VCC  1|    |14  GND
//             (D  0)  PB0  2|    |13  AREF (D 10)
//             (D  1)  PB1  3|    |12  PA1  (D  9) 
//                     PB3  4|    |11  PA2  (D  8) 
//  PWM  INT0  (D  2)  PB2  5|    |10  PA3  (D  7) 
//  PWM        (D  3)  PA7  6|    |9   PA4  (D  6) 
//  PWM        (D  4)  PA6  7|    |8   PA5  (D  5)        PWM
//                           +----+

Original comment by f41...@googlemail.com on 11 Dec 2014 at 9:47

GoogleCodeExporter commented 9 years ago
> In tiny core the mapping P -> D has changed. For what reason?

Your question is misplaced.  The pin mapping with this core has never changed.  
This core was published long before David Mellis' version.

If you don't like the pin mapping then change it.  You have the source code.

Or, complain to David Mellis.

Or, provide a mapping / translation in your code.

But a difference in pin mapping is not a bug.

Original comment by arduino....@gmail.com on 11 Dec 2014 at 10:16