ATTiny85 port (work in progress)

Does anyone has an explanation on why the Adruino (not ATTiny85)+softserial+RF doesn't work from my pervious question ? Thanks.

Hi,

I'm trying to get a tiny45 and NSSerial working, i'm getting an error relating to timer0, i assume its because the tiny45 either doesnt have a timer0 or its called something else (it seems to be looking for TIMSK0).

C:\Program Files (x86)\arduino-0019\libraries\NewSoftSerial\NewSoftSerial.cpp: In static member function 'static void NewSoftSerial::enable_timer0(bool)':
C:\Program Files (x86)\arduino-0019\libraries\NewSoftSerial\NewSoftSerial.cpp:520: error: 'TIMSK0' was not declared in this scope
C:\Program Files (x86)\arduino-0019\libraries\NewSoftSerial\NewSoftSerial.cpp:526: error: 'TIMSK0' was not declared in this scope

I'm going to compare datasheets now and see what i can find.

Turns out it was easier than i thought.

Because the ATtiny45 only has one timer the register is called TIMSK not TIMSK0. Therefore, if you edit the end of NewSoftSerial.cpp to look like this:

#if defined(AVR_ATtiny45)
sbi(TIMSK, TOIE0);
#else
sbi(TIMSK0, TOIE0);
#endif
else
#if defined(AVR_ATtiny45)
cbi(TIMSK, TOIE0);
#else
cbi(TIMSK0, TOIE0);
#endif

and recompile it will work. I think you'll probably have to have the 45/85 running at atleast 8MHz though.

@Chinese Jack

the problems disappear if I user either of following solutions:

  1. Removing RF models, so the Pin2 is directly connect with Pin3
  2. use standard hardware serial Pins (Pin 0 and Pin 1)

Can you verify that SS is actually talking at the correct bit rate?

I am trying to changes the fuses to run at 8MHz. I am using an Arduino as an ISP (http://hlt.media.mit.edu/wiki/pmwiki.php?n=Main.ArduinoATtiny4585). Here is my boards.txt

attiny45.name=ATtiny45
attiny45.upload.using=arduino:arduinoisp
attiny45.upload.maximum_size=4096
attiny45.build.mcu=attiny45
attiny45.build.f_cpu=1000000L
attiny45.build.core=attiny45_85

attiny85s.name=ATtiny85
attiny85s.upload.using=arduino:arduinoisp
attiny85s.upload.maximum_size=8192
attiny85s.build.mcu=attiny85
attiny85s.build.f_cpu=1000000L
attiny85s.build.core=attiny45_85

attiny85.name=ATtiny85-8MHz
attiny85.upload.using=arduino:arduinoisp
attiny85.upload.maximum_size=8192
attiny85.bootloader.low_fuses=0xE2 
attiny85.bootloader.high_fuses=0xDF 
attiny85.bootloader.path= attiny85 
attiny85.bootloader.file=fake.hex 
attiny85.bootloader.unlock_bits=0x3F 
attiny85.bootloader.lock_bits=0x0F
attiny85.build.mcu=attiny85
attiny85.build.f_cpu=8000000L
attiny85.build.core=attiny45_85

When I try to burn the bootloader to set the fuses I get the following errors

avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny85
avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny85
avr_read(): error reading address 0x0000
    read operation not supported for memory "lock"
avrdude: failed to read all of lock memory, rc=-2

John Abshier

@Andy Brown:

Firstly, the default port of the core code continues to use timer 0 for millis() and micros() timing. The ATtiny has only two timers and they are not equally capable. Timer 0 can do full PWM in the same way as we're used to with the ATmega series. Timer 1 cannot and is the less useful of the two.

In what way is PWM limited when performed from Timer 1?

@John Abshier:

When I try to burn the bootloader to set the fuses I get the following errors

avr_read(): error reading address 0x0000

read operation not supported for memory "lock"
avrdude: failed to read all of lock memory, rc=-2

I've run into the same problem. Did you figure out how to get it to work?

I didn't get it to work. I borrowed a friends programmer and burnt the fuses with that.

John Abshier

As luck would have it, very early this morning I figured out why the "read operation not supported for memory "lock"" error occurs. There is a section missing from the avrdude.conf file that ships with Arduino.

#------------------------------------------------------------
# ATtiny85
#------------------------------------------------------------

part
     id            = "t85";
     desc          = "ATtiny85";

[lots of stuff here not included in this post]

     memory "lock"
         size            = 1;
         write           = "1 0 1 0  1 1 0 0  1 1 1 x  x x x x",
                           "x x x x  x x x x  1 1 i i  i i i i";
[glow]         read            = "0 1 0 1  1 0 0 0  0 0 0 0  0 0 0 0",
                           "0 0 0 0  0 0 0 0  o o o o  o o o o";[/glow]
        min_write_delay = 9000;
        max_write_delay = 9000;
       ;

I copied the section for the ATtiny84. I have no idea if it is accurate but it seems to work. I don't have time to verify the change against the latest version of AVRDUDE.

I have been looking at this post and i whent to this web page:
http://hlt.media.mit.edu/wiki/pmwiki.php?n=Main.ArduinoATtiny4585
I followed the instructons to the "T" and when i program the chip it gives me this error :(...

java.lang.NullPointerException
      at processing.app.debug.AvrdudeUploader.getProgrammerCommands(AvrdudeUploader.java:97)
      at processing.app.debug.AvrdudeUploader.uploadUsingPreferences(AvrdudeUploader.java:58)
      at processing.app.Sketch.upload(Sketch.java:1498)
      at processing.app.Sketch.exportApplet(Sketch.java:1465)
      at processing.app.Sketch.exportApplet(Sketch.java:1420)
      at processing.app.Editor$46.run(Editor.java:2219)
      at java.lang.Thread.run(Thread.java:619)

What is this all about?? :-[
Any ideas???

Which IDE version are you using?

Post your boards.txt file. Please use code tags.

Arduino v18 IDE
this is the board file in hardware sketch file

attiny45.name=ATtiny45
attiny45.upload.using=arduino:arduinoisp
attiny45.upload.maximum_size=4096
attiny45.build.mcu=attiny45
attiny45.build.f_cpu=800000L
attiny45.build.core=attiny45_85

attiny85.name=ATtiny85
attiny85.upload.using=arduino:arduinoisp
attiny85.upload.maximum_size=8192
attiny85.build.mcu=attiny85
attiny85.build.f_cpu=800000L
attiny85.build.core=attiny45_85

I am using the attiny 85v -10PU-ND just for refrence..
I am using the Arduino Duemilanove (w/ 328) for the ISP
I have a ISP (usb tiny ISP) and if i could figure out how to use that with this I think id be better off.)

Two suggestions...

  1. I'm not certain if version 0018 supports Tiny processors. I know version 0019 does. If it won't cause problems for you, I suggest installing 0019.

  2. Try including the bootloader options in boards.txt...

attiny85.bootloader.low_fuses=0x62
attiny85.bootloader.high_fuses=0xD7
attiny85.bootloader.extended_fuses=0xFF

attiny85.bootloader.path=empty

attiny85.bootloader.file=empty85at1.hex

attiny85.bootloader.unlock_bits=0xFF
attiny85.bootloader.lock_bits=0xFF

By not changing anything i am getting to this point...

Binary sketch size: 666 bytes (of a 8192 byte maximum)
avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny85
avrdude: stk500_program_enable(): protocol error, expect=0x14, resp=0x50
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.

avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x51

I think this is that reset issue with having to cut that trace to allow it to upload.....
i would like to modify the download setting to the USBtinyISP, any idea how?

  1. I'm not certain if version 0018 supports Tiny processors.

I use 18 with your 84 core, works fine

I got it to work with the v19 arduino IDE.
This is he board file in the shekch area....

attiny45.name=ATtiny45
attiny45.upload.using=arduino:arduinoisp
attiny45.upload.maximum_size=4096
attiny45.build.mcu=attiny45
attiny45.build.f_cpu=1000000L
attiny45.build.core=attiny45_85

attiny85.name=ATtiny85
attiny85.upload.using=arduino:arduinoisp
attiny85.upload.maximum_size=8192
attiny85.build.mcu=attiny85
attiny85.build.f_cpu=1000000L
attiny85.build.core=attiny45_85

I am still trying the USbtinyISP

  1. I'm not certain if version 0018 supports Tiny processors.

I use 18 with your 84 core, works fine

Good to know. Thanks.

avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny85

That error may be because your avrdude.conf needs to be updated. It's a text file. See if there's a section for the '85 processor.

I'm using the Pololu USB Programmer. This is my programmers.txt files...

pololu.name=Pololu USB AVR Programmer
pololu.communication=serial
pololu.protocol=avrispv2

And my boards.txt...

###########################################################################
#
# Example boards.txt from...
#
# http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1236434254/94#94
# http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1274754985/6#6
# http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1274820597/49#49
#
###########################################################################

attiny84at8.name=ATtiny84 @ 8 MHz

# The following do NOT work...
# attiny84at8.upload.using=avrispv2
# attiny84at8.upload.using=Pololu USB AVR Programmer

# The following DO work (pick one)...
# attiny84at8.upload.protocol=avrispv2
attiny84at8.upload.using=pololu

attiny84at8.upload.maximum_size=8192
attiny84at8.upload.speed=19200

# Default clock (slowly rising power; long delay to clock; 8 MHz internal)
# Int. RC Osc. 8 MHz; Start-up time PWRDWN/RESET: 6 CK/14 CK + 64 ms; [CKSEL=0010 SUT=10]; default value
# Brown-out detection disabled; [BODLEVEL=111]
# Preserve EEPROM memory through the Chip Erase cycle; [EESAVE=0]

attiny84at8.bootloader.low_fuses=0xE2
attiny84at8.bootloader.high_fuses=0xD7
attiny84at8.bootloader.extended_fuses=0xFF
attiny84at8.bootloader.path=empty
attiny84at8.bootloader.file=empty84at8.hex

attiny84at8.bootloader.unlock_bits=0xFF
attiny84at8.bootloader.lock_bits=0xFF

attiny84at8.build.mcu=attiny84
attiny84at8.build.f_cpu=8000000L
attiny84at8.build.core=tiny
 
###########################################################################

attiny84at1.name=ATtiny84 @ 1 MHz

# The following do NOT work...
# attiny84at1.upload.using=avrispv2
# attiny84at1.upload.using=Pololu USB AVR Programmer

# The following DO work (pick one)...
# attiny84at1.upload.protocol=avrispv2
attiny84at1.upload.using=pololu

attiny84at1.upload.maximum_size=8192
attiny84at1.upload.speed=19200

# Default clock (slowly rising power; long delay to clock; 8 MHz internal; divide clock by 8)
# Int. RC Osc. 8 MHz; Start-up time PWRDWN/RESET: 6 CK/14 CK + 64 ms; [CKSEL=0010 SUT=10]; default value
# Divide clock by 8 internally; [CKDIV8=0]
# Brown-out detection disabled; [BODLEVEL=111]
# Preserve EEPROM memory through the Chip Erase cycle; [EESAVE=0]

attiny84at1.bootloader.low_fuses=0x62
attiny84at1.bootloader.high_fuses=0xD7
attiny84at1.bootloader.extended_fuses=0xFF
attiny84at1.bootloader.path=empty
attiny84at1.bootloader.file=empty84at1.hex

attiny84at1.bootloader.unlock_bits=0xFF
attiny84at1.bootloader.lock_bits=0xFF

attiny84at1.build.mcu=attiny84
attiny84at1.build.f_cpu=1000000L
attiny84at1.build.core=tiny
 
###########################################################################

attiny85at8.name=ATtiny85 @ 8 MHz

# The following do NOT work...
# attiny85at8.upload.using=avrispv2
# attiny85at8.upload.using=Pololu USB AVR Programmer

# The following DO work (pick one)...
# attiny85at8.upload.protocol=avrispv2
attiny85at8.upload.using=pololu

attiny85at8.upload.maximum_size=8192
attiny85at8.upload.speed=19200

# Default clock (slowly rising power; long delay to clock; 8 MHz internal)
# Int. RC Osc. 8 MHz; Start-up time PWRDWN/RESET: 6 CK/14 CK + 64 ms; [CKSEL=0010 SUT=10]; default value
# Brown-out detection disabled; [BODLEVEL=111]
# Preserve EEPROM memory through the Chip Erase cycle; [EESAVE=0]

attiny85at8.bootloader.low_fuses=0xE2
attiny85at8.bootloader.high_fuses=0xD7
attiny85at8.bootloader.extended_fuses=0xFF
attiny85at8.bootloader.path=empty
attiny85at8.bootloader.file=empty85at8.hex

attiny85at8.bootloader.unlock_bits=0xFF
attiny85at8.bootloader.lock_bits=0xFF

attiny85at8.build.mcu=attiny85
attiny85at8.build.f_cpu=8000000L
attiny85at8.build.core=tiny
 
###########################################################################

attiny85at1.name=ATtiny85 @ 1 MHz

# The following do NOT work...
# attiny85at1.upload.using=avrispv2
# attiny85at1.upload.using=Pololu USB AVR Programmer

# The following DO work (pick one)...
# attiny85at1.upload.protocol=avrispv2
attiny85at1.upload.using=pololu

attiny85at1.upload.maximum_size=8192
attiny85at1.upload.speed=19200

# Default clock (slowly rising power; long delay to clock; 8 MHz internal; divide clock by 8)
# Int. RC Osc. 8 MHz; Start-up time PWRDWN/RESET: 6 CK/14 CK + 64 ms; [CKSEL=0010 SUT=10]; default value
# Divide clock by 8 internally; [CKDIV8=0]
# Brown-out detection disabled; [BODLEVEL=111]
# Preserve EEPROM memory through the Chip Erase cycle; [EESAVE=0]

attiny85at1.bootloader.low_fuses=0x62
attiny85at1.bootloader.high_fuses=0xD7
attiny85at1.bootloader.extended_fuses=0xFF
attiny85at1.bootloader.path=empty
attiny85at1.bootloader.file=empty85at1.hex

attiny85at1.bootloader.unlock_bits=0xFF
attiny85at1.bootloader.lock_bits=0xFF

attiny85at1.build.mcu=attiny85
attiny85at1.build.f_cpu=1000000L
attiny85at1.build.core=tiny
 
###########################################################################

I'm not clear on something. Are there any actual changes to the software serial code, or does it just work because the timing in the millis() and micros() functions has been fixed up for the tiny 85?

I'm not clear on something.

That makes two of us. :slight_smile:

Are there any actual changes to the software serial code, or does it just work

Are you asking about NewSoftSerial?

because the timing in the millis() and micros() functions has been fixed up for the tiny 85?

I don't think either was changed in the published '85 core. But I don't think they needed to be changed.