loading

Step 4: Programming Digispark via ISP

You can now use ISP programming to program the ATtiny85 on the Digispark as you see fit. I use the Uno loaded with the example ArduinoISP sketch to do that.

You can continue to use the Micronucleus bootloader and the Digispark-specific version of Arduino IDE. Pin 5 is now a reset pin instead of a digital pin, so make adjustments in your sketches for that.

OR

You can install an ATtiny85 core in your Arduino IDE and program it using ISP just like a stand alone ATtiny85. The Digispark has been converted to an ATtiny85 breakout board.

OR

You can install the Trinket bootloader on it and use it as a Trinket. See Adafruit's website and tutorials on the Trinket.

Command line for avrdude

Your command line for avrdude may use different directory paths and different ports. To learn what the correct command line looks like for your computer, I think it is easiest to upload the ArduinoISP sample sketch to the Uno, set Tools, Programmer to Arduino as ISP, and use the Uno to burn the bootloader on another Arduino of yours, such as a Nano, Pro Mini. You can actually leave the Uno disconnected and attempt to burn a bootloader to an imaginary device if you want. If you have gone into the Arduino IDE preferences and checked show verbose output during upload, the command line for avrdude which attempted to burn the bootloader will be shown to you. All you need to do is change the last part of the line that gives the path to the bootloader, and replace it with the path to your bootloader, and add the fuse settings. And you may need to also change the -p option, which is where you specify the processor type.

Continue to use board as a Digispark and upgrade Digispark Micronucleus bootloader

I downloaded the latest Micronucleus bootloader from here: https://github.com/micronucleus/micronucleus/tree...

And loaded it onto the Digispark like this:

/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avrdude -C/Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf -v -pattiny85 -cstk500v1 -P/dev/cu.usbmodem411 -b19200 -Uflash:w:t85_default_micronucleus.hex -U lfuse:w:0xF1:m -U hfuse:w:0xD5:m -U efuse:w:0xFE:m

Use board as a Trinket

I downloaded the Trinket bootloader from here:
https://github.com/adafruit/Adafruit-Trinket-Gemma...

And loaded it like this:

/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avrdude -C/Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf -v -pattiny85 -cstk500v1 -P/dev/cu.usbmodem411 -b19200 -Uflash:w:trinketgemma_v1.hex -U lfuse:w:0xF1:m -U hfuse:w:0xD5:m -U efuse:w:0xFE:m

If it has the Trinket bootloader on it, it is now a Trinket. If you are new to Trinket, look at the Adafruit website and tutorials about Trinket to find out how to set it up your IDE for programming it. It is a little different than other Arduinos in that you do not need to select a port, but instead you set Programmer to USBtinyISP. Just like with Digispark, the Trinket does not use Serial Monitor the same way you might do with other Arduinos.

<p>When I found the Digispark clones on Banggood, I bought a handful because I became addicted to SMALL -- if all you want to do is drive a couple of LEDs or some NeoPixels, who needs an Uno, right? Cheap too, but mostly small. This is a great, detailed tutorial with sharp pictures, details and (forgive me for this) understandable English. Very educational, I will benefit from your experience, thanks. You are bookmarked.</p>
<p>Not sure why that comment posted twice and even more not sure why it took me so long to see that it had posted twice and delete the second one.</p>
<p>I made an all-in-one plug-in board with HV programmer for Digispark (left) and regular ICSP programmer for Digispark (right) and ATmega328/168. I have room for a 5V-to-12V booster lower left to be added (item ordered and in transit). The capacitor for the reset is activated by a simple jumper. I added two tiny LED (from analog outputs 18 &amp; 19): one that flashes at low intensity while waiting for character entry, and runs full light when in program mode, and one that runs full light when 12V is active. ..a bit of gadgetry but fun to see.</p><p>Delay time for 12V kick-in in program adapted to 40usec. Fuses for Digispark adapted equally: see my previous note here.</p>
<p>Forgot to add this spaghetti-picture-underside.</p>
<p>How do you set the extended fuse with this program? Or don't you need a HV programmer for this fuse?</p>
I think that is the case, you don't need a HV programmer for the extended fuse because nothing about the extended fuse could cause the chip to be non-programmable via ISP. I did not study this programmer code in detail or alter it, it is from a different blog and I just adapted the schematic a little bit to work with Digispark boards. <br><br>I have another Instructable https://www.instructables.com/id/HV-Rescue-Simple/ that is based on Jeff Keyzer's version 2 of his HV Rescue Shield. I simplified the hardware to make it breadboard-based with fewer components, and enhanced the sketch to work with most Arduinos and give it a menu with control of the fuse values.
I looked at this instruction; can you upload the &quot;HV Rescue Simple schematic.png&quot; with higher resolution? The current one is barely readable. Thks!<br>
<p>I just downloaded the zip file and in it is the schematic. I was able to zoom the schematic to any size with my favorite image editing program. I think you just need to zoom in if it is too small.</p>
<p>Fuse settings are wrong if you want to emulate the Digispark settings without pin5 reset disabled. Lfuse needs to be E1 and Hfuse need to be DD. Efuse should be FE.</p>
<p>I don't think I agree with using the word &quot;wrong.&quot; Those are my preferred fuse values. The differences between those and what the Digispark comes set with are brown out detection, EESAVE, and start up time. Digispark's official values are on this page: http://digistump.com/wiki/digispark/tutorials/programming </p>
<p>You are right, your instructable says &quot;..return to a trinket.&quot;, not &quot;return to Digispark&quot;. I should have used the word &quot;different&quot;.</p><p>However, it would still be usefull for anyone wanting to use their Digispark with the USB downloader, that the fuse settings must be adapted in your program.</p>
<p>Works well, except on two Digispark where I had the RSTDSBL set (pin5 as output, no reset). On one Digispark the program hangs 2 minutes at reading lfuse, then finalises ok. The other Digispark causes the program to hang after lfuse reading as E0.</p><p>Strange thing is it works well on Digisparks where RSTDSBL is not set.</p><p>What could be the reason?</p><p>Erik</p>
<p>I think I may have solved it: I increased &quot;delayMicroseconds(20);&quot; to 60: page 156 of the datasheets specifies between 20 and 60 microseconds delay between Vcc and Reset High..</p>
<p>This is an interesting instructable, in regards to the reference to the 12v battery . I haven't seen a battery on other programmers, so this bears making time for more reading. Thanks for the clarification on why you used 100-ohm resistors, versus the 1k used in the other page you referenced. :-)</p>
<p>Great instructable and thank you for sharing it :-D</p><p>Your instructable solved my problem to an extent.</p><p>When I tried to program digispark's attiny85 to run a blink code with a delay of 1000ms, the delay doesnt seem to be 1000ms. Instead it is observed to be around 16000ms. I measured it using a stopwatch I programmed the attiny85 with the method that you have decribed. Any solutions to the above problem? TIA :-)</p>
<p>You may also want to check out this Fuse Calculator (http://www.engbedded.com/fusecalc), if you want to get a bit deeper into the AVR programming side. Clock speed is just one facet you can modify in that programming sketch. This helped me to get the Tiny85 running at 16 MHz internal clock. More clues can be found in one of my Instructables, https://www.instructables.com/id/IKEA-Star-With-ATtiny-and-NeoPixels/</p>
I think the fuse settings and the core you use when you compile a sketch for it determine how fast the processor runs. It sounds like your sketch is compiled for 16MHz but your processor is actually running at 1MHz if you are noticing that speed difference. If you have put the Micronucleus bootloader back onto it and are programming it as a Digispark, then you should be able to find information on the Digispark website or wiki about speeds. If you have put the Trinket bootloader on it and are programming it as a Trinket, you should be able to find information in Adafruit's tutorials or forums about that. There are a variety of cores you can use to add on to the Arduino IDE to program plain ATtiny85's using an ISP programmer, and most of those will involve using the Burn Bootloader function of the IDE to set the fuses to the appropriate values. Help for using those cores could probably be found at the arduino.cc website in the Microcontrollers section of the forum.
<p>Thanks for this great Instructable!</p><p>This worked really nicely. I had a bricked clone-spark due to a failed bootloader attempt. This brought it back to life and upgraded it with the addition of the Digispark bootloader (so it's much easier to program now).</p><p>Worked like a charm - it was so easy I almost thought I'd screwed it up :D</p><p>In case it helps others to know: I used a PN2222A transistor, and a direct-clip-on adapter that allowed me to directly connect to the chip (I haven't put headers on the board, to keep it tiny).</p>
<p>Thanks! I was messing with my digisparks bootloader and bricked it, this tutorial helped me save it! After hours of searching on the web, this is the absolute best tutorial i found! It should be noted that I did not use the 100ohm resistors or pin 13 to transistor and it still worked! (although it was probably risky), i just connected the 1kohm resistor from the battery to pin 5 manually without a transistor. Thanks again!</p>
<p>Thanks, I have edited the Instructable to include the alternate wiring. </p>

About This Instructable

15,674views

43favorites

License:

Bio: These Arduinos are driving me up the wall.
More by dmjlambert:HV Rescue Simple How to unlock Digispark ATtiny85 and convert it to a Trinket Bluetooth Serial Adapter for Pro Mini 
Add instructable to: