Wanting to programme a Tiny 85 20pu using arduino

Hi,

I have been trying to programme a AT Tiny 85 using the Arduino as the programmer. Dispite the fact there are hundreds of tutorials on the web saying how easy it is, I have to admit to quite a degree of frustration. I have looked through as many threads, on as many forums as I can before my brain melts but still I can not get it to work, nor can I see anything related to issue I think might be at the heart of MY problem.

I am using :
Win XP,
Arduino Uno R3
Arduino IDE 1.5.2,
the 'arduino-tiny-0150-0020.zip' core files from 'Google Code Archive - Long-term storage for Google Code Project Hosting.',
ATTiny85-20PU, Farnell code 145-5162. (20Mhz)

The core files appear to install correctly and I have a choice of tiny85's 16Mhz, 8Mhz and 1 Mhz. But no 20Mhz..

Instinct is telling me I simply do not have the core file for my TIny 85, and hence no matter what ever I do it will not work. So that would in itself explains why I am not getting anywere.

Is that correct? Becasue a search on RS comp and Farnell suggest it is getting REALLY hard to get 1,8, or 16Mhz Tiny's.

Any thoughts welcome...

Thanks

Liam

You might have better luck buying a USBtinyISP programmer. They sell for about $14USD shipped on eBay. Arduino IDE supports these type of programmers, so the programming is quite easy once you install the programmer's driver.

Hi Borland,

That is an option I can investigate, but as it's the Holiday season here in England pretty much everything is shut down for a week, and I'm trying to have a play with an idea, this week, as I have a week to play with.. :slight_smile:

Also surely I would still need the core files for a Tiny85 20Mhz? As I am imagining that is the root cause of my problem.

But I will hold your suggestion in mind, particularly if I need to knock out more than half a dozen of these.

Thank you

Liam

Do you need to program it to run at that speed? I buy 85-20s but run them at 16.

Hi Dannable,

Frankly, no I don't need it to run at 20Mhz. I just can not get my hands on any through hole tiny85's at anything other than 10 or 20Mhz.

So out of the options for the board core which one do you usually choose? may I ask?

Regards

Liam

I just use the 16MHz internal PLL, although I'm thinking about dropping the speed to see if that will improve battery life.

And I use the cores that you have downloaded.

Hi Dannable,

Cool, That's useful information to start with reduces the number of variables I have to experiment with.

Do you load a bootloader on the the Tiny before you load the code?

Regards

Liam

AFAIK, despite the terminology, all 'burning the bootloader' does with the Tiny processors is set the fuses to enable it to run at the specified speed. I use TinyTuner to calibrate the internal oscillator of all the Tiny processors I use regardless of what the task is.

Do you load a bootloader on the the Tiny before you load the code?

Both Digispark and Trinket are ATtiny85 with bootloaders and each take a novel way to make it work w/ the Arduino IDE. If you are using UNO and ArduinoISP, you do not need a bootloader, but you must set the fuses before running a sketch.

The "core files" match the crystal frequency, not the uC max ratings!

Nick Gammon has a great programmer sketch too.

Ray

Hi all,

Well I have has some success.

I rolled back my IDE to 022, and used the core files that came under the:-

http://www.hobbytronics.co.uk/arduino-attiny tutorial.

They use the attiny45_85.zip cores. Gave it a try. Hey presto it worked. I can make my Tiny flash an LED.

Of note my only option for the board to use with Tiny is 'Tiny85 (w/ Arduino as ISP)' and it worked fine.

This tell me that my hook up is correct, and the Attiny 85 is in itself working.

However when I switch to the 1.5.2 IDE I have used ATting85@16 Mhz (internal PLL:4.3V BOD) to upload more or less the identical sktch and get an error:-

Avrdude:stk500_get sync(): not in sync: resp= Oxff

Which means I think I am using the wrong core files...

I will experiment with the option I have some more, but I am not entriely sure what all those options mean in a practical sence.

Regards

Liam

However when I switch to the 1.5.2 IDE

1.0.5 works well with Coding Badly's Google Code Archive - Long-term storage for Google Code Project Hosting.
I far prefer this core to others I have tried. Dropping back to 0022 should not be necessary.

Ray

Hi Ray,

Thank you for pointing out that repository. It is not clear from git hub that it is a repository for the tiny 85, as if you choose the home option it takes you to all the core files I have not managed to get to work.

But as it stands at the moment I do have IDE 1.0.5 working with 'arduino-tiny-2564944ce78c.zip' cores.

However I do have one interesting little anomaly. I seem only to get it to run any code at the right speed using the Tiny @ 1Mhz (internal Osc,, BOD disabled). If I choose anything else it will either not uplaod at all or runs 10 times slower than it should. For example the Tiny @ 16Mhz (internal Osc,, BOD disabled) runs soo slow I have to edit the blink sketch to delay(100).

However it is up and running. Have not tried to see if it works on 1.5.2 yet. But a bit more success, although the speed thing is a bit strange.

May | ask which board options you choose?

Regards

Liam

If you go to this page

https://code.google.com/p/arduino-tiny/

You will find two cores:

Download the latest version for Arduino 1.0, works for Arduino 1.0.X

Download the latest version for Arduino 1.5 works for Arduino 1.5.X

So no need to roll back to Arduino 0022.

As for the speed thing:
The factory default for the internal osc. is 1MHz
If you want to use for axample 8MHz you have to set the fuses to this frequence.

Select board -> Attiny85@8MHZ
select ->Tools->Burn Bootloader

This step do not burn a bootloader to your chip, it is only used to set the fuses to another clock-speed.

Hi Erni,

I have managed to get the Tiny85 programmed at 8Mhz on my 1.5.2 IDE from my Arduino Uno Rev 3...Yippee...

It is presently running a strip of Nexpixels all on its own!

There are a few pitfalls along the way so for the benifit of anyone reading in here is a few tips.

Download the right core files for your IDE. If you are using Arduino IDE 1.xxxx then the cores are available here:-
https://code.google.com/p/arduino-tiny/

The file names of the zip files don't on first read match your IDE but that ok. Download them and unzip them in to a tempory directory instalation.

So for example:-

IDE 1.0.1 will use core files :- Arduino-tiny-0100-0018.zip

and

IDE 1.5.4 will use core files:- Arduino-tiny-0150-0020.zip

Once you have downloaded and unpacked them, open the README.TXT file and carefully follow the installation instructions.
You will need to create a 'hardware' directory usually in your sketch folder. (some other installs require it to be inthe IDE directory) Make sure it is spelt correctly and it is case sensative! The core files need to go in a sub directory of the 'hardware' directory 'tiny'. The readme.txt file will be specific for the core file package.

Next using a text editor open the 'Perspective Boards.txt' file and then resave it as 'boards.txt'. I think it is wise to be case specific. This is the list of board that the new core files support. It can be edited to only list the chips you are interested in but for now don't bother. You can do that later.

Now load up the IDE, and you should notice more boards under Tools-Boards menu. If not, go back and examine your set up. Something is not right and you might have missed out a step in the REDME.TXT file... It is easy to jump ahead of yourself and miss something simple.

Without adding anything to your Uno board, plug it in and upload to it the ArduinoISP sketch from the File-Examples menu. Not much will appear to happen, thats OK.

Now hook up the AtTiny85 to the Uno with these pin outs:-

Arduino +5V ---> ATtiny Pin 8
Arduino Ground ---> ATtiny Pin 4
Arduino Pin 10 ---> ATtiny Pin 1
Arduino Pin 11 ---> ATtiny Pin 5
Arduino Pin 12 ---> ATtiny Pin 6
Arduino Pin 13 ---> ATtiny Pin 7

Google 'Arduino AtTiny85' and load of ilustrations should come up to assist you.. Dont forget the capacitor across GND and Reset, but only add the once you are trying to programme the TINY85, it you want to programme the UNO it need to be removed.

In the Tools menu for the first time test choose programmer and select 'Arduino as ISP'. This is often defaulted to ARVISP mkII. and if so you will likely get :-
'arvdude: usbdev_open(); did not find any USB device "USB" ' error.
This is becasue the IDE can not see the chip. Check you connections, wires can come loose, and check the setting for the board and the programmer.. Also if you have any unused instances of the IDE open check they have got 'Arduino as ISP' selelcted as well. Sometime other windows casue issues. Either close them or double check...

Select the board you want to use and in the Tools-Board menu, and then at the bottom of the Tools menu select 'Burn Bootloader' Not much will appear to happend.

Select the blink sketch, and change the pin assignment from 13 to 0. The Tiny uses different pin assignments not only in code but also physically on the chip. Pin 0 in code is pin 5 on the chip.

Upload the sketch to the tiny85. If all gos well there will be a pause for compiling, and then alot of flashing light on the UNO RX and TX leds. also you will likely get the 'arvdude: please define PAGEL and BS2 signals xxxxxxxxx' error. Thats ok and normal.

Disconnect the 5V line to the Tiny85, Now connect a diode and reisitor across pin 4(Gnd) and 5(Sig) of the Tiny85 and reconnect the 5V line and you should have a flashing LED.

Hope that helps some people.

Liam

borland:
You might have better luck buying a USBtinyISP programmer. They sell for about $14USD shipped on eBay. Arduino IDE supports these type of programmers, so the programming is quite easy once you install the programmer's driver.

A USBASP is even cheaper at $4:
http://www.fasttech.com/products/0/10000022/1002900-atmegaattiny-51-avr-isp-usbasp-usb-programmer-down

Or even cheaper than that would be to hack a Nokia CA-42 and use FTDI-bitbang which is supported by avrdude.

If you have a parallel port you could make a programmer with some basic parts.

VideoLiam:
Hi Dannable,

Frankly, no I don't need it to run at 20Mhz. I just can not get my hands on any through hole tiny85's at anything other than 10 or 20Mhz.

The Attiny85 has an internal 8Mhz RC oscillator, and the factory-default fuse settings use a divisor of 8 for a 1Mhz clock. Using the internal PLL you can run it at 16Mhz, or with an external crystal officially up to 20Mhz, but unoficially they overclock well (25-30Mhz is common).

They're a nice little chip, but rather limited with only 5 usable pins (6 if you disable the reset pin), and not compatible with many Arduino libraries (like serial and SPI), so you may find yourself having to adapt Arduino code or write it from scratch.

so you may find yourself having to adapt Arduino code

With the advent of Digispark and Trinket, a lots of code has been adapted to the Attiny85. Trinket does not disable Reset but the Digispark does and therefore gains another pin. Both products have active forums and code on github. I think Digispark is the more stable product and their "viral bootloader" is way ahead of Adafruit's Trinket in stability.

ray

mrburnette:

so you may find yourself having to adapt Arduino code

With the advent of Digispark and Trinket, a lots of code has been adapted to the Attiny85.

But it's not plug-and-go like any of the ATMega328 boards available, and the documentation sucks. For example it took me over an hour to get TinyDebugSerial working on a Digispark. One of the few pages I found covering it is here:
http://www.ernstc.dk/arduino/tinycom.html
However that page says output is on PB3 while it's actually on PB2 when F_CPU is >8Mhz.

The micronucleus bootloader is a hack job (and Jenna Fox doesn't deny it). After 15 days of going through the micronucleus code I barley understand how it all works, while understanding Optiboot only took 15 minutes.

I haven't been able to get nRF24l01 modules working with the digispark which is an example of the kind of problems you can expect to run into. Part of the problem is specific to the ATTinyx5 (USI instead of SPI on the ATMega), and part is because 2 of the 6 available ports on the Digispark are crippled by the USB pullup resistor and zener diodes.

Eric pitches the Digispark as a beginner-level plug-and-play arduino compatible device. Just download their patched version of The 1.04 IDE and go. But the IDE isn't well patched. Look in the libraries directory and you'll find Arduino_SPI instead of SPI85. Although you'll find TinyWireM_Digispark, there's still a copy of Arduino_Wire to make things confusing. Both Arduino_SPI and Arduino_Wire should have been deleted from the Digispark version of the IDE; something that's really simple to do but wasn't done. I suspect it is so Eric wouldn't keep his kickstarter supporters waiting.

With some work someone could make a decent Tiny85-based Arduino. Patch the IDE so all the compatible libraries are included and the incompatible ones removed. Have it emmulate a USB serial port connected to a STK500 compatible bootloader, and include a fully-compatible version of the Serial class. But that's a lot of work to save ~25c (cost difference between the Tiny85 and Mega8A), and with the upcoming availability of the LGT8F88A, I think we'll see that cost gap get smaller.

I'd say the trinket is well named. They're more of a cute toy than a practical hardware platform, and they're more than double the price of a Pro Mini ATMega328 board. I plan to give my DigiSpark to a friend who likes cute electronic toys and do my hacking on Pro mini boards.

But it's not plug-and-go like any of the ATMega328 boards available, and the documentation sucks.

Dude, your expectations may be a bit demanding, IMO. I said

With the advent of Digispark and Trinket, a lots of code has been adapted to the Attiny85.

But I surely did not mean to suggest that the t85 was an Arduino-class uC. It is not. The low-end of the current Arduino line is the UNO with 2K SRAM and 32k flash. The Atmega328P-PU is officially supported and I guess an argument could be made that grandfathered support goes all the way back to Atmega8.

In any event, there is not an official t85 Arduino product, so to have 100% compatibility is not something that is likely to happen; with only 512 Bytes of SRAM and 8K of flash, it really is a nice "utility" that can sometimes be programmed with the Arduino GUI and some standard libraries. I use it when it makes sense, but I use ISP for 99% of this need. I think the Trinket and Digispark are fun toys - if a few folks get bitten with the Arduino bug and move up the food-chain, then all the better.

Ray