ATTiny45 and ADC0

I've an ATtiny45 design & have built quite a few. It's programmed with Arduino as ISP (on UNO). All has worked well. Now an added feature (or is it function bloat??) requires another analogue input, and ADC0/Reset is the only option. After several days of searching I've learned only that the RSTDSBL fuse must be programmed to enable using ADC0 (which shares the Reset pin), but I've no idea how to do that. It's also indicated that if one programs RSTDSBL, that will eliminate further program changes with Arduino as ISP, but I've not seen how to go about 'un-bricking' the ATTiny.
Does anyone know of a tutorial - or can provide one - to lead me by the hand through this? Any suggestions will be appreciated!

Note that for voltages higher than 0.9*Vcc, the ADC shared with reset may be usable without disabling reset. If the voltage were constrained to that range by resistor divider, that might let you have your cake and eat it too.

RSTDSBL is programmed in the same way as any other fuse. This typically would need to be done manually after uploading the code with AVRdude (with "verbose output on upload" enabled in preferences, the output shown when initializing the fuses with burn bootloader will include the the AVRdude invocation which can be used as a model - you would want to remove the -e, -Uefuse, -Ulfuse, and -Uflash directives, and change the value specified by the -Uhfuse directive to have the RSTDISBL bit 0 instead of 1.

For unbricking, you need an HVSP programmer for 8 and 14-pin classic tinyAVR parts. All classic AVR devices with more than 14 pins require HVPP instead, which is an even nastier protocol. Search for "fuse doctor" for plans for devices designed specifically to reset the fuses when they have been configured such that normal ISP programming is impossible. This is a far more common method in hobby circles than using a full general purpose programmer (those seem to be very much an exotic item), though the process overall is sufficiently onerous that it is rarely used by hobbyists, the main exception being digispark clones which often set that option as the original digispark did, with the board being unplugged and replugged and the bootloader running at the power-on reset.

HVSP programming pulls the RESET pin up to +12v while using 4 I/O pins for data transfer with a bizarre physical layer having 2 lines carrying data to the target (one for instruction, one for data), a dummy clock cycle at the start of every byte and two dummy clock cycles after every byte, with each operation involving 3-6 steps. The instructions are not the same as used in ISP programming - indeed they bear little similarity. (HVPP uses 16 I/O pins and the data and instructions are transmitted in parallel). All pins must be disconnected from any loads during HV programming of either sort.

Thank you for that comprehensive reply! This is, apparently, not your first rodeo...

As it turns out, the extra analogue input will be looking at a back-biased PIN photodiode, loosely pulled up to +5, and detecting ambient light to control the intensity of an indicator LED. That measurement could be accomplished in a 500 mV span below +5, although clamping it in that range while allowing the LV programmer access to Reset provides an opportunity to load the board with resistors and diodes...

Digikey is making noises of the sort that suggest the days of ATTiny45s are numbered. Can this be? Might it be time to roll the whole works into a 212/412?

If you are at all serious about electronics as a hobby, getting a cheap TL866 is an easy way to have HV programming of a huge range of chips. I generally use one for my ATTiny85 projects and it simplifies things for me, as well as making choice of using the reset pin completely moot. Dave did a video about this programmer ages ago -- it's worth a watch.

@DrAzzy wrote the ATTinyCore which is the core that you should be using (my humble opinion) for programming the tiny85.

1 Like

Ah. The evidence of DrAzzy's deeper magic was clear, and his contribution is very much appreciated!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.