Programming

I don’t have it yet, but I’m thinking of buying an ATtiny85 from SFE. I know that I can program it with ArduinoISP or an FTDI cable. But can I use this? Is the connection the same?

Thanks,
baum

baum: I don't have it yet, but I'm thinking of buying an ATtiny85 from SFE. I know that I can program it with ArduinoISP or an FTDI cable. But can I use this? Is the connection the same?

Thanks, baum

That module being based on the FTDI FT232RL USB to serial IC is functionally equivalent to any of the Arduino USB boards that use the same chip on-board.

Lefty

K. Have you seen any ATtiny bootloaders? Don't I need one to be able to use the FTDI cable/board? The ISP method is over SPI, right?

baum: K. Have you seen any ATtiny bootloaders? Don't I need one to be able to use the FTDI cable/board?

Yes, a bootloader is required to program via serial comm. Some ATtiny chips don't even have a built in serial port. Check with Coding Badly, he has done and posted quite a lot on using the ATtiny chips.

The ISP method is over SPI, right?

Correct, and by not requiring a bootloader there is more flash memory avalible for your application program which may be very important as some of the ATtiny chips have rather tiny memory resources. ;) That would require a hardware based programmer but these days that can be as simple as a arduino board loaded with the proper programmer sketch and auto-reset disabled.

Does the ATtiny85 have a serial port? No. So why use a bootloader?

Directly using an ISP programmer is pretty simple and that even works with current versions of the arduino IDE.

You can modify the ‘boards.txt’ file to use it:

...
<boardname>.upload.using=arduino:usbtinyisp
...

Unfortunately the documentation for this is currently hidden in the source files somewhere. The ‘usbtinyisp’ part is defined in ‘programmers.txt’. You also should update the fuse settings and the ‘max upload size’ or whatever it is named exactly.

There’s an article on todbot.com about this. He’s using his BlinkM boards that way, which happen to use the ATtiny85 chips.

That I know. But I am going to have the ATtinys embedded in a project, and want to be able to program it without taking it out of the project… I can use an arduino, but it’s sort of bulky. Does the ATtiny 2313 support serial? Or are there any ATmegas I can use?

As far as I know, the attiny2313/4313 are the only tinies that have a real serial port. Personally I'd choose the 4313, as it has more memory. But it is still hard to get and there are nasty issues with device support for it (at least on some linux flavours with avr-gcc). Nevertheless a bootloader would take away a relatively big chunk of flash memory.

Depending on what kind of external components you have, you may get away with adding resistors (something like 1k...10k) in the data lines between the cpu and the components. Then connect the programmer directly to the cpu. That way the ISP programmer would 'win' against other chips and can still programm the cpu. That doesn't work well with LEDs/transistors(excluding mosfets) connected to the pins though. Adding jumpers to the MOSI/MISO/SCK/SS lines is an option as well, but takes away some space.

Using e.g. an ATmega88/168 in TQFP-32 package is not much larger than an ATtiny85 in DIP-8. Soldering this SMD package is close to trivial with enough flux. Of course there's a price penalty for using a mega. But you get a real serial port, a real I²C module, a real SPI module... each on different pins. The ATtiny chips come with USI (universal serial interface). It can be made to behave like serial/I²C/SPI, which may be OK as long as you only need one of these and you can tolerate having to do quite a lot by hand. Something I personally don't always consider worth the effort, if I can get a mega for maybe 50 cents more.

So far all of my little projects have an ISP port, and that includes: ATmega168, ATtiny2313/4313, ATtiny24. It works just fine without pulling the devices apart. Worst case: remove a few jumpers.

I'll rephrase my question: What is the best way to program an ATtiny85?

The idea of this project was to use the Attiny, and I don't have any breakout boards for the MEGA, I'd have to make/buy a PCB.

baum

I don’t have it yet, but I’m thinking of buying an ATtiny85 from SFE.

SparkFun charges $1 more (56% markup; ouch) than you can get them at Mouser and DigiKey. If you plan to get a few, I suggest buying them someplace else.

I know that I can program it with ArduinoISP

Yes.

or an FTDI cable.

Maybe. I don’t know of anyone doing that. I guess this technique would work (bit-bang ICSP)…

http://www.geocities.jp/arduino_diecimila/bootloader/index_en.html

But can I use this?

I’m not aware of anyone using something like that for programming ATtiny processors.

Is the connection the same?

On the processor side, yes. (if it works)

For $5 more, I suggest one of these…

It’s essentially both an ICSP and a TTL serial port. It works great with ATtiny processors. You can leave your favourite terminal application running while the processor is programmed.

Have you seen any ATtiny bootloaders?

I have not. Bootloaders on ATtiny processors are a messy business. It really isn’t worth the effort.

The ISP method is over SPI, right?

Yes.

But I am going to have the ATtinys embedded in a project

Which is where life gets fun! Atmel recommends very low value resistors inline with the rest of your circuit to help isolate the processor when it is programmed. I’ve not bothered so I don’t know if it does or does not help. If you’d like the details, let me know and I’ll try to find the document.

You can safely connect some things to the ICSP / SPI lines. An LED has never caused me a problem. A piezeoelectric buzzer with a series resistor seems to trouble free.

You may have to disconnect some things during programming (via a jumper or switch).

Does the ATtiny 2313 support serial?

It has a UART but no provision for a bootloader. In addition, it has very little SRAM and Flash. Getting a bootloader and your application to fit is going to be a rather big challenge.

Or are there any ATmegas I can use?[/quote]
I’m not aware of any low pin count ATmegas.
> That doesn’t work well with LEDs/transistors(excluding mosfets) connected to the pins though
I haven’t had any problems with LEDs.
> What is the best way to program an ATtiny85?
ICSP with this…
http://www.pololu.com/catalog/product/1300
:smiley:

I haven't had any problems with LEDs.

but that's only because you use a high enough current limiting resistor. Not everybody does that ;-) I'm not sure if your typical programmer would be happy to source 40mA on the SPI lines and still reliably program the chip. Adding jumpers is a safe way. You don't want to find out that it doesn't work once the PCB is done, although it worked on the prototype board. That's not good for your chi.

I’m not sure if your typical programmer would be happy to source 40mA on the SPI lines and still reliably program the chip.

40ma? How did you arrive at that value?

I'll look at the adapter @ sparkfun (search usb avr). Can I program that in circuit (rest of the circuit is a ds1307 and 3 leds)

Thanks everyone!

Well I didn’t. Some people like bright LEDs and take all the poor chip can give :wink:

Let’s just agree that as a rule of thumb there should be jumpers on the ISP lines. The rest can be left to the designer of the project. People with more knowledge can make the decision to do without them.

So I need:

  1. USB to 10 pin: http://www.sparkfun.com/products/9825
  2. 10 pin to 6 pin adapter: http://www.sparkfun.com/products/8508

Then I plug everything in... But how do I program? Arduino software w/ ATtiny selected?

baum: So I need: 1. USB to 10 pin: http://www.sparkfun.com/products/9825

Yes. Or an Arduino. Or the Pololu AVR Programmer. Or a programmer from EBay (retrolefty has recommended one in other threads).

  1. 10 pin to 6 pin adapter: http://www.sparkfun.com/products/8508

From SparkFun...

Board comes bare. We recommend ordering male pins to insert into the programmer and female pins to couple to the ISP connector on your target.

...so, you will also need male headers.

Then I plug everything in... But how do I program? Arduino software w/ ATtiny selected?

You will have to change one entry in "boards.txt" and then yes, you use the Arduino software.

madworm: Let's just agree that as a rule of thumb there should be jumpers on the ISP lines

Sounds good to me. ;)

baum:
Can I program that in circuit (rest of the circuit is a ds1307 and 3 leds)

I have no idea how an I2C device will behave during programming. I assume the folks at Atmel are smart enough to not place an I2C address on the bus during programming. You will either have to run the test yourself or hope that someone wiser than me can answer.

So long as you keep the per-pin current draw below 20ma, the LEDs are fine.

so, you will also need male headers.

I have pins.

You will have to change one entry in "boards.txt" and then yes, you use the Arduino software.

What entry? I have your cores installed, do I need anything else?

Thanks!

p.s. I'm thinking of making a breakout for the ATtiny... an "Arduino Tiny" (need to email arduino team about that). Ill post it here if I finish the EAGLEs.

I assume the folks at Atmel are smart enough to not place an I2C address on the bus during programming

Just looked at the datasheet, I2C pins are SCK and MOSI. What’s the chance of having the right address and legal commands being sent over?

Tsk tsk tsk... challenging Murphy's Law ?

If there is a possibility of several things going wrong, the one that will cause the most damage will be the one to go wrong

[u]Extreme version:[/u] If there is a possibility of several things going wrong, the one that will cause the most damage will be the FIRST to go wrong

It's Your decision ;-)