Ralph, this is great stuff. One of my current projects is using six gpio pins on a Nano. I want to use an ATtiny85 and now thank to this video I think I can. Will save a lot of space on the board. Yours is by far the best explination of how it's done. Good instructions/schematics on the 12V board too. Also have to get a 128x32 ssd1306 OLED working on i2c, so hopefully can figure that out and I should be good to go. I have a few leads but if you have and inspiring tips then I'm all ears. Huge thanks as always for your great videos.
If you're looking to get the SSD1306 running on I2C on the Tiny85, I did a video on how to get the I2C running (using a different LCD screen) which may help. Video #82 ruclips.net/video/5bnXeHz06Ck/видео.html
Indeed you could Nick. If you see my response to 2000jago you'll note that I mention there are several choices and whatever is right (for whatever reason - size, cost, power, features, I-got-one-in the-toolbox) then it's the right one for you! Nice to hear from you again.
Hello Ralph , I found out from Atmel ATTINY85 datasheet page 148 note 2. After this fuse has been programmed device can be programmed via high-voltage serial mode, only, so the best way to alternate is to use an HV fuse setter.
Thanks John, looks like the current UK heatwave will peter out just in time for Bank Holiday Monday! Gosh! We didn't see that one coming! I do think that Arduinites should at least be aware of this Tiny85 chip (or, as Nich B points out, its family) and perhaps just get on and experiment a bit. Whether you'd then ever use it in a project is a different question altogether! Good to hear from you.
Unreal weather at the moment, eh! And yes, Arduinites should be aware of this littel beauty. Also, may I add, I really do find your approach to videos quite refershing, and am enjoying watching them (hence the comments in random ones from the past!!!) :)
My 'video office' at the moment is 30C degrees - far too hot for any Arduino work really (but here I am...). Thank you so much for your kind words about my videos, they (your words) are most appreciated! Now, where's my ice cold beer...
You're very welcome, I hope your subscriber numbers rocket soon, i am sure they will. Yep, I know exactly what you mean... but me too, I am here in my little spare bedroom amongst Mac's, Dell laptop turned on for 1st time in 12yrs - and it works (Linux install coming up), Arduinos, ESP32 research, and of course... a nice cold glass of wine... (OK, bottle!!) :) It's Friday after all.
Great information and well presented Ralph. With regards to the 12V programming voltage you may be able to use a MOSFET to control the supply using one of those extra ports you have available. I think this programmer could also be built on a prototype shield board.
You mean control the 12v supply via a logic-level MOSFET thus dispensing with the slider switch? Yes, indeed, that would be an alternative approach. And I'm sure you're right about building this on a prototype board, it could be a very neat job!
You can NOT use a MosFet. You could use a LOGIC GATE MosFet. The most common ones are in a TO-220 package which takes up space. Plus you have ESD headaches. TUNs are cheap and easy to get.
They are called "fuses" because originally, this sort of setting was literally a fuse - a bit of the IC that was permanently opened up with a relatively high current pulse. Now that's a way to permanently make it impossible to read the code back off a microcontroller. Now it is a resettable device, although the security now is that resetting certain fuses also erases the program memory.
Now that you can get LGT8F328P boards for about a pound each if you buy 20 at a time on AliExpress, I wonder if there's much point in using an ATTiny85 except maybe if it saves power in a battery-operated project? Of course there's also the sense of pride and accomplishment.
Your last sentence struck a chord with me, Sean. Imagine (it's easy if you try) that all cars were the same price, from Rolls Royce to Smart For Fours. Would we all be driving Bugatti Veyrons? Some, certainly. But the thrill of getting some old "classic" car restored, and running reliably is a real challenge, a labour of love. Whilst I do not restore old cars, using a low power and smaller microcontrollers is always a challenge to the maker! And, as you say, the sense of accomplishment that you have really honed that code gives a sense of pride too. That said, I tend to use ATMega328-based boards for most of my projects (so, Nano, Pro Mini, even the relatively large UNO) but now and again I'll use a Tiny85, Tiny13, ESPXXXX and now that a viewer has pointed me to a new bootloader for the STM32 (yet to be verified) that one too!
Great video as ever. What do you do if you don't want to watch any more Christmas movies on TV and the weather looks like rain? - you finally get round to building a HV programmer to unbrick that MCU. I made a slight product variant - used strip board to hook in Uno 5v so as to feed a small boost convertor to generate the 12v. I also put a jumper in place just in case I ever come across a bricked ATtiny15 and want to route SCI to correct pin. I padded out your code to handle Reset Disable for a range of MCU and added a fuse reset to make this more generally applicable to bricked MCUs. It seems to work, I can read, change and re-read fuse settings to confirm the changes made. I bricked an ATtiny13A in my early days by setting the clock speed to 128kHz and also adjusting the System Clock Prescaler until it was too slow to talk to using my ISP (I was trying to save power OK). I'd like to unbrick this device (just to know I can) in place of throwing all 50p worth of it in the bin. I see I am successful in setting fuse defaults back to Low: 0x6A, High: 0xFF but I can't seem to enter programming mode using an ISP (Studio 7 via a Pololu ISP in this case as it has a rocking GUI fuse editor). Would you have any hunches what also might be wrong (other than it's U/S and lacking the magic blue smoke)? Best regards Happy New Year Peter
It looks like you've made some interesting improvements to my original design, very cool 👍 Regarding getting the ATtiny13 reprogrammed, you'll only be able to do this using SPI initially, unless you've loaded a bootloader of some kind and are using a hacky way to get it into the right state. Adafruit describe this for other processors, but admit it's unreliable. Also the correct oscillator must be used, to whatever you've set via the fuses.
@@RalphBacon Thanks for all your encouragement. I managed to unbrick it in the end. I remembered I'd bricked it by selecting internal 128kHz oscillator AND then compounded my issue by being bold with the System Clock Prescaler. I am using a Pololu USB AVR Programmer (emulates STK500 to Studio7) and I am able to control the ISP frequency through the Studio 7 fuse blowing GUI. So, using the HV Programmer, I modified the LFUSE value for ATtiny13A to 0x7A (no CKDIV8) and set the ISP frequency to as low as it would go (1.747kHz) and success! I did some more testing with the ISP frequency and the fastest I can successfully run this at is 7.008kHz - wow that MCU clock must be slow!) BTW - do you know where you can source genuine ATtiny402 devices? I got a few from eBay, mounted them up so I could play with them, built a UPDI programmer and found out that they had incorrect device IDs - I hacked my way round that only to find out I could not control two of the GIO pins - further reading indicates that batches of these also have corrupt pin multiplex tables in the silicone. Dr Azzy suggests not sourcing from eBay / AliExpress (I'd agree). Main suppliers advertise a next production run in Aug next year (2023). I only want a handful and spending 10 times the value of the shipment on postage sticks in my throat. Keep up the good work.
I remember the thousands of PROMS, EPROMS and EEPROMS we burned at Boeing during the late 70's and 80's. Then we started in on PLA's for even denser circuits. At least the EPROMS and EEPROMS were reusable
But surely the ones you mention (in my Grandad's time, I believe, cough, cough) only had about 100 bytes capacity? Probably 4-bit devices too, or were things more advanced than that? You'll be telling me that you had running water too, no doubt. Just kidding, Raymond, I remember mainframe 'hard disks' consisting of many platters and giving us a whopping 16Mb (that Mb not Gb) in the early eighties (as my Grandad told me as I sat on his knee).
Mr Bacon: Thank you for all the wonderful videos. Recently I used the video on using all 6 pins on an ATTiny85. Very informative and helpful to a project I currently have on my table. BUT it left with with a question I can not find a simple answer to. Consequently I am asking you if you don't mind. How can I configure the reset pin PB5 to an ADC input. Which brings up another thought. Would you consider a video on pin reassignment for the ATTiny85 or ATTiny's in general. Thank you very much for everything.
Hello Mr Zubli, thank you for your kinds words. If you have reset the fuse (as described in this video) for physical pin 1 to turn it into GPIO digital pin 5, you could try and do an AnalogRead on A4 (I'm guessing this is the next analog channel available). If it doesn't work it may just be that they never included the circuitry for ADC on physical pin 1/GPIO 5 as it is normally used as the RESET pin anyway. Do let us know how you get on though!
I'm going to use this trick to make my 8x8 dot matrix led which requires 2 sets of 74xx595 IC. I already soldered ATTiny85 and 74xx595 onto the PCB and I just found out pin5 is not usable until reset is disabled. You mentioned it's weak I/O pin. Does it have enough current to make 74xx595 clock pin work?
@@RalphBacon Thank you for your advice. I have more questions. What is Zener Diode model number you put in your circuit? How many voltage and how many watt? and what value of that capacitor?
@@RalphBacon At 21:17, there is one component next to the capacitor. It sits between 12v rail and resistor that goes into the collector of the BC547 transistor. It looks like Zener Diode. That's why I'm confused.
Good day sir, I love your videos.I even made a humidifier of such with auto filling of water. Well on with my question. (sorry for the long question) I made this project but im having a problem. Im using a 12v 1.5A power pack and im getting intermingling fuse changing. This is what is happening. I programmed the attiny85 to blink PB0 to PB5 one at a time. As it should it only flashes PB0 to PB4. I run the code, it shows the default values but will not set the new value constantly. Im wondering via a scope what voltage everyone is getting on pin 1 while it is writing. Im getting 10v ± .5. Thank you for your time in advance.
Hey Havid, what a question! Remember that unless you have changed the 'fuse' setting to allow physical pin 1 to act as a GPIO pin then it is only used as a reset pin. Be aware (or perhaps, beware) that if you do change that fuse setting (all described in this video) to allow Pin 1 to act as a GPIO pin, then you must reset that fuse again using a special 12v resetter (see my video) to allow the board to be reset to allow uploading of code - otherwise your ATTiny85 will become 'bricked', no longer able to be programmed. All is explained in the video, so watch very carefully! All clear?
VERY GOOD THANKS i was looking at this maybe i can use a shift reg to add extra out put pins do you have any code for this, i want to make a simple security system that just has blinking lights on each window to make it look like the window has some sensor on it. i did this before using a 4017 and 556 timer
Happy New Year from downunder.....new to this fuse setting I have a program where it is required to set fuses at certain values, Low-E2, High-DF and Extended-FF. Going by your video here, this is possible to do at any time, either before or after uploading the sketch. Correct..? Your program though is only meant for resetting the reset to an I/O and back again.....??
Happy New Year Jorgo! Fuse settings? You can only set the fuses as part of a bootloader / sketch upload; in other words, you can't do this programmatically when the sketch is running. You can change the fuses by editing the boards.txt file (found in C:\Program Files (x86)\Arduino\hardware\arduino\avr\boards.txt although your modified versions can also appear here: Arduino Sketches\hardware\breadboard\avr\boards.txt) and then using that board definition. You have to be careful here. Setting the wrong fuse could brick your Arduino, so use this fuse calculator and always double check the settings - and never "try things out to see what happens" (don't ask me why I know this): www.engbedded.com/fusecalc The video here shows how to use all six pins for GPIO (including the RST pin) but you have to use my fuse resetter to get the RST pin back to its default state so you can upload a new sketch. Take care!
@@RalphBacon Don't want to change the fuse settings when running the sketch. Sketch I have here calls for the settings Low = E2, High = DF and Extended =FF. Intention is to do this using a HV programmer. I watched your video where you changed the reset pin to an output and back again via a hv programmer and showed how it worked with the flashing LED. It appears the sketch itself remained intact in the Attiny at that time. So my query was, does it make any difference if I use a hv programmer to change the fuses before or after uploading the sketch that will be run on the Attiny ? Your code I believe only changes pin 1 to an I/O and back to a reset...??? Just thinking...I should be able to use a usbasp programmer to set the fuse I require...yes..? Added a ten pin plug to an 8 pin ic clamp to suit usbasp programmer and using a couple of different software (Avrdudess and eXtreme burner...had to change the driver to libUsb in zadig) changed the fuse settings to what was required. Did similar to yourself in that I changed over to one setting in one software and back again in the other. Then loaded the sketch to the ATtiny85 using the usbasp programmer in Arduino IDE.....Yet to test outcome but no errors so far. ...Cheers Jorgo
You will only need a High Voltage (12 volts) if you want to change the RST pin back to a standard GPIO pin. All the other fuse settings can be set just by writing the values to them, in the way you seem to be doing already. When using the HV resetter (for the RST pin) the fuse setting is changed but the sketch remains intact. When changing the other fuses without using an HV programmer the sketch is also kept intact. It seems you are good to go, Jorgo!
Hi Ralph. Love your videos mate! How have you got that LED hooked up to the HV line into the ATtiny85 pin5 Ralph? Won't that cause a voltage drop of a few volts along with the 1K resistor...? What is the minimum Voltage Pin5 Needs to See in order to ReSet the fuse? Thanks.
If you are referring to the LED2 that shows the power is on from the 12v battery and goes to pin 1 of the ATTiny85 - this is the RST pin and requires that pulse to reset the fuse internally. To reset the RST pin from GPIO back to RST you need 12v. Take a look at the circuit diagram in video #144 (ruclips.net/video/bTTdvcnAOgg/видео.html ). The PCB and circuit diagram are in the GitHub and are for EasyEDA.
@@RalphBacon Awesome yes, Got it. Thank you Ralph. I'm still not having any luck here. when I run the fuse reset it always reads ALL fuses as FF.... What do you suppose that could mean? Which pin is responsible for getting the hex value of the fuses? I've checked and rechecked my connections many times, but to no avail. I'm going to try the same schematic using a Nano. Many thanks to sir, I love your vids and I love Benny's input. I was sad to hear of his passing.
@@RalphBacon Hi Again Ralph. I found that it was because the 12v battery (in name only) was below 10v - so that meant it would enter high voltage programming mode. I've done some re wiring of the circuit and put in a 9V Battery/Boost converter controlled by a Photo Voltaic Mosfet Driver (PVI5080 - Love those things!) which I get the Arduino to power up and power down at the end of the program. I'm now making the dedicated board. Just one question, At the start of the program, in the serial monitor the first line reads "NTurn on the 12 volt power." I can't find where this annoying Capital N is coming from... Do you have any ideas Ralph? Other than that, it's all working brilliantly. Thanks again, for you help, vids and general coolness. Cheers.
I was looking at the high voltage programming site, just two days ago, and why? It was to see how one changes the functionality of P5 on the ATTiny. Its spooky how often that happens with your videos. Your presentation helped my understanding considerably, thank you. I do have to voice (or is that publish?) one small concern: The timing of Benny's interventions seem so uncannily perfect that a more suspicious soul might be forgiven for thinking that a boot poised above that wonderful pet's tail might be the cause.
Michael, how can you even suggest that Benny is not treated with absolute love and care? He is known as BCE - Best Cat Ever, and that's because he is. I could no more poise my boot above his tail than I could pull out my own teeth with a rusty pair of pliers. The very thought.... But, that said, Benny is most pleased that his video appeared at a serendipitous time and we both hope it will help you in your investigations. My stripboard module works *very well*, is self contained (so I don't have to scrabble about hunting for cables or batteries or whatever) and I have even dedicated a £2.42 Uno to the project so the code is always loaded. Cheap as chips, really. Anyway, I'm not sure I can forgive you (yet) for your insinuations about my treatment of poor Benny. Hmph.
Well!! Thats me told! Keep 'em coming Ralph. I have seen from other comments that I am not the only subscriber who finds the day a little more brighter for seeing a new video of yours in his/her youTube home page.
Ha ha! Yes, consider yourself told (off). But seriously, I do appreciated your support and it's very motivating to hear that my (Benny's) videos are appreciated so much. Thanks for posting, you're forgiven. Benny says he never took umbrage anyway. See what I mean about him being the BCE?
The reason would be power consumption and possibly size. Dawid Watts did a video on how to switch an ESP8266 on and off with an ATTiny85 controlled MOSFET. He was able to extend the battery life to the point were he decided to end the project (or put it on hold). ;-) Another reason for choosing an ATTiny85 is price. These micros are cheap. I also like to think of it this way: If you have enough IO-pins on an ATTiny85 and the performance and memory are ok, why use anything else? Assuming of course that the alternative is an ATMega328P or similar.
Oh, and I forgot to answer the first question. Yes, I have several ATTiny85s and ATTiny2313 and ATMega328P among other Atmel micros. However, I don't use them (yet). I put one of them on a breadboard from time to time, write some code and program it. I really need a reason to use any of my Nanos/Unos or other DIP package I have lying around. :) The demand for microcontroller-controlled gadgets are low at the moment.
Thanks for the reply, Robert, it's interesting that your replies seem to reflect the general mood regarding the Tiny85. Power, size, good enough and so on. Well, if nothing else my videos on this device will have raised awareness!
Great video again Ralph! Does anyone know where I can buy a pre-made fuse resetter by any chance? I tried searching on ebay but I might have used the wrong terms(?) Cheers!
I found this one (UK site): www.ecrater.co.uk/p/25674542/usbasp-usbisp-avr-programmer-usb?gps=1&gclid=CjwKCAjwt5DXBRAtEiwAa3vyEhsK-bMlOC4PwiLkMW09NtHvcz5Vxj-rJ1awjTS_1ywL7b84MuAMUxoCTvcQAvD_BwE But you're on your own to determine how to use it and whether it will do what you want, I'm afraid, Mikael! I searched for ATTiny85 Programmer. But making one takes about 1 hour, does what it should, and costs very little. Always assuming you can solder OK, of course. Perhaps others will suggest other items...
Thank you for the link Ralph. I have one of those around. Is it able to de-brick an attiny85 that I can not communicate with as well? I mean the "Yikes!" error message. I bricked mine using the wrong clock I think. Or do I need to construct one of these 12v boards in order to get it working again?
Ok so I built one of these reset boards and it works! However, the readings that come back after writing the fuses are a little odd. Another strange thing is that the chip seems to totally reset. If I have set the clock to 8Mhz and programmed it it will switch back to 1MHz (noticed by slower blink). Is that to be expected with this method? This is the output I'm getting when using your sketch: pastebin.com/1rDePKBY
Let's put it this way, MIkael: the fuse-setter that I built ONLY set the RST pin 1 back to a reset pin (rather than a GPIO pin). That's it. It didn't change anything else because it wasn't setting any fuses, it was just applying that 12v pulse at the appropriate time. I'm guessing you're doing more than this, hence the whole chip resetting (but I'm guessing). You should be able to set the speed back to 8Mhz just by programming the board again with the required settings (and perhaps a few fuse settings that you might now have inadvertently changed).
The thing is that I was only using this sketch but still saw that behavior. I figured it out though. My default settings in the Arduino IDE was 8Mhz internal, rather than the 1Mhz (which seems to be factory default). The difference there seems to be the low fuse which is 62 at 1Mhz and E2 at 8Mhz. The setting in the fusecalc is called "Divide clock by 8 internally; [CKDIV8=0]". So what I gather is that if I want to run the A85 at 8Mhz I need to set the default low fuse to E2 rather than 62.
You could bit-bang a further PWM pin I imagine, Nicholas, but it would not be hardware-based and therefore not independent from the rest of the sketch. MIght work, might not depending on what else you are doing in your sketch. You could not have a single "delay" statement in the entire sketch.
Hi I've enjoyed your videos. i have an issue with an attiny 85 board. i have the one you have shown from allexpress, and it works pretty good, however i also have another board that i can't get the IDE to recognize. i was wondering if you've seen this board or now how i can use it. I would like to use it because it comes with usb and a socket to switch out the tiny85 if needed. this is the board.
Er, which is the board, Spencer? I think the link disappeared. However, I have a new, very small ATTiny85 board, with USB connector that I want to try out when I have a few nano-seconds spare in my life, maybe they are the same. Send me a link to the webpage you bought it and I will compare.
Oh, I see you posted the link separately, that's fine, I'll check it out. In fact, I just did and it looks JUST like the one I have here. Stay tuned to see if I have any success!
Hello, and thank's for this excellent video, I'm just getting involve with a ATTINY85 about fuses setup and I wonder I found this video on youtube about AVR Fuses by Mitch Davis, "Bare-Metal MCU #5 - AVRDude and fuses" , does the AVR setup can do the same as an HV fuses setup module. thank's again for your time.
Any standard NPN transistor will do, such as BC337 BC327 *2N2222* 2N2907 2N3904 2N3906 (these are the ones I currently have on order from AliExpress, what a coincidence!). I can only see one capacitor that I probably used for decoupling the power supply so a 10µF will do. You can get a great selection in a small plastic case from AliExpress or Banggood for just a few dollars that will see you right for years!
Hey Ralph, I got my Reset pin to work as gpio thanks to your tutorial, but now I'm having the issue that my Attiny85 is working slower than usual. I have a red, green and blue led that change their respective intensity with an integer that goes back and forth between 0 and 255, resulting in a "fade" pattern that goes through the entire color spectrum. This pattern only takes a few seconds to go through the entire spectrum once but now all of a sudden takes about a minute. This seems like an issue related to my clock speed but I couldn't find a solution for it so far. Any help from you or anyone else is apreciated, thanks in advance.
Sounds as if you have changed the fuses settings so that it divides by 8 now. Check your fuse settings (it displays them when you upload) and compare to what they should be by using this page: www.engbedded.com/fusecalc/
The 4 least significant bits on the Low-Fuse byte are the CKSEL bits which control the clock. On a new ATtiny85 they are set to 0010 giving 8MHz divided by 8 (1MHz) and this is what the HV programmer described here is setting the CKSEL & CKDIV8 fuse bits to. The Arduino IDE has options for setting the clock under the Tools menu. By default this sets the ATtiny85 CKSEL bits to 0001 which is 64MHz divided by 4 (16MHz). So, if you change the Low-Fuse byte from 0x62 to 0xF1 and reprogram the fuses again you will restore the chip's clock and speed to the Arduino IDE default settings. If you just want the HV fuse programmer to set or unset the Reset pin then comment out the code that writes the Low-Fuse byte - because there is no need to change this byte. The CKSEL fuse bits are explained on page 25 & 30 of the ATtiny85 datasheet (see link provided below video).
Thanks for the info! Much appreciated! Did anyone figure out a known resistor value that works for pin 1 and a transistor? I am going to try 1k, but will have to wait for parts.
Hey Willysnowman, good question and easy to answer. If you are driving a simple NPN transistor from a GPIO Pin of any Arduino-style board, then you have 5v available. To turn the transistor on fully, you have to supply sufficient current to the base (you really should refer to the spec sheet for the transistor) but let's say you need 15mA of base current, then at 5 volts you need a resistor of around 300 ohms. A 1k might also work (depends on how much current you need to flow in the transistor down the collector , eg to turn on a relay) but what you want to avoid is the transistor not turning on fully - it will generate more heat if partially on. Start with a 1k and measure the current flow in the base, refer to the spec sheet to ensure that makes the transistor 'saturated', aka fully switched on. This answer glosses over various aspects but it will be enough to get you going.
Hi Ralph. Very nice explanation....but I got a little problem - after make the changes in fuse bits, the Attiny85 started to work slower. When I tried to Blink, the delay time was almost 10x slower ... What could It be?
I suspect you are running the ATTiny85 at its factory default speed of 1Mhz, Filipe. Go to this website www.engbedded.com/fusecalc and select the correct chip and then see if you can decipher what you need to run at 8Mhz using the internal RC oscillator. Be careful, you can make unwanted changes that might brick your device. I used this though, and it all worked as intended. Or, when you program the ATTiny85, just tell the Arduino IDE that you're running at 1Mhz and it will compile accordingly. It's worth uploading the BLINK program with a 1-second delay between blinks to double check your speed fuse settings.
Ralph S Bacon thanks for the answer! I think I found the thing...in the sketch, the Low fuse is defined as 0x62, this is default option that , looking at the engbedded Calc, this value makes the clock be divided by 8 ... So If I modify the LFUSE define from 0x62 to 0xE2 It should work. I think when I burn the bootloader with the 8 MHz option , the LFUSE os setted to 0xE2, and when I upload teh attinyreset It sets back to 0x62...I'll try later...tell me If does It make Sense (Sorry my english!!)
Yes, the default is to divide by 8, but it does depend on what settings you are using in the Arduino IDE. For example, if you specify 8Mhz as the clock speed (in Tools > Settings), but in reality your ATTiny85 is only running at 1Mhz then you will have an eight times slower "Delay" and "Millis" in your code! So what you propose makes good sense - let us know if you have success with this change.
Hey Ralph,,,I tested right now and works! I create another function establishClockContact() and other variant - targetClock, and now I can choose the clock fuse bit :))...very thanks for that!
instagram.com/p/BidCVgqBdlH/ I felt inspired by yours, so I made a board to high voltage programming and normal program via arduino, just sharing :) ... and the sketch with my mods #include "Arduino.h" // AVR High-voltage Serial Programmer // Originally created by Paul Willoughby 03/20/2010 // www.rickety.us slash 2010/03/arduino-avr-high-voltage-serial-programmer/ // Inspired by Jeff Keyzer mightyohm.com // Serial Programming routines from ATtiny25/45/85 datasheet // Desired fuse configuration #define HFUSE 0xDF // Defaults for ATtiny25/45/85 #define LFUSE 0x62 //default - 1MHz operation #define RST 13 // Output to level shifter for !RESET from transistor to Pin 1 #define CLKOUT 12 // Connect to Serial Clock Input (SCI) Pin 2 #define DATAIN 11 // Connect to Serial Data Output (SDO) Pin 7 #define INSTOUT 10 // Connect to Serial Instruction Input (SII) Pin 6 #define DATAOUT 9 // Connect to Serial Data Input (SDI) Pin 5 #define VCC 8 // Connect to VCC Pin 8 // Added by Ralph S Bacon just for enhanced user experience #define GND 5 // GND for buzzer #define PWRLED 6 // Power on LED #define BUZZ 7 // Beeper pin int inData = 0; // incoming serial byte AVR int targetValue = HFUSE; int targetClock = LFUSE; void setup() { // Set up control lines for HV parallel programming pinMode(VCC, OUTPUT); pinMode(RST, OUTPUT); pinMode(DATAOUT, OUTPUT); pinMode(INSTOUT, OUTPUT); pinMode(CLKOUT, OUTPUT); pinMode(DATAIN, OUTPUT); // configured as input when in programming mode // RSB "enhancements" // Sink the Buzzer to ground pinMode(GND, OUTPUT); digitalWrite(GND, LOW); // Turn on power LED pinMode(PWRLED, OUTPUT); // Buzzer / beeper pinMode(BUZZ, OUTPUT); digitalWrite(PWRLED, HIGH); // Let user know we're ready to go digitalWrite(BUZZ, HIGH); delay(50); digitalWrite(BUZZ, LOW); // End of RSB // Initialize output pins as needed digitalWrite(RST, HIGH); // Level shifter is inverting, this shuts off 12V // start serial port at 9600 bps: Serial.begin(9600); } void loop() { switch (establishResetContact()) { case 49: targetValue = HFUSE; break; case 50: targetValue = 0x5F; break; default: targetValue = HFUSE; } switch (establishClockContact()) { case 49: targetClock = LFUSE; break; case 56: targetClock = 0xE2; break; default: targetClock = LFUSE; } Serial.println("Entering programming Mode "); // Initialize pins to enter programming mode pinMode(DATAIN, OUTPUT); //Temporary digitalWrite(DATAOUT, LOW); digitalWrite(INSTOUT, LOW); digitalWrite(DATAIN, LOW); digitalWrite(RST, HIGH); // Level shifter is inverting, this shuts off 12V // Enter High-voltage Serial programming mode digitalWrite(VCC, HIGH); // Apply VCC to start programming process delayMicroseconds(20); digitalWrite(RST, LOW); //Turn on 12v delayMicroseconds(10); pinMode(DATAIN, INPUT); //Release DATAIN delayMicroseconds(300); //Programming mode int hFuse = readFuses(); //Write hfuse if not already the value we want 0xDF (to allow RST on pin 1) if (hFuse != targetValue) { delay(1000); Serial.print("Writing hfuse as ");Serial.println(targetValue, HEX); shiftOut2(DATAOUT, INSTOUT, CLKOUT, MSBFIRST, 0x40, 0x4C); // The default RESET functionality //shiftOut2(DATAOUT, INSTOUT, CLKOUT, MSBFIRST, HFUSE, 0x2C); // this turns the RST pin 1 into a (weak) IO port //shiftOut2(DATAOUT, INSTOUT, CLKOUT, MSBFIRST, 0x5F, 0x2C); // User selected option shiftOut2(DATAOUT, INSTOUT, CLKOUT, MSBFIRST, targetValue, 0x2C); shiftOut2(DATAOUT, INSTOUT, CLKOUT, MSBFIRST, 0x00, 0x74); shiftOut2(DATAOUT, INSTOUT, CLKOUT, MSBFIRST, 0x00, 0x7C); } //Write lfuse delay(1000); Serial.println("Writing lfuse ");Serial.println(targetClock, HEX); shiftOut2(DATAOUT, INSTOUT, CLKOUT, MSBFIRST, 0x40, 0x4C); shiftOut2(DATAOUT, INSTOUT, CLKOUT, MSBFIRST, targetClock, 0x2C); shiftOut2(DATAOUT, INSTOUT, CLKOUT, MSBFIRST, 0x00, 0x64); shiftOut2(DATAOUT, INSTOUT, CLKOUT, MSBFIRST, 0x00, 0x6C); // Confirm new state of play hFuse = readFuses(); digitalWrite(CLKOUT, LOW); digitalWrite(VCC, LOW); digitalWrite(RST, HIGH); //Turn off 12v // Let user know we're done digitalWrite(BUZZ, HIGH); delay(50); digitalWrite(BUZZ, LOW); delay(50); digitalWrite(BUZZ, HIGH); delay(50); digitalWrite(BUZZ, LOW); Serial.println(" Programming complete. Press RESET to run again."); while (1==1){}; } int establishClockContact() { Serial.println("You can choose the 1MHz or 8MHz clock frequency, " "to match the bootloader burned
"); // We must get a 1 or 8 to proceed int reply; do { Serial.println("Enter 1 to 1 MHz"); Serial.println("Enter 8 to 8 MHz
"); while (!Serial.available()) { // Wait for user input } reply = Serial.read(); } while (!(reply == 49 || reply == 56)); return reply; } int establishResetContact() { Serial.println("Turn on the 12 volt power/
You can ENABLE the RST pin (as RST) " "to allow programming or DISABLE it to turn it into a (weak) GPIO pin. "); // We must get a 1 or 2 to proceed int reply; do { Serial.println("Enter 1 to ENABLE the RST pin (back to normal)"); Serial.println("Enter 2 to DISABLE the RST pin (make it a GPIO pin)
"); while (!Serial.available()) { // Wait for user input } reply = Serial.read(); } while (!(reply == 49 || reply == 50)); return reply; } int shiftOut2(uint8_t dataPin, uint8_t dataPin1, uint8_t clockPin, uint8_t bitOrder, byte val, byte val1) { int i; int inBits = 0; //Wait until DATAIN goes high while (!digitalRead(DATAIN)) { // Nothing to do here } //Start bit digitalWrite(DATAOUT, LOW); digitalWrite(INSTOUT, LOW); digitalWrite(clockPin, HIGH); digitalWrite(clockPin, LOW); for (i = 0; i < 8; i++) { if (bitOrder == LSBFIRST) { digitalWrite(dataPin, !!(val & (1
EDIT: I pulled out another ATTiny85 and its working with no issues. So, apparently there are no problems with my circuit or sketch. Though, what is happening, as described below, is still strange. Did I really 'brick' my chip? (The code I put in does function, I just can't update it with anything since I can't change even read the fuses) Do I just need to do an erase? (I know I didn't set the lock bits) I'll investigate more. Cheers! -------------------------------------- Hi Ralph, I really tried to get this working, but i'm hitting a wall... Hoping you, or another viewer, can help! :-) I built the circuit per the schematic on your GitHub, with the following changes: Using a Pro-Mini rather than an UNO - same pin numbering For the 12V source, I'm using a MAX662 rather than a battery. removed switch, 12V LED and protection diode Removed Buzzer I did use a 10uF, as per the schematic, for VCC2. (I understand you used 0.22uf) The only changes I made to your code was removing any references to BUZZ, and removing the GND2. (As the GND2 seems to be only for improving the buzzer & Other many other schematics appear identical to yours, but use a single common ground.) With a bunch of detective work, I've traced the problem to the first shiftOut2 command: // Returns the value of the HFUSE int readFuses() { Serial.println("Reading fuses"); //Read lfuse shiftOut2(DATAOUT, INSTOUT, CLKOUT, MSBFIRST, 0x04, 0x4C); pause(); // Function i added to wait for user action. *** ... The "Reading Fuses" displays properly, but it never reaches the pause(); - It just hangs (The pause function does work - it was used several times to get to this point) Presumably, the code should work regardless if there is an ATTiny inserted or not, yes? (The code gets to the same point regardless) I've run through all the pins with a hardware check program that activates only one pin at a time, on an empty socket, to confirm proper operation, check for shorts, etc. The MAX 662 can only supply up to 30mA, but the line isn't being pulled down, so I assume it isn't using much current. I haven't been able to find much documentation on the shiftOut2 command. almost all references I can find relate to HVSP code. I've been banging my head for a couple of days on this! Any Ideas??? My only idea remaining is to remove/change out the cap on the VCC2 line ** EDIT ** While writing this, I had the program sitting in the background. after MANY minutes, the code did reach the pause() function. I've entered a value to get it to continue. From what I have seen on your video, and others, this should take less than a second. All the other commands seem to operate with the expected timing - ie, really fast. (my pro-mini is a 5 V 16MHz & has been working fine with previous projects and everything else in this one) ... Now that I have writing the above, I have a lfuse reading E0. (was expecting E2, but whatever, at least its a reading) Waiting now to see if a hfuse value gets read. It has been several more minutes since I got the lfuse reading. been about 10 minutes, nothing yet, but will let it continue running.
It sounds as if the Tiny85 with which you're having issues is that it is running very slowly - but really slowly, not just 1MHz instead of 8MHz. At the end of the day, if that chip is causing so many issues just continue with the other one, it's not worth spending hours sorting out a $1 chip.
sir, as im new to arduino(Beginner) this problem arise when i wanted to program ATtiny85, when i connected all pins to uno and upload sketch, error it saying select correct board from board manager. even i selected crct board and port, i googled about this problem and found that my ATtiny85 is bricked,finally i found a page and link to this video, and i collected all components but i didn't understand that how do i upload the code? im having few questions, should i use "arduino as ISP" ? or should i select ATtiny85 from board manager? and which clock speed should i use? help... thanks in advance.
Have a look at video #82 which describes in some detail using the ATTiny85, ARGS. If that doesn't answer your query let me know and I'll dig further for you. As it happens I will be demoing some very small ATTiny85 adapter boards in a future video which have a micro USB port but that won't help you right now but may interest you in the future. Good luck!
Ralph S Bacon i understood the concept of programming ATtiny85 using arduino uno as ISP but inorder to set the correct fuses by using arduino uno, we nee to program arduino as ISP then select the board ATtiny85 frm board manager and upload the fuse resetter sketch, am i right. am i on the right track? even i created the board which ur using for resetting fuses or for extra gpio pin. correct me if am wrong. thank you for replying on my comment.
I think that pretty much sums it up, Args, just be sure to follow the video step-by-step and look at the video description for more resources that I may have included.
Thank you Ralph, for all the good videos. And now for ARGS. Using Arduino IDE upload the sketch to the UNO board. Keep in mind, the sketch is for UNO and not for attiny. When you upload the sketch do not use Arduino as ISP. Select the simple AVRISP mkII or AVR ISP as programmer and Arduino/Genuino UNO for the board. After programming the UNO board with the sketch go to Tools and click on Serial Monitor. Check to see if you have 9600baud in the right corner of your Serial Monitor window. Connect the High Voltage programmer board in to the UNO board an you should see in Serial Monitor window a message like this: " Turn on the 12 volt power/ You can ENABLE the RST pin (as RST) to allow programming or DISABLE it to turn it into a (weak) GPIO pin. Enter 1 to ENABLE the RST pin (back to normal) Enter 2 to DISABLE the RST pin (make it a GPIO pin) "
Hi Ralph, Love your videos - always well produced without waffle. Did you show the diagram for your modified circuit anywhere? I can't seem to find it. Keep up the good videos!
I can't remember what I did with the modified circuit, kintara58, as I'm a few thousand miles away from my workshop it will have to wait until I return. Give me a nudge if you don't hear anything in a couple of weeks!
Not to worry. After careful examination of the video footage and the Arduino IDE script I think I have worked out the circuit. The only thing I’m having an educated guess at is the addition of a reverse polarity protection diode on the 12v line and a smoothing capacitor (10uF?) between 5v and ground. Next step is to make it up and maybe etch a PCB. Thanks for all your video tutorials - I find them very useful and easy to follow.
Dumb question because I'm too lazy to research it: Can this pin be used as a digital input instead of a "weak" output, or is it only GPIO in terms of RST in, and "Weak" out and no other options?
@@RalphBacon - Thanks for the reply. I required 4 digital inputs (to read a binary switch), one digital output used as an interrupt to a peripheral processor and one analog input. I used the reset pin for the analog input after first debugging the program using an UNO and then loading it in the normal way to the Attiny. After the load, I then used your Fuse bit board to make use of the reset pin as an analog input. Works....
Well, Omo, I've discovered that there are several, very similar circuits just like the Fuse Doctor one (which I searched on Google for) so I suppose it is similar to that, although the source of my (somewhat upgraded) circuit board is, I believe, mentioned in the video or the video description. But the gist of them all is that you apply a 12v pulse to the correct pin at the right time and voila! You have a reset fuse. My home grown version works very well although you can get kits (or ready-made versions) of similar items off the Internet if your soldering skills are not up to the job. I hope this helps.
Great video again Ralph. Thank you for your research on expanding the ATTiny85. With your permission, for anyone needing the AttinyShield programmer: - The DIY version of AttinyShield can be found here: www.ebay.com/itm/221434907666 - The fully soldered version of AttinyShield can be found here: www.ebay.com/itm/221324819158 Also I would happily accept the challenge of making this pcb probgrammer but because of your videos I have a lot of AttinyShield's to make, since with every video i have new orders of the Shield :) Also did you receive the gift board of AttinyShield I have sent you? Waiting for your next video my friend. Themis
Amisail3 How about a shield for both high and low voltage programming? I recently bought your programming shield, works well. Used it on my latest project.
Thank you Steve I am grlad you've found it usefull. I guess the problem for a mixed shield would be the size. It should cover more pins and have more componets on it. Also not everybody needs both functions. The soft programming that my AttinyShield does is enough for many projects with 2-3 inputs-outputs. Ralph showed us that if we need more then it is possible... but a shield... In any case Steve it was nice bringing it up. Themis
Hey Themis, great to hear that business is booming! Yes, I just got your replacement shield, thank you so much, I shall construct it soon (and not modify it this time). I guess there is not enough demand for a PCB for a HV programmer; at least I have shown that it is easy to construct on strip board! I wish you continued success and enjoy the videos. NIce to hear from you.
@Amisail3. I recently received your ATtiny85 shield and very promptly to. It completely simplifies the programming of, and the development of firmware for, these devices. Thank you so much.
Calm down, Kenn, no need for such stress! The program in a microcontroller is called a 'sketch' in the Arduino world. And a bit flag is called a 'fuse'. It's to ensure no-one that is not in the Arduino club has any idea of what we're all talking about.
@@RalphBacon I think it is absouletly asinine to create a new set of jargon for something that is virtually identical. But why stop there? For the uC world we can have: Zebra - Switch statement Alberta - If statement Potato - Do loop SameSame - assignment Relation - a function (Math joke)
Well, unlike your examples, using a different set of terms does confine what we are talking about to the Arduino world! That said, can we use a Zebra within a Potato, or is it best to stick with a simple Alberta? (Now my brain hurts).
Thats how languages evolved, words meaning change with time, like the F word for example fuse meant to melt metal, then it got used to mean an electrical component that protect electrical hardwares but basicaly it was made from metal that fuse at cetrain current the intended meaning of fuse is no different from the electrical one instead this bit is meant to protect your code running on uC, but at a certain voltage, the "fuse" blow up and reset everything
@@zazugee Seems to me you have a basic MIS understanding of micro-controller fuses. Which is not surprising given the terrible mis-use of the term. As in any design process, let’s say graphics design. There are some settings are being tuned at the beginning of the design project such as dimensions, dpi, background, colors, etc. These setting are said to be “The configurations” of the project which will not be changed till the end ideally. Similarly, in embedded software design, there are also some configurations for each MCU used in the whole project. Such as the type of oscillator internal/external, whether you’ll use a watchdog timer or not, whether there’ll be a reset pin or not, and so. These configurations are controlled via a dedicated specific register in the ROM, In our MCU it’s called “CONFIG_WORD”. Every single bit in this register controls a specific feature, combined together in this register to control all the settings (configurations), Hence they are often called the “Configuration Bits”. Some books in the embedded literature call these bits as “Fuses”. All in all, these names stand for the same thing. deepbluembedded.com/configuration-bits-fuses-for-microcontrollers/
Ralph, this is great stuff. One of my current projects is using six gpio pins on a Nano. I want to use an ATtiny85 and now thank to this video I think I can. Will save a lot of space on the board. Yours is by far the best explination of how it's done. Good instructions/schematics on the 12V board too.
Also have to get a 128x32 ssd1306 OLED working on i2c, so hopefully can figure that out and I should be good to go. I have a few leads but if you have and inspiring tips then I'm all ears.
Huge thanks as always for your great videos.
If you're looking to get the SSD1306 running on I2C on the Tiny85, I did a video on how to get the I2C running (using a different LCD screen) which may help.
Video #82 ruclips.net/video/5bnXeHz06Ck/видео.html
@@RalphBacon cheers Ralph. Will give that a bash.
Of course if you really need more gpio there is always the ATtiny84 with its 14 pins. ;)
Indeed you could Nick. If you see my response to 2000jago you'll note that I mention there are several choices and whatever is right (for whatever reason - size, cost, power, features, I-got-one-in the-toolbox) then it's the right one for you! Nice to hear from you again.
Hello Ralph , I found out from Atmel ATTINY85 datasheet page 148 note 2. After this fuse has been programmed device can be programmed via high-voltage serial mode, only, so the best way to alternate is to use an HV fuse setter.
If you watch my video #144 you will see the Fuse Resetter PCB that I made specifically for this purpose. Works well.
Not ever used this chip, Ralph! Must have a delve at some point! Thanks for this video, have a nice Bank Hol weekend!
Thanks John, looks like the current UK heatwave will peter out just in time for Bank Holiday Monday! Gosh! We didn't see that one coming!
I do think that Arduinites should at least be aware of this Tiny85 chip (or, as Nich B points out, its family) and perhaps just get on and experiment a bit. Whether you'd then ever use it in a project is a different question altogether! Good to hear from you.
Unreal weather at the moment, eh! And yes, Arduinites should be aware of this littel beauty. Also, may I add, I really do find your approach to videos quite refershing, and am enjoying watching them (hence the comments in random ones from the past!!!) :)
My 'video office' at the moment is 30C degrees - far too hot for any Arduino work really (but here I am...). Thank you so much for your kind words about my videos, they (your words) are most appreciated! Now, where's my ice cold beer...
You're very welcome, I hope your subscriber numbers rocket soon, i am sure they will. Yep, I know exactly what you mean... but me too, I am here in my little spare bedroom amongst Mac's, Dell laptop turned on for 1st time in 12yrs - and it works (Linux install coming up), Arduinos, ESP32 research, and of course... a nice cold glass of wine... (OK, bottle!!) :) It's Friday after all.
PS Ralph: Do you have a twitter account?
Great information and well presented Ralph.
With regards to the 12V programming voltage you may be able to use a MOSFET to control the supply using one of those extra ports you have available.
I think this programmer could also be built on a prototype shield board.
You mean control the 12v supply via a logic-level MOSFET thus dispensing with the slider switch? Yes, indeed, that would be an alternative approach. And I'm sure you're right about building this on a prototype board, it could be a very neat job!
You can NOT use a MosFet. You could use a LOGIC GATE MosFet. The most common ones are in a TO-220 package which takes up space. Plus you have ESD headaches. TUNs are cheap and easy to get.
They are called "fuses" because originally, this sort of setting was literally a fuse - a bit of the IC that was permanently opened up with a relatively high current pulse. Now that's a way to permanently make it impossible to read the code back off a microcontroller. Now it is a resettable device, although the security now is that resetting certain fuses also erases the program memory.
Interesting. And some fuses are still "burn once" on some chips so we do have to be aware (and beware) of what we're doing.
Now that you can get LGT8F328P boards for about a pound each if you buy 20 at a time on AliExpress, I wonder if there's much point in using an ATTiny85 except maybe if it saves power in a battery-operated project? Of course there's also the sense of pride and accomplishment.
Your last sentence struck a chord with me, Sean.
Imagine (it's easy if you try) that all cars were the same price, from Rolls Royce to Smart For Fours. Would we all be driving Bugatti Veyrons?
Some, certainly. But the thrill of getting some old "classic" car restored, and running reliably is a real challenge, a labour of love. Whilst I do not restore old cars, using a low power and smaller microcontrollers is always a challenge to the maker! And, as you say, the sense of accomplishment that you have really honed that code gives a sense of pride too.
That said, I tend to use ATMega328-based boards for most of my projects (so, Nano, Pro Mini, even the relatively large UNO) but now and again I'll use a Tiny85, Tiny13, ESPXXXX and now that a viewer has pointed me to a new bootloader for the STM32 (yet to be verified) that one too!
Great video as ever. What do you do if you don't want to watch any more Christmas movies on TV and the weather looks like rain? - you finally get round to building a HV programmer to unbrick that MCU.
I made a slight product variant - used strip board to hook in Uno 5v so as to feed a small boost convertor to generate the 12v. I also put a jumper in place just in case I ever come across a bricked ATtiny15 and want to route SCI to correct pin.
I padded out your code to handle Reset Disable for a range of MCU and added a fuse reset to make this more generally applicable to bricked MCUs.
It seems to work, I can read, change and re-read fuse settings to confirm the changes made.
I bricked an ATtiny13A in my early days by setting the clock speed to 128kHz and also adjusting the System Clock Prescaler until it was too slow to talk to using my ISP (I was trying to save power OK).
I'd like to unbrick this device (just to know I can) in place of throwing all 50p worth of it in the bin.
I see I am successful in setting fuse defaults back to Low: 0x6A, High: 0xFF but I can't seem to enter programming mode using an ISP (Studio 7 via a Pololu ISP in this case as it has a rocking GUI fuse editor).
Would you have any hunches what also might be wrong (other than it's U/S and lacking the magic blue smoke)?
Best regards
Happy New Year
Peter
It looks like you've made some interesting improvements to my original design, very cool 👍
Regarding getting the ATtiny13 reprogrammed, you'll only be able to do this using SPI initially, unless you've loaded a bootloader of some kind and are using a hacky way to get it into the right state. Adafruit describe this for other processors, but admit it's unreliable.
Also the correct oscillator must be used, to whatever you've set via the fuses.
@@RalphBacon Thanks for all your encouragement. I managed to unbrick it in the end. I remembered I'd bricked it by selecting internal 128kHz oscillator AND then compounded my issue by being bold with the System Clock Prescaler.
I am using a Pololu USB AVR Programmer (emulates STK500 to Studio7) and I am able to control the ISP frequency through the Studio 7 fuse blowing GUI.
So, using the HV Programmer, I modified the LFUSE value for ATtiny13A to 0x7A (no CKDIV8) and set the ISP frequency to as low as it would go (1.747kHz) and success! I did some more testing with the ISP frequency and the fastest I can successfully run this at is 7.008kHz - wow that MCU clock must be slow!)
BTW - do you know where you can source genuine ATtiny402 devices? I got a few from eBay, mounted them up so I could play with them, built a UPDI programmer and found out that they had incorrect device IDs - I hacked my way round that only to find out I could not control two of the GIO pins - further reading indicates that batches of these also have corrupt pin multiplex tables in the silicone. Dr Azzy suggests not sourcing from eBay / AliExpress (I'd agree). Main suppliers advertise a next production run in Aug next year (2023). I only want a handful and spending 10 times the value of the shipment on postage sticks in my throat.
Keep up the good work.
Cool stuff thanks a bunch Ralph , keep smiling :-)
Very kind of you say so, Lance, thanks for posting. (Still smiling) :)
I remember the thousands of PROMS, EPROMS and EEPROMS we burned at Boeing during the late 70's and 80's. Then we started in on PLA's for even denser circuits. At least the EPROMS and EEPROMS were reusable
But surely the ones you mention (in my Grandad's time, I believe, cough, cough) only had about 100 bytes capacity? Probably 4-bit devices too, or were things more advanced than that? You'll be telling me that you had running water too, no doubt. Just kidding, Raymond, I remember mainframe 'hard disks' consisting of many platters and giving us a whopping 16Mb (that Mb not Gb) in the early eighties (as my Grandad told me as I sat on his knee).
Mr Bacon:
Thank you for all the wonderful videos. Recently I used the video on using all 6 pins on an ATTiny85. Very informative and helpful to a project I currently have on my table. BUT it left with with a question I can not find a simple answer to. Consequently I am asking you if you don't mind. How can I configure the reset pin PB5 to an ADC input. Which brings up another thought. Would you consider a video on pin reassignment for the ATTiny85 or ATTiny's in general. Thank you very much for everything.
Hello Mr Zubli, thank you for your kinds words. If you have reset the fuse (as described in this video) for physical pin 1 to turn it into GPIO digital pin 5, you could try and do an AnalogRead on A4 (I'm guessing this is the next analog channel available). If it doesn't work it may just be that they never included the circuitry for ADC on physical pin 1/GPIO 5 as it is normally used as the RESET pin anyway. Do let us know how you get on though!
Actually, I still have a question: it also works on attiny13a?
I don't think I ever used on the ATTiny13A, you had best check whether the RESET pin can be turned back into a RST pin when you want!
I'm going to use this trick to make my 8x8 dot matrix led which requires 2 sets of 74xx595 IC.
I already soldered ATTiny85 and 74xx595 onto the PCB and I just found out pin5 is not usable until reset is disabled.
You mentioned it's weak I/O pin. Does it have enough current to make 74xx595 clock pin work?
It _might_ work with its weak output - or else wire it to a transistor to boost the signal. Make sure you test your design on a breadboard first!
@@RalphBacon Thank you for your advice.
I have more questions. What is Zener Diode model number you put in your circuit? How many voltage and how many watt?
and what value of that capacitor?
Are you talking about the fuse resetter circuit, or something else? No Zener in the former, hence my query.
@@RalphBacon At 21:17, there is one component next to the capacitor. It sits between 12v rail and resistor that goes into the collector of the BC547 transistor.
It looks like Zener Diode. That's why I'm confused.
Good day sir, I love your videos.I even made a humidifier of such with auto filling of water. Well on with my question. (sorry for the long question) I made this project but im having a problem. Im using a 12v 1.5A power pack and im getting intermingling fuse changing. This is what is happening. I programmed the attiny85 to blink PB0 to PB5 one at a time. As it should it only flashes PB0 to PB4. I run the code, it shows the default values but will not set the new value constantly. Im wondering via a scope what voltage everyone is getting on pin 1 while it is writing. Im getting 10v ± .5. Thank you for your time in advance.
Hey Havid, what a question! Remember that unless you have changed the 'fuse' setting to allow physical pin 1 to act as a GPIO pin then it is only used as a reset pin. Be aware (or perhaps, beware) that if you do change that fuse setting (all described in this video) to allow Pin 1 to act as a GPIO pin, then you must reset that fuse again using a special 12v resetter (see my video) to allow the board to be reset to allow uploading of code - otherwise your ATTiny85 will become 'bricked', no longer able to be programmed. All is explained in the video, so watch very carefully! All clear?
VERY GOOD THANKS
i was looking at this maybe i can use a shift reg to add extra out put pins
do you have any code for this, i want to make a simple security system that just has blinking lights on each window to make it look like the window has some sensor on it. i did this before using a 4017 and 556 timer
You can cascade several PCF8574 pin extenders on I2C (which the ATTiny85 can bit-bang). See my video #49. Also my video on ATTiny85 and I2C video #82.
Happy New Year from downunder.....new to this fuse setting
I have a program where it is required to set fuses at certain values, Low-E2, High-DF and Extended-FF.
Going by your video here, this is possible to do at any time, either before or after uploading the sketch. Correct..?
Your program though is only meant for resetting the reset to an I/O and back again.....??
Happy New Year Jorgo! Fuse settings? You can only set the fuses as part of a bootloader / sketch upload; in other words, you can't do this programmatically when the sketch is running.
You can change the fuses by editing the boards.txt file (found in C:\Program Files (x86)\Arduino\hardware\arduino\avr\boards.txt although your modified versions can also appear here: Arduino Sketches\hardware\breadboard\avr\boards.txt) and then using that board definition.
You have to be careful here. Setting the wrong fuse could brick your Arduino, so use this fuse calculator and always double check the settings - and never "try things out to see what happens" (don't ask me why I know this):
www.engbedded.com/fusecalc
The video here shows how to use all six pins for GPIO (including the RST pin) but you have to use my fuse resetter to get the RST pin back to its default state so you can upload a new sketch. Take care!
@@RalphBacon Don't want to change the fuse settings when running the sketch. Sketch I have here calls for the settings Low = E2, High = DF and Extended =FF.
Intention is to do this using a HV programmer. I watched your video where you changed the reset pin to an output and back again via a hv programmer and showed how it worked with the flashing LED. It appears the sketch itself remained intact in the Attiny at that time. So my query was, does it make any difference if I use a hv programmer to change the fuses before or after uploading the sketch that will be run on the Attiny ?
Your code I believe only changes pin 1 to an I/O and back to a reset...???
Just thinking...I should be able to use a usbasp programmer to set the fuse I require...yes..?
Added a ten pin plug to an 8 pin ic clamp to suit usbasp programmer and using a couple of different software (Avrdudess and eXtreme burner...had to change the driver to libUsb in zadig) changed the fuse settings to what was required. Did similar to yourself in that I changed over to one setting in one software and back again in the other.
Then loaded the sketch to the ATtiny85 using the usbasp programmer in Arduino IDE.....Yet to test outcome but no errors so far. ...Cheers Jorgo
You will only need a High Voltage (12 volts) if you want to change the RST pin back to a standard GPIO pin. All the other fuse settings can be set just by writing the values to them, in the way you seem to be doing already.
When using the HV resetter (for the RST pin) the fuse setting is changed but the sketch remains intact. When changing the other fuses without using an HV programmer the sketch is also kept intact.
It seems you are good to go, Jorgo!
@@RalphBacon Thankyou...looking forward to your videos this year...cheers
Hi Ralph. Love your videos mate!
How have you got that LED hooked up to the HV line into the ATtiny85 pin5 Ralph? Won't that cause a voltage drop of a few volts along with the 1K resistor...? What is the minimum Voltage Pin5 Needs to See in order to ReSet the fuse? Thanks.
If you are referring to the LED2 that shows the power is on from the 12v battery and goes to pin 1 of the ATTiny85 - this is the RST pin and requires that pulse to reset the fuse internally. To reset the RST pin from GPIO back to RST you need 12v. Take a look at the circuit diagram in video #144 (ruclips.net/video/bTTdvcnAOgg/видео.html ). The PCB and circuit diagram are in the GitHub and are for EasyEDA.
@@RalphBacon Awesome yes, Got it. Thank you Ralph.
I'm still not having any luck here. when I run the fuse reset it always reads ALL fuses as FF.... What do you suppose that could mean? Which pin is responsible for getting the hex value of the fuses?
I've checked and rechecked my connections many times, but to no avail. I'm going to try the same schematic using a Nano.
Many thanks to sir, I love your vids and I love Benny's input. I was sad to hear of his passing.
@@RalphBacon Hi Again Ralph. I found that it was because the 12v battery (in name only) was below 10v - so that meant it would enter high voltage programming mode. I've done some re wiring of the circuit and put in a 9V Battery/Boost converter controlled by a Photo Voltaic Mosfet Driver (PVI5080 - Love those things!) which I get the Arduino to power up and power down at the end of the program. I'm now making the dedicated board. Just one question, At the start of the program, in the serial monitor the first line reads "NTurn on the 12 volt power." I can't find where this annoying Capital N is coming from... Do you have any ideas Ralph? Other than that, it's all working brilliantly. Thanks again, for you help, vids and general coolness. Cheers.
I was looking at the high voltage programming site, just two days ago, and why? It was to see how one changes the functionality of P5 on the ATTiny. Its spooky how often that happens with your videos. Your presentation helped my understanding considerably, thank you.
I do have to voice (or is that publish?) one small concern: The timing of Benny's interventions seem so uncannily perfect that a more suspicious soul might be forgiven for thinking that a boot poised above that wonderful pet's tail might be the cause.
Michael, how can you even suggest that Benny is not treated with absolute love and care? He is known as BCE - Best Cat Ever, and that's because he is. I could no more poise my boot above his tail than I could pull out my own teeth with a rusty pair of pliers. The very thought....
But, that said, Benny is most pleased that his video appeared at a serendipitous time and we both hope it will help you in your investigations. My stripboard module works *very well*, is self contained (so I don't have to scrabble about hunting for cables or batteries or whatever) and I have even dedicated a £2.42 Uno to the project so the code is always loaded. Cheap as chips, really.
Anyway, I'm not sure I can forgive you (yet) for your insinuations about my treatment of poor Benny. Hmph.
Well!! Thats me told!
Keep 'em coming Ralph. I have seen from other comments that I am not the only subscriber who finds the day a little more brighter for seeing a new video of yours in his/her youTube home page.
Ha ha! Yes, consider yourself told (off). But seriously, I do appreciated your support and it's very motivating to hear that my (Benny's) videos are appreciated so much. Thanks for posting, you're forgiven. Benny says he never took umbrage anyway. See what I mean about him being the BCE?
Another great one! Thanks!
Thanks Robert - but would you ever use a Tiny85 or stick with the 'traditional' Uno/Nano? And, more importantly, the reason?
The reason would be power consumption and possibly size. Dawid Watts did a video on how to switch an ESP8266 on and off with an ATTiny85 controlled MOSFET. He was able to extend the battery life to the point were he decided to end the project (or put it on hold). ;-)
Another reason for choosing an ATTiny85 is price. These micros are cheap. I also like to think of it this way: If you have enough IO-pins on an ATTiny85 and the performance and memory are ok, why use anything else? Assuming of course that the alternative is an ATMega328P or similar.
Oh, and I forgot to answer the first question. Yes, I have several ATTiny85s and ATTiny2313 and ATMega328P among other Atmel micros. However, I don't use them (yet). I put one of them on a breadboard from time to time, write some code and program it. I really need a reason to use any of my Nanos/Unos or other DIP package I have lying around. :) The demand for microcontroller-controlled gadgets are low at the moment.
Thanks for the reply, Robert, it's interesting that your replies seem to reflect the general mood regarding the Tiny85. Power, size, good enough and so on. Well, if nothing else my videos on this device will have raised awareness!
Great video again Ralph! Does anyone know where I can buy a pre-made fuse resetter by any chance? I tried searching on ebay but I might have used the wrong terms(?) Cheers!
I found this one (UK site):
www.ecrater.co.uk/p/25674542/usbasp-usbisp-avr-programmer-usb?gps=1&gclid=CjwKCAjwt5DXBRAtEiwAa3vyEhsK-bMlOC4PwiLkMW09NtHvcz5Vxj-rJ1awjTS_1ywL7b84MuAMUxoCTvcQAvD_BwE
But you're on your own to determine how to use it and whether it will do what you want, I'm afraid, Mikael! I searched for ATTiny85 Programmer. But making one takes about 1 hour, does what it should, and costs very little. Always assuming you can solder OK, of course. Perhaps others will suggest other items...
Thank you for the link Ralph. I have one of those around. Is it able to de-brick an attiny85 that I can not communicate with as well? I mean the "Yikes!" error message. I bricked mine using the wrong clock I think. Or do I need to construct one of these 12v boards in order to get it working again?
Ok so I built one of these reset boards and it works! However, the readings that come back after writing the fuses are a little odd. Another strange thing is that the chip seems to totally reset. If I have set the clock to 8Mhz and programmed it it will switch back to 1MHz (noticed by slower blink). Is that to be expected with this method? This is the output I'm getting when using your sketch: pastebin.com/1rDePKBY
Let's put it this way, MIkael: the fuse-setter that I built ONLY set the RST pin 1 back to a reset pin (rather than a GPIO pin). That's it. It didn't change anything else because it wasn't setting any fuses, it was just applying that 12v pulse at the appropriate time. I'm guessing you're doing more than this, hence the whole chip resetting (but I'm guessing). You should be able to set the speed back to 8Mhz just by programming the board again with the required settings (and perhaps a few fuse settings that you might now have inadvertently changed).
The thing is that I was only using this sketch but still saw that behavior. I figured it out though. My default settings in the Arduino IDE was 8Mhz internal, rather than the 1Mhz (which seems to be factory default). The difference there seems to be the low fuse which is 62 at 1Mhz and E2 at 8Mhz. The setting in the fusecalc is called "Divide clock by 8 internally; [CKDIV8=0]". So what I gather is that if I want to run the A85 at 8Mhz I need to set the default low fuse to E2 rather than 62.
Just curious if you are able to recode to have a 3rd PWM
You could bit-bang a further PWM pin I imagine, Nicholas, but it would not be hardware-based and therefore not independent from the rest of the sketch. MIght work, might not depending on what else you are doing in your sketch. You could not have a single "delay" statement in the entire sketch.
Hi I've enjoyed your videos. i have an issue with an attiny 85 board. i have the one you have shown from allexpress, and it works pretty good, however i also have another board that i can't get the IDE to recognize. i was wondering if you've seen this board or now how i can use it. I would like to use it because it comes with usb and a socket to switch out the tiny85 if needed. this is the board.
Er, which is the board, Spencer? I think the link disappeared. However, I have a new, very small ATTiny85 board, with USB connector that I want to try out when I have a few nano-seconds spare in my life, maybe they are the same. Send me a link to the webpage you bought it and I will compare.
Oh, I see you posted the link separately, that's fine, I'll check it out. In fact, I just did and it looks JUST like the one I have here. Stay tuned to see if I have any success!
Where do I go to find "ATTiny_reset.ino"?
Edit: Found it. It's on the git linked in the description.
All my code is always in my GitHub, glad you found it.
Hello, and thank's for this excellent video, I'm just getting involve with a ATTINY85 about fuses setup and I wonder I found this video on youtube about AVR Fuses by Mitch Davis, "Bare-Metal MCU #5 - AVRDude and fuses" , does the AVR setup can do the same as an HV fuses setup module. thank's again for your time.
If you watch my video #144 you will see the Fuse Resetter PCB that I made specifically for this purpose. Works well.
Which Kind of Transistor and capacitors You User.
Any standard NPN transistor will do, such as BC337 BC327 *2N2222* 2N2907 2N3904 2N3906 (these are the ones I currently have on order from AliExpress, what a coincidence!). I can only see one capacitor that I probably used for decoupling the power supply so a 10µF will do. You can get a great selection in a small plastic case from AliExpress or Banggood for just a few dollars that will see you right for years!
Thanks a lot!
Hey Ralph, I got my Reset pin to work as gpio thanks to your tutorial, but now I'm having the issue that my Attiny85 is working slower than usual. I have a red, green and blue led that change their respective intensity with an integer that goes back and forth between 0 and 255, resulting in a "fade" pattern that goes through the entire color spectrum. This pattern only takes a few seconds to go through the entire spectrum once but now all of a sudden takes about a minute. This seems like an issue related to my clock speed but I couldn't find a solution for it so far. Any help from you or anyone else is apreciated, thanks in advance.
Sounds as if you have changed the fuses settings so that it divides by 8 now. Check your fuse settings (it displays them when you upload) and compare to what they should be by using this page: www.engbedded.com/fusecalc/
The 4 least significant bits on the Low-Fuse byte are the CKSEL bits which control the clock. On a new ATtiny85 they are set to 0010 giving 8MHz divided by 8 (1MHz) and this is what the HV programmer described here is setting the CKSEL & CKDIV8 fuse bits to. The Arduino IDE has options for setting the clock under the Tools menu. By default this sets the ATtiny85 CKSEL bits to 0001 which is 64MHz divided by 4 (16MHz). So, if you change the Low-Fuse byte from 0x62 to 0xF1 and reprogram the fuses again you will restore the chip's clock and speed to the Arduino IDE default settings. If you just want the HV fuse programmer to set or unset the Reset pin then comment out the code that writes the Low-Fuse byte - because there is no need to change this byte. The CKSEL fuse bits are explained on page 25 & 30 of the ATtiny85 datasheet (see link provided below video).
Thanks for the info! Much appreciated! Did anyone figure out a known resistor value that works for pin 1 and a transistor? I am going to try 1k, but will have to wait for parts.
BTW: I am using a digispark clone for testing. I think I may like your setup better.
Hey Willysnowman, good question and easy to answer.
If you are driving a simple NPN transistor from a GPIO Pin of any Arduino-style board, then you have 5v available. To turn the transistor on fully, you have to supply sufficient current to the base (you really should refer to the spec sheet for the transistor) but let's say you need 15mA of base current, then at 5 volts you need a resistor of around 300 ohms. A 1k might also work (depends on how much current you need to flow in the transistor down the collector , eg to turn on a relay) but what you want to avoid is the transistor not turning on fully - it will generate more heat if partially on. Start with a 1k and measure the current flow in the base, refer to the spec sheet to ensure that makes the transistor 'saturated', aka fully switched on. This answer glosses over various aspects but it will be enough to get you going.
Thanks Ralph! My ebay digispark seems to provide 3V on high. I may move towards your setup as I am getting tired of playing with these.
Hi were can I get a copy of eclipse your using
Sure thing, you can find it here, v4.2 at the time of writing: eclipse.baeyens.it/ Have fun!
Ralph S Bacon thanks for the link ill have a look at it tomorrow love ya videos
Hi Ralph. Very nice explanation....but I got a little problem - after make the changes in fuse bits, the Attiny85 started to work slower. When I tried to Blink, the delay time was almost 10x slower ... What could It be?
I suspect you are running the ATTiny85 at its factory default speed of 1Mhz, Filipe.
Go to this website www.engbedded.com/fusecalc and select the correct chip and then see if you can decipher what you need to run at 8Mhz using the internal RC oscillator.
Be careful, you can make unwanted changes that might brick your device. I used this though, and it all worked as intended. Or, when you program the ATTiny85, just tell the Arduino IDE that you're running at 1Mhz and it will compile accordingly.
It's worth uploading the BLINK program with a 1-second delay between blinks to double check your speed fuse settings.
Ralph S Bacon thanks for the answer! I think I found the thing...in the sketch, the Low fuse is defined as 0x62, this is default option that , looking at the engbedded Calc, this value makes the clock be divided by 8 ... So If I modify the LFUSE define from 0x62 to 0xE2 It should work. I think when I burn the bootloader with the 8 MHz option , the LFUSE os setted to 0xE2, and when I upload teh attinyreset It sets back to 0x62...I'll try later...tell me If does It make Sense (Sorry my english!!)
Yes, the default is to divide by 8, but it does depend on what settings you are using in the Arduino IDE. For example, if you specify 8Mhz as the clock speed (in Tools > Settings), but in reality your ATTiny85 is only running at 1Mhz then you will have an eight times slower "Delay" and "Millis" in your code! So what you propose makes good sense - let us know if you have success with this change.
Hey Ralph,,,I tested right now and works! I create another function establishClockContact() and other variant - targetClock, and now I can choose the clock fuse bit :))...very thanks for that!
instagram.com/p/BidCVgqBdlH/
I felt inspired by yours, so I made a board to high voltage programming and normal program via arduino, just sharing :) ...
and the sketch with my mods
#include "Arduino.h"
// AVR High-voltage Serial Programmer
// Originally created by Paul Willoughby 03/20/2010
// www.rickety.us slash 2010/03/arduino-avr-high-voltage-serial-programmer/
// Inspired by Jeff Keyzer mightyohm.com
// Serial Programming routines from ATtiny25/45/85 datasheet
// Desired fuse configuration
#define HFUSE 0xDF // Defaults for ATtiny25/45/85
#define LFUSE 0x62 //default - 1MHz operation
#define RST 13 // Output to level shifter for !RESET from transistor to Pin 1
#define CLKOUT 12 // Connect to Serial Clock Input (SCI) Pin 2
#define DATAIN 11 // Connect to Serial Data Output (SDO) Pin 7
#define INSTOUT 10 // Connect to Serial Instruction Input (SII) Pin 6
#define DATAOUT 9 // Connect to Serial Data Input (SDI) Pin 5
#define VCC 8 // Connect to VCC Pin 8
// Added by Ralph S Bacon just for enhanced user experience
#define GND 5 // GND for buzzer
#define PWRLED 6 // Power on LED
#define BUZZ 7 // Beeper pin
int inData = 0; // incoming serial byte AVR
int targetValue = HFUSE;
int targetClock = LFUSE;
void setup() {
// Set up control lines for HV parallel programming
pinMode(VCC, OUTPUT);
pinMode(RST, OUTPUT);
pinMode(DATAOUT, OUTPUT);
pinMode(INSTOUT, OUTPUT);
pinMode(CLKOUT, OUTPUT);
pinMode(DATAIN, OUTPUT); // configured as input when in programming mode
// RSB "enhancements"
// Sink the Buzzer to ground
pinMode(GND, OUTPUT);
digitalWrite(GND, LOW);
// Turn on power LED
pinMode(PWRLED, OUTPUT);
// Buzzer / beeper
pinMode(BUZZ, OUTPUT);
digitalWrite(PWRLED, HIGH);
// Let user know we're ready to go
digitalWrite(BUZZ, HIGH);
delay(50);
digitalWrite(BUZZ, LOW);
// End of RSB
// Initialize output pins as needed
digitalWrite(RST, HIGH); // Level shifter is inverting, this shuts off 12V
// start serial port at 9600 bps:
Serial.begin(9600);
}
void loop() {
switch (establishResetContact()) {
case 49:
targetValue = HFUSE;
break;
case 50:
targetValue = 0x5F;
break;
default:
targetValue = HFUSE;
}
switch (establishClockContact()) {
case 49:
targetClock = LFUSE;
break;
case 56:
targetClock = 0xE2;
break;
default:
targetClock = LFUSE;
}
Serial.println("Entering programming Mode
");
// Initialize pins to enter programming mode
pinMode(DATAIN, OUTPUT); //Temporary
digitalWrite(DATAOUT, LOW);
digitalWrite(INSTOUT, LOW);
digitalWrite(DATAIN, LOW);
digitalWrite(RST, HIGH); // Level shifter is inverting, this shuts off 12V
// Enter High-voltage Serial programming mode
digitalWrite(VCC, HIGH); // Apply VCC to start programming process
delayMicroseconds(20);
digitalWrite(RST, LOW); //Turn on 12v
delayMicroseconds(10);
pinMode(DATAIN, INPUT); //Release DATAIN
delayMicroseconds(300);
//Programming mode
int hFuse = readFuses();
//Write hfuse if not already the value we want 0xDF (to allow RST on pin 1)
if (hFuse != targetValue) {
delay(1000);
Serial.print("Writing hfuse as ");Serial.println(targetValue, HEX);
shiftOut2(DATAOUT, INSTOUT, CLKOUT, MSBFIRST, 0x40, 0x4C);
// The default RESET functionality
//shiftOut2(DATAOUT, INSTOUT, CLKOUT, MSBFIRST, HFUSE, 0x2C);
// this turns the RST pin 1 into a (weak) IO port
//shiftOut2(DATAOUT, INSTOUT, CLKOUT, MSBFIRST, 0x5F, 0x2C);
// User selected option
shiftOut2(DATAOUT, INSTOUT, CLKOUT, MSBFIRST, targetValue, 0x2C);
shiftOut2(DATAOUT, INSTOUT, CLKOUT, MSBFIRST, 0x00, 0x74);
shiftOut2(DATAOUT, INSTOUT, CLKOUT, MSBFIRST, 0x00, 0x7C);
}
//Write lfuse
delay(1000);
Serial.println("Writing lfuse
");Serial.println(targetClock, HEX);
shiftOut2(DATAOUT, INSTOUT, CLKOUT, MSBFIRST, 0x40, 0x4C);
shiftOut2(DATAOUT, INSTOUT, CLKOUT, MSBFIRST, targetClock, 0x2C);
shiftOut2(DATAOUT, INSTOUT, CLKOUT, MSBFIRST, 0x00, 0x64);
shiftOut2(DATAOUT, INSTOUT, CLKOUT, MSBFIRST, 0x00, 0x6C);
// Confirm new state of play
hFuse = readFuses();
digitalWrite(CLKOUT, LOW);
digitalWrite(VCC, LOW);
digitalWrite(RST, HIGH); //Turn off 12v
// Let user know we're done
digitalWrite(BUZZ, HIGH);
delay(50);
digitalWrite(BUZZ, LOW);
delay(50);
digitalWrite(BUZZ, HIGH);
delay(50);
digitalWrite(BUZZ, LOW);
Serial.println("
Programming complete. Press RESET to run again.");
while (1==1){};
}
int establishClockContact() {
Serial.println("You can choose the 1MHz or 8MHz clock frequency, "
"to match the bootloader burned
");
// We must get a 1 or 8 to proceed
int reply;
do {
Serial.println("Enter 1 to 1 MHz");
Serial.println("Enter 8 to 8 MHz
");
while (!Serial.available()) {
// Wait for user input
}
reply = Serial.read();
}
while (!(reply == 49 || reply == 56));
return reply;
}
int establishResetContact() {
Serial.println("Turn on the 12 volt power/
You can ENABLE the RST pin (as RST) "
"to allow programming
or DISABLE it to turn it into a (weak) GPIO pin.
");
// We must get a 1 or 2 to proceed
int reply;
do {
Serial.println("Enter 1 to ENABLE the RST pin (back to normal)");
Serial.println("Enter 2 to DISABLE the RST pin (make it a GPIO pin)
");
while (!Serial.available()) {
// Wait for user input
}
reply = Serial.read();
}
while (!(reply == 49 || reply == 50));
return reply;
}
int shiftOut2(uint8_t dataPin, uint8_t dataPin1, uint8_t clockPin, uint8_t bitOrder, byte val, byte val1) {
int i;
int inBits = 0;
//Wait until DATAIN goes high
while (!digitalRead(DATAIN)) {
// Nothing to do here
}
//Start bit
digitalWrite(DATAOUT, LOW);
digitalWrite(INSTOUT, LOW);
digitalWrite(clockPin, HIGH);
digitalWrite(clockPin, LOW);
for (i = 0; i < 8; i++) {
if (bitOrder == LSBFIRST) {
digitalWrite(dataPin, !!(val & (1
EDIT:
I pulled out another ATTiny85 and its working with no issues. So, apparently there are no problems with my circuit or sketch.
Though, what is happening, as described below, is still strange.
Did I really 'brick' my chip? (The code I put in does function, I just can't update it with anything since I can't change even read the fuses)
Do I just need to do an erase? (I know I didn't set the lock bits)
I'll investigate more.
Cheers!
--------------------------------------
Hi Ralph,
I really tried to get this working, but i'm hitting a wall... Hoping you, or another viewer, can help! :-)
I built the circuit per the schematic on your GitHub, with the following changes:
Using a Pro-Mini rather than an UNO - same pin numbering
For the 12V source, I'm using a MAX662 rather than a battery.
removed switch, 12V LED and protection diode
Removed Buzzer
I did use a 10uF, as per the schematic, for VCC2. (I understand you used 0.22uf)
The only changes I made to your code was removing any references to BUZZ, and removing the GND2.
(As the GND2 seems to be only for improving the buzzer & Other many other schematics appear identical to yours, but use a single common ground.)
With a bunch of detective work, I've traced the problem to the first shiftOut2 command:
// Returns the value of the HFUSE
int readFuses() {
Serial.println("Reading fuses");
//Read lfuse
shiftOut2(DATAOUT, INSTOUT, CLKOUT, MSBFIRST, 0x04, 0x4C);
pause(); // Function i added to wait for user action. ***
...
The "Reading Fuses" displays properly, but it never reaches the pause(); - It just hangs
(The pause function does work - it was used several times to get to this point)
Presumably, the code should work regardless if there is an ATTiny inserted or not, yes?
(The code gets to the same point regardless)
I've run through all the pins with a hardware check program that activates only one pin at a time, on an empty socket, to confirm proper operation, check for shorts, etc.
The MAX 662 can only supply up to 30mA, but the line isn't being pulled down, so I assume it isn't using much current.
I haven't been able to find much documentation on the shiftOut2 command. almost all references I can find relate to HVSP code.
I've been banging my head for a couple of days on this!
Any Ideas???
My only idea remaining is to remove/change out the cap on the VCC2 line
** EDIT **
While writing this, I had the program sitting in the background. after MANY minutes, the code did reach the pause() function. I've entered a value to get it to continue.
From what I have seen on your video, and others, this should take less than a second.
All the other commands seem to operate with the expected timing - ie, really fast.
(my pro-mini is a 5 V 16MHz & has been working fine with previous projects and everything else in this one)
...
Now that I have writing the above, I have a lfuse reading E0. (was expecting E2, but whatever, at least its a reading)
Waiting now to see if a hfuse value gets read. It has been several more minutes since I got the lfuse reading. been about 10 minutes, nothing yet, but will let it continue running.
It sounds as if the Tiny85 with which you're having issues is that it is running very slowly - but really slowly, not just 1MHz instead of 8MHz. At the end of the day, if that chip is causing so many issues just continue with the other one, it's not worth spending hours sorting out a $1 chip.
sir, as im new to arduino(Beginner) this problem arise when i wanted to program ATtiny85, when i connected all pins to uno and upload sketch, error it saying select correct board from board manager. even i selected crct board and port, i googled about this problem and found that my ATtiny85 is bricked,finally i found a page and link to this video, and i collected all components but i didn't understand that how do i upload the code? im having few questions, should i use "arduino as ISP" ? or should i select ATtiny85 from board manager? and which clock speed should i use? help...
thanks in advance.
Have a look at video #82 which describes in some detail using the ATTiny85, ARGS. If that doesn't answer your query let me know and I'll dig further for you. As it happens I will be demoing some very small ATTiny85 adapter boards in a future video which have a micro USB port but that won't help you right now but may interest you in the future. Good luck!
Ralph S Bacon i understood the concept of programming ATtiny85 using arduino uno as ISP but inorder to set the correct fuses by using arduino uno, we nee to program arduino as ISP then select the board ATtiny85 frm board manager and upload the fuse resetter sketch, am i right. am i on the right track? even i created the board which ur using for resetting fuses or for extra gpio pin. correct me if am wrong.
thank you for replying on my comment.
I think that pretty much sums it up, Args, just be sure to follow the video step-by-step and look at the video description for more resources that I may have included.
Thank you Ralph, for all the good videos. And now for ARGS.
Using Arduino IDE upload the sketch to the UNO board. Keep in mind, the sketch is for UNO and not for attiny. When you upload the sketch do not use Arduino as ISP. Select the simple AVRISP mkII or AVR ISP as programmer and Arduino/Genuino UNO for the board. After programming the UNO board with the sketch go to Tools and click on Serial Monitor. Check to see if you have 9600baud in the right corner of your Serial Monitor window. Connect the High Voltage programmer board in to the UNO board an you should see in Serial Monitor window a message like this:
"
Turn on the 12 volt power/
You can ENABLE the RST pin (as RST) to allow programming
or DISABLE it to turn it into a (weak) GPIO pin.
Enter 1 to ENABLE the RST pin (back to normal)
Enter 2 to DISABLE the RST pin (make it a GPIO pin)
"
Hi Ralph, Love your videos - always well produced without waffle. Did you show the diagram for your modified circuit anywhere? I can't seem to find it. Keep up the good videos!
I can't remember what I did with the modified circuit, kintara58, as I'm a few thousand miles away from my workshop it will have to wait until I return. Give me a nudge if you don't hear anything in a couple of weeks!
Not to worry. After careful examination of the video footage and the Arduino IDE script I think I have worked out the circuit. The only thing I’m having an educated guess at is the addition of a reverse polarity protection diode on the 12v line and a smoothing capacitor (10uF?) between 5v and ground. Next step is to make it up and maybe etch a PCB. Thanks for all your video tutorials - I find them very useful and easy to follow.
See my post above. Schematic posted.
Dumb question because I'm too lazy to research it: Can this pin be used as a digital input instead of a "weak" output, or is it only GPIO in terms of RST in, and "Weak" out and no other options?
I don't see anything in the datasheet to suggest that it cannot be used as an input pin (weak GPIO, is says).
@@RalphBacon - Thanks for the reply. I required 4 digital inputs (to read a binary switch), one digital output used as an interrupt to a peripheral processor and one analog input.
I used the reset pin for the analog input after first debugging the program using an UNO and then loading it in the normal way to the Attiny. After the load, I then used your Fuse bit board to make use of the reset pin as an analog input. Works....
Is that Tool at 15.00 aka Fuse doctor! Thanks
Well, Omo, I've discovered that there are several, very similar circuits just like the Fuse Doctor one (which I searched on Google for) so I suppose it is similar to that, although the source of my (somewhat upgraded) circuit board is, I believe, mentioned in the video or the video description. But the gist of them all is that you apply a 12v pulse to the correct pin at the right time and voila! You have a reset fuse. My home grown version works very well although you can get kits (or ready-made versions) of similar items off the Internet if your soldering skills are not up to the job. I hope this helps.
Ralph S Bacon
Thanks Great 👌🏻
Great video 👍 subbed
You are most welcome usama muneer, I'm glad you like the video. Nice to hear from you and thanks for the sub. You're now an official Arduinite!
Fuse is subject to confuse
Yes, fuses do require a bit of learning.
@@RalphBacon it was just a rhyme xD
Great video. I know it's not your's and at least it works... but that is some horrible code that you're using to set the fuses.
Thanks for sharing! I'm not even going to look at that code to set the fuses; if it's not my code then you're right, it will be horrible. 🤣
Great video again Ralph. Thank you for your research on expanding the ATTiny85.
With your permission, for anyone needing the AttinyShield programmer:
- The DIY version of AttinyShield can be found here: www.ebay.com/itm/221434907666
- The fully soldered version of AttinyShield can be found here: www.ebay.com/itm/221324819158
Also I would happily accept the challenge of making this pcb probgrammer but because of your videos I have
a lot of AttinyShield's to make, since with every video i have new orders of the Shield :)
Also did you receive the gift board of AttinyShield I have sent you?
Waiting for your next video my friend.
Themis
Amisail3 How about a shield for both high and low voltage programming? I recently bought your programming shield, works well. Used it on my latest project.
Thank you Steve I am grlad you've found it usefull.
I guess the problem for a mixed shield would be the size. It should cover more pins and have more componets on it.
Also not everybody needs both functions. The soft programming that my AttinyShield does is enough for many projects with 2-3 inputs-outputs.
Ralph showed us that if we need more then it is possible... but a shield...
In any case Steve it was nice bringing it up.
Themis
Hey Themis, great to hear that business is booming!
Yes, I just got your replacement shield, thank you so much, I shall construct it soon (and not modify it this time). I guess there is not enough demand for a PCB for a HV programmer; at least I have shown that it is easy to construct on strip board!
I wish you continued success and enjoy the videos. NIce to hear from you.
Great news Ralph. Hope you ll enjoy it.
Keep up the good work friend :)
@Amisail3. I recently received your ATtiny85 shield and very promptly to. It completely simplifies the programming of, and the development of firmware for, these devices. Thank you so much.
WTF with uC esp Arduino a fuse? a sketch? sweet jesus ....just call it what it is
Calm down, Kenn, no need for such stress! The program in a microcontroller is called a 'sketch' in the Arduino world. And a bit flag is called a 'fuse'. It's to ensure no-one that is not in the Arduino club has any idea of what we're all talking about.
@@RalphBacon I think it is absouletly asinine to create a new set of jargon for something that is virtually identical. But why stop there? For the uC world we can have:
Zebra - Switch statement
Alberta - If statement
Potato - Do loop
SameSame - assignment
Relation - a function (Math joke)
Well, unlike your examples, using a different set of terms does confine what we are talking about to the Arduino world! That said, can we use a Zebra within a Potato, or is it best to stick with a simple Alberta? (Now my brain hurts).
Thats how languages evolved, words meaning change with time, like the F word for example
fuse meant to melt metal, then it got used to mean an electrical component that protect electrical hardwares
but basicaly it was made from metal that fuse at cetrain current
the intended meaning of fuse is no different from the electrical one
instead this bit is meant to protect your code running on uC, but at a certain voltage, the "fuse" blow up and reset everything
@@zazugee Seems to me you have a basic MIS understanding of micro-controller fuses. Which is not surprising given the terrible mis-use of the term.
As in any design process, let’s say graphics design. There are some settings are being tuned at the beginning of the design project such as dimensions, dpi, background, colors, etc. These setting are said to be “The configurations” of the project which will not be changed till the end ideally.
Similarly, in embedded software design, there are also some configurations for each MCU used in the whole project. Such as the type of oscillator internal/external, whether you’ll use a watchdog timer or not, whether there’ll be a reset pin or not, and so. These configurations are controlled via a dedicated specific register in the ROM, In our MCU it’s called “CONFIG_WORD”.
Every single bit in this register controls a specific feature, combined together in this register to control all the settings (configurations), Hence they are often called the “Configuration Bits”. Some books in the embedded literature call these bits as “Fuses”. All in all, these names stand for the same thing.
deepbluembedded.com/configuration-bits-fuses-for-microcontrollers/