So after debugging for 6h+ I am stuck at that the reset pin of my attiny 45 needs to differentiate between two voltage levels. (5v and 3.7v) Ive seen in the datasheet that this pin has an adc. So it should be able to read an analog value, right? Atleast as long as it is not pulled to gnd. I am using an Arduino Uno as an isp to program the chip. The essential question I have, which pin number has the reset pin in arduino code? As it seems th hang on this point. I thought it is five. But it doesnt seem to work. (I may be worng on this part because my debugging seemd to loose quality over time.) Ive also found, that one may need to put the chip in high voltage programming mode, which I wont like to do.
\$\begingroup\$ You are probably resetting the chip. When configured as a reset input, the logic high level is considered anything 0.9xVcc or above (4.5V). Anywhere between there and 1V and the chip may or may not be in reset. \$\endgroup\$– Tom CarpenterJan 9, 2018 at 20:43
\$\begingroup\$ Try blinking an LED as the first thing you do in the program and see if it blinks when you take the reset signal down to 3.7V \$\endgroup\$– Tom CarpenterJan 9, 2018 at 20:44
1\$\begingroup\$ @TomCarpenter One could almost think you were reading a datasheet if you could come up with this vital information. \$\endgroup\$– Harry SvenssonJan 9, 2018 at 20:52
3\$\begingroup\$ @HarrySvensson maybe. ;) \$\endgroup\$– Tom CarpenterJan 9, 2018 at 20:53
1\$\begingroup\$ Take note that you can only use the reset pin as an input if you disable its reset functionality, and you need an ISP programmer to set the fuses to do that. Without reset pin, uploading a program using Arduino will be much harder, and ISP programming will become impossible altogether. \$\endgroup\$– marcelmJan 9, 2018 at 22:37
A few gotchas using the RESET pin as input...
- There is an internal pull-up resistor on it...
- In order to be able to use the ~RESET pin as an input and NOT also reset the chip, you need to disable the RESET pin with the RSTDISBL fuse...
- If you set the RSTDISBL fuse, you will be unable to use in-circuit programming to reprogram the part.
1\$\begingroup\$ Looks like the pull-up resistor inside is keeping me from reading correct values. Well, time to get a different mcu with more IO. Thanks for your help! \$\endgroup\$– user158029Jan 10, 2018 at 18:01