Pages: [1] 2 3 ... 8   Go Down
Author Topic: ATTiny85 port (work in progress)  (Read 12783 times)
0 Members and 1 Guest are viewing this topic.
Amsterdam
Offline Offline
Full Member
***
Karma: 1
Posts: 138
he's looking at you, kiddy...
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I wanted a very small arduino type chip and foud out about a soic version of the attiny85v. My aim is a chip with a pull-up resistor to the reset pin. so a internal clock on 8Mhz. the fuse settings reflect this. here is my attempt at a altered hardware folder for the arduino ide. of course you cannot use the normal upload procedure and have to use icsp to program the chip because the attiny does not have a hardware UART.

unfortunately i have had no time yet to test the files, but here is wat i deduced by looking at the original atmega168 pdf and the pins_arduino.c and pins_arduino.h files and a very good explanation of the workings from here:
http://www.urbanhonking.com/ideasfordozens/2009/05/an_tour_of_the_arduino_interna.html

So this is the changed pins_arduino.c file:

Code:
/*
  pins_arduino.c - pin definitions for the Arduino board
  Part of Arduino / Wiring Lite

  Copyright (c) 2005 David A. Mellis

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General
  Public License along with this library; if not, write to the
  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  Boston, MA  02111-1307  USA

  $Id: pins_arduino.c 254 2007-04-20 23:17:38Z mellis $
  adapted to ATTiny85 2010-05-25 22:19:10 by swc
*/

#include <avr/io.h>
#include "wiring_private.h"
#include "pins_arduino.h"

// On the Sanguino board, digital pins are also used
// for the analog output (software PWM).  Analog input
// pins are a separate set.

// ATMEL ATTINY85
//
//                  +-\/-+
//            PB5  1|    |8  VCC
//     (AI 3) PB3  2|    |7  PB2 (AI 1)
//     (AI 2) PB4  3|    |6  PB1 PWM
//            GND  4|    |5  PB0 PWM
//                  +----+

#define PB 1


// these arrays map port names (e.g. port B) to the
// appropriate addresses for various functions (e.g. reading
// and writing)
const uint8_t PROGMEM port_to_mode_PGM[] =
{
      NOT_A_PORT,
    &DDRB,
};

const uint8_t PROGMEM port_to_output_PGM[] =
{
      NOT_A_PORT,
      &PORTB,
};

const uint8_t PROGMEM port_to_input_PGM[] =
{
      NOT_A_PORT,
      &PINB,
};

const uint8_t PROGMEM digital_pin_to_port_PGM[] =
{
      PB, /* 0 */
      PB,
      PB,
      PB,
      PB,
};

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

const uint8_t PROGMEM digital_pin_to_timer_PGM[] =
{
      TIMER0A,       /* 0  - PB0 */
      TIMER1A,       /* 1  - PB1 */
      NOT_ON_TIMER,       /* 2  - PB2 */
      TIMER1B,           /* 3  - PB3 */
      TIMER1B,             /* 4  - PB4 */
};
and this the boards.txt file

Code:
##############################################################

attiny85.name=attiny85

attiny85.upload.using=avrispmk2

attiny85.upload.maximum_size=8190
attiny85.upload.speed=38400
attiny85.bootloader.low_fuses=0xE2
attiny85.bootloader.high_fuses=0xDF
attiny85.bootloader.extended_fuses=0xFF
attiny85.bootloader.path=attiny85v
attiny85.bootloader.file=attiny85v
attiny85.bootloader.unlock_bits=0x3F
attiny85.bootloader.lock_bits=0x0F
attiny85.build.mcu=attiny85v
attiny85.build.f_cpu=8000000L
attiny85.build.core=arduino


of course i should make one for the attiny13 as well

I have not done the analog mapping in wiring_analog.c yet. first i have to find out how that works. same with pwm. maybe the attiny2313 port wil clarify it.

remember, this code is not tested yet, but pure to see if I missed something. i encourage everybody to post comments and improve on this.

*update added
Code:
attiny85.upload.using=avrispmk2
to the boards.txt file. and removed
Code:
attiny85.upload.protocol=stk500
« Last Edit: May 26, 2010, 02:40:52 am by macsimski » Logged

--
"We're all in this together..."

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


Are you able to upload using the IDE?
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 62
Arduino rocks / OpenLCB rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How did you find the http://www.urbanhonking.com/ideasfordozens/2009/05/an_tour_of_the_arduino_intern... , it is dead for me, and the Way-back machine says the last update on that site was in 2008 !?

Thanks, David
Logged

Dr. David Harris
OpenLCB Dev Team

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

@dpharris:

Did you click the link or copy-and-paste it?  It looks like the forum software truncated the URL and placed an ellipses on the end.
Logged

Amsterdam
Offline Offline
Full Member
***
Karma: 1
Posts: 138
he's looking at you, kiddy...
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

@dpharris: sorry. url was not complete. now it is. please reload this page and click the link

@coding badly: no no upload due to missing uart(serial input) on the attiny
Logged

--
"We're all in this together..."

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


I believe we're talking past each other.  Let me try again...

I think it's possible to get the IDE to upload using an ICSP.  I tried with an ATtiny84 using IDE version 0017.  It doesn't work.  I think the problem has something to do with the processor name.  I believe Rene Bohne got something similar to work but he had to modify and rebuild the IDE.

Have you tried uploading a Sketch to an ATtiny85 through an ICSP using the IDE?  Or do you upload Sketches from the command-line?
Logged

Offline Offline
Edison Member
*
Karma: 3
Posts: 1001
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I believe I've had the Arduino IDE working with direct upload for both AtTiny84 and AtTiny85 at some point.

If my memory serves me right, one issue was with Arduino constructing a mcu identifier not recognized by Avrdude. Knowing the identifier created by Arduino however, you can easily patch the avrdude.conf file to fix the "unknown part" issue.
Logged

Amsterdam
Offline Offline
Full Member
***
Karma: 1
Posts: 138
he's looking at you, kiddy...
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

no, i never tried. will keep you posted.
Logged

--
"We're all in this together..."

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

Quote
If my memory serves me right, one issue was with Arduino constructing a mcu identifier not recognized by Avrdude.
That's the problem!

Quote
Knowing the identifier created by Arduino however, you can easily patch the avrdude.conf file to fix the "unknown part" issue.
Add an entry for "m84" (or "m85")?
Logged

Offline Offline
Edison Member
*
Karma: 3
Posts: 1001
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Add an entry for "m84" (or "m85")?
I don't have my notes to verify against, but I believe this is correct (avrdude expects "t84"). There was also some tossing of ideas to patch the IDE to help with this, but I don't remember seeing anything from that make it to 0018.

Anyhow it should be possible to upload from within the IDE and even with an all empty core you're quickly up and running without having to learn new tools.
Logged

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


Nice!  Thank you!

I'll play around with it when I get back from vacation and report what I find (but I suspect macsimski will be reporting back much sooner).
Logged

SE USA
Offline Offline
Faraday Member
**
Karma: 41
Posts: 3783
@ssh0le
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have the same issue in 17 with my 84, it always comes back invalid part m84, I was getting around to that question just have not yet

NOW that that is resolved, when doing the exact same thing in 18 it always comes back with a not in sync error, even though the 2 are setup identically
Logged


Amsterdam
Offline Offline
Full Member
***
Karma: 1
Posts: 138
he's looking at you, kiddy...
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Well. I finally had some time to look into the stuff. it looks promising, but i was yelling to early.  >smiley-sad
A lot of files in the core directory need to be changed to get the things working. with the above files and a bare minimum sketch i get a  compile error. after removing the v behind attiny85v that was changed into acompile error in WInterrupts.c complaining that EICRA was not defined. this is true because this is not a atmega8:

Code:
#if defined(__AVR_ATmega8__)
#define EICRA MCUCR
#define EIMSK GICR
#endif

[/code]
so there is something wrong with:


#if !defined(__AVR_ATmega8__)


but i have not found the place where that would be defined. a folder search in the core dir did not yield a file.
« Last Edit: May 26, 2010, 10:51:04 am by macsimski » Logged

--
"We're all in this together..."

0
Offline Offline
Full Member
***
Karma: 6
Posts: 200
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I got an error when I tried to compile, I forget what it was but I'll tell you later. Would this work on an attiny45 too?
« Last Edit: May 26, 2010, 12:57:16 pm by wyager » Logged

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

Quote
so there is something wrong with:
#if !defined(__AVR_ATmega8__)
but i have not found the place where that would be defined
__AVR_ATmega8__ is defined by the compiler from the mmcu option which the Arduino IDE gets from boards.txt (Whew!  That sentence overran.) ...

http://www.nongnu.org/avr-libc/user-manual/using_tools.html

For an ATtiny85 or ATtiny85V __AVR_ATtiny85__ is defined (but not __AVR_ATmega8__).
« Last Edit: May 26, 2010, 01:49:54 pm by bcook » Logged

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