ATtiny45/85 programmer - Page 1
Forum section: electronics / projects

author: David Braun
author_rank: Newbie
timestamp: February 26, 2017, 07:49:11 pm
content: Hello,Who am I?I'm a forty something hobbyist who enjoys machinist, wood working, automobile, aviation, and electronics projects. I have been working my way through 'Digital Computer Electronics' by Malvino and am nearing completion of a SAP-1 breadboard computer.What I am not.I most certainly am not a EE.Why am I bothering you?I recently went through Jameco's inventory of Atmel chips and pretty much bought 1 of each . I see that most people use Atmel development boards to program their chips via the Atmel software stack. I want to start from "First Principals" and build a programmer that I can use top program other chips. The goal is to understand how it works not to get it working.I'm looking for input from people who know what they are doing to see if it would be possible to write to the ATtiny EEPROM without a programmer via a standard serial connection and MINICOM. Would anyone have any interest in mentoring me?Cheers,David

author: amitchell
author_rank: Regular Contributor
timestamp: February 26, 2017, 09:05:16 pm
content: Hello,This may be a good place for you to start, it uses an attiny to program other attiny's.https://learn.adafruit.com/usbtinyisp-AdamQuote from: David Braun on February 26, 2017, 07:49:11 pm

author: Ian.M
author_rank: Super Contributor
timestamp: February 26, 2017, 10:57:36 pm
content: Inventing your own programmer + software to run it for <whatever> MCU seems to be a historic rite of passage for FOSS hardware types, but the result is rarely as useful compared to commercial programmers and clones, as a Fred Flintstone bicycle compared to a pickup truck.I've been down the home-brew bit-banged parallel programmer road under DOS, programming PIC16C84 chips with software based on David Tait's PP utility, ported to Borland C and hacked on till it worked with my hardware - weeks of work to program a single type of chip, and it took many more hours to add support for a PIC16F84A. I soon moved on to using WinPIC, which was reasonably simple to configure for my hardware and let me program far more types of PIC under Win98 and even XP, but at that point I no longer needed to understand every single bit transition in the programming protocol. I then bit the bullet and got a PICkit 2 as my valuable time was better spent working on PIC projects rather than on inferior tools to program them. The situation with Atmel AVR MCUs is fairly similar but I don't have hands-on experience from the 'write your own programmer' era.Modern PCs tend not to have the legacy parallel and serial ports used by the traditional bit-banged 'dumb' programmers for most MCUs, and if you are lucky enough to still have real ports, Windows versions more recent than XP tend to get in the way of the programming software using them. Most currently supported programmers are 'smart' usually with a USB interface and to build one you need a MCU programmed with the correct firmware. Unfortunately, this is a chicken and egg situation - you need one to build one.There are a few ways around it if you don't have a legacy PC running an old Windows or Linux - specifically for AVR, the ArduinoISP sketch uses an Arduino as a programmer, or its possible to do bit-banged programming really really slowly (an arthritic tortoise wading through treacle would be faster) using a FTDI breakout board. Seehttps://learn.adafruit.com/ftdi-friend/programming-blank-avrsThe only people that still care about the details of the low level programming protocols outside of the MCU manufacturers are those maintaining or porting AVRDUDE or similar + those with a master/slave MCU project who need the master to be able to update the slave firmware and cant use a bootloader in the slave.

author: FrankBuss
author_rank: Unknown
timestamp: February 27, 2017, 12:01:18 am
content: Quote from: David Braun on February 26, 2017, 07:49:11 pmNo, that's not possible without extra hardware. The Atmel programming protocol is SPI, e.g. 5 V for ATtiny (see the datasheets for details, it is not complicated). All signals of a standard serial connection, if you mean RS232 and not a TTL USB serial adapter, uses from -3/+3 V up to -15/+15 V. And then you need to translate the serial protocol (1 bit at a time) to the SPI protocol (1 bit in, 1 bit out, and a clock in parallel). With a voltage level converter, or a TTL USB serial adapter, your could try to implement some bit-banging on the DTR/RTS/CTS lines, but this would require some programming, unless you want to set each bit individually in minicom, which would be very boringI think an easy way of doing it using minicom, while still learning and programming the programmer yourself, would be to use an Arduino. You can buy itfor EUR 2.57, free shipping. Then you could write a simple Arduino sketch, which translates the serial port (it has one integrated) to SPI and back. Use hex code and some control commands to set the reset line etc., then you could use minicom to program it, or implement something like XModem on the Arduino, then you can simply upload the firmware file from minicom. If you want something fancy, you could useProcessingon the PC side to implement a nice GUI for your programmer, with verify etc.

author: DaJMasta
author_rank: Super Contributor
timestamp: February 27, 2017, 12:02:00 am
content: There's an arduino sketch that lets you program your attiny with an arduino as the ISP (and with a couple of modifications and a higher voltage source, you can even reset the high voltage registers), but I've had good luck with a USBasp programmer which is quite cheap on ebay.Going with a development board or dedicated programmer is nice, but the trouble will come from the package - attinys come in everything from 6 pin so packages up to 64 pin (maybe more?) QFNs and everything in between.... so while having a socket can be really helpful for a lot of chips, it's also not going to work with most of them. If you get a simple USB stick programmer or an arduino to use as a programmer, you can just use a little space on your breadboard and some jumpers to get the needed pins connected up.As far as I know, the eeprom isn't externally writable. It would be easy to write a program that took data from the pins in whatever configuration and wrote them to eeprom, making them programmable without going through flash, but since it's designed to be used by the chip and not by an external chip, I don't think there's a way to expose the eeprom by default.

author: FrankBuss
author_rank: Unknown
timestamp: February 27, 2017, 12:40:49 am
content: That's interesting, I have only used a ATtiny 2313 so far, with an AVR Dragon programmer:http://www.instructables.com/id/Using-a-Quadrature-Encoder-with-an-ATtiny-2313-and/But the ATiny45/85 uses the debugWire protocol. Unlike the SPI protocol looks like it is undocumented. But there is this page:http://www.ruemohr.org/docs/debugwire.htmlSo it uses a simple RS232 interface, but with 125 kbaud. This means it might be possible to use minicom, if the suggested modification with a 14.745MHz chip clock and then using 115,200 baud works.Writing the EEPROM is possible, too, but since the OP bought new chips, I guess he means flash. BTW, better to buy them at Digikey, has more different parts than Jameco.

author: amyk
author_rank: Super Contributor
timestamp: February 27, 2017, 11:21:27 am
content: You should start by doing itmanually:There is no minimum clock frequency. All the information you need is in the datasheets.

author: FrankBuss
author_rank: Unknown
timestamp: February 27, 2017, 02:06:51 pm
content: Quote from: amyk on February 27, 2017, 11:21:27 amLol, do this with a few kB. Damn, one wrong bit in the last byte, again

author: Bryan
author_rank: Frequent Contributor
timestamp: February 27, 2017, 10:09:51 pm
content: http://highlowtech.org/?p=1695

author: eugenenine
author_rank: Frequent Contributor
timestamp: February 27, 2017, 10:41:30 pm
content: replace the switch with a relay and control the relay with rs232I think the closest you'll get will be using AVRdude. You can review the source to understand how it works (thats where I'm at now)

author: David Braun
author_rank: Newbie
timestamp: February 28, 2017, 12:55:12 am
content: Thanks for all your suggestions!Cheers

author: Fungus
author_rank: Super Contributor
timestamp: February 28, 2017, 01:43:41 pm
content: Quote from: David Braun on February 26, 2017, 07:49:11 pmThe Atmel datasheets have all the methods available to externally program the memories of their chips.Standard RS232/Serial isn't built into the chip but you can reserve a small part of the flash memory to hold a program which receives RS232 data and writes it to the memory (this is exactly what the Arduino "bootloader" is an RS232 to flash memory interface that runs for three seconds when you reset the chip).The AVR datasheets have sections titled "self programming" and "bootloader support", you might want to start there.

author: nuno
author_rank: Frequent Contributor
timestamp: February 28, 2017, 02:13:10 pm
content: I did wrote the programmer software for my few first AVRs, AT90S1200, then ATtiny2313, ATtiny26 and ATmega8. It was lots of fun and not that hard, just me, the datasheet and my PC's soundcard as a scope. 1st AVR I ever programmed was with this thing, so you can imagine the joy of the 1st LED blink. Still use it sometimes, as I have old projects that still use it from the Makefile. It was C running on Windows in a computer with... a parallel port (I still have one). RIP LPT, you'll be missed.

author: technix
author_rank: Super Contributor
timestamp: March 02, 2017, 11:52:21 pm
content: You can get a Raspberry Pi as a programmer for this thing. Using a full Linux computer for a job like this is clunky but it works.

author: boffin
author_rank: Unknown
timestamp: March 03, 2017, 06:03:19 am
content: Quote from: David Braun on February 26, 2017, 07:49:11 pmHoly shite! That's still around ? That was a text I had in college in 1980 !QuoteI'd be more than happy to help point you in the right direction. Basically to program an atmel chip, you just need to hook up a few pins into the right place and run the software that comes with the arduino suite. Short of buying a full fledged program 101 different chip family type programmers, for the ATxxx series, you have three simple options1) You can use another Arduino. Lots of decent examples here:https://www.arduino.cc/en/Tutorial/ArduinoISP2) You can buy a USB ASP (which is basically a tiny arduino and a 10 and/or 6 pin programming cable). I have one similar to this. You can get them with just the 10 pin cable, but spend the extra buck and make sure you have the 10 to 6 adaptorhttps://www.aliexpress.com/item/Free-Shipping-2PCS-USBASP-10PIN-TO-6PIN-ADAPTER-New-USBASP-USBISP-AVR-Programmer-USB-ATMEGA8-ATMEGA128/1807010158.htmlTo actually hold the chip in place (and save having to run wires manually) you'll want something like this:https://www.tindie.com/products/insidegadgets/attiny-programmer-adapter-pcb-v14/?pt=full_prod_searchor thishttps://www.tindie.com/products/bot_thoughts/attiny85--attiny13-development-board3) you can buy a dedicated programmer with a nice zif (open/close) socket like this:https://www.tindie.com/products/jeffmurchison/tinyloadr-avr-programmer/I've used all three (in that order).

author: eugenenine
author_rank: Frequent Contributor
timestamp: March 03, 2017, 12:21:10 pm
content: A combination of your #1 and # are what I have. Use an ardiono and a shield with a zif sockethttps://learn.adafruit.com/arduino-tips-tricks-and-techniques/arduinoispwhen you want to program an avr you stick your programmer shield on top of the arduino.

author: rrinker
author_rank: Super Contributor
timestamp: March 03, 2017, 07:57:28 pm
content: I built myself a shield complete with the 3 status LEDs plus an LED for the stock blink sketch to plug in to one of my Unos to program ATTiny 45/85. This then gets used with the Arduino as ISP sketch running on the Uno.