How to use UPDI Pin as GPIO Output on ATtiny804 ? #1203
-
Dear All, I need help configuring a GPIO pin as an output on my ATtiny804. I require an additional output pin for my circuit, and I would like to use the UPDI pin11 (physical pin 10). Here’s an example code I tried (not working): // Pin 11 is used as the output pin
const int outputPin = 11;
void setup() {
// Initialize pin 11 as an output
pinMode(outputPin, OUTPUT);
}
void loop() {
// Turn the LED on
digitalWrite(outputPin, HIGH);
delay(100); // Wait for 100ms
// Turn the LED off
digitalWrite(outputPin, LOW);
delay(2000); // Wait for 2 seconds
} Could someone guide me on how to properly configure the UPDI pin as a GPIO output? Any suggestions or example code would be greatly appreciated! Thank you in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
If you configure the UPDI pin for GPIO, you'll no longer be able to re-program the chip without a high voltage programmer, so make sure the extra GPIO is worth the effort. There are notes on how to enable GPIO at https://github.com/SpenceKonde/megaTinyCore?tab=readme-ov-file#list-of-tools-sub-menus - search for the text "Tools -> UPDI/Reset". An alternative is to use the UPDI pin as an input, with some limitations. I haven't tried it myself, but see #380 |
Beta Was this translation helpful? Give feedback.
Now you need to disconnect the 10K resistor if you want to program. If you put your pushbutton between GND and UPDI, you automatically use the internal weak pullup resistor from the UPDI pin instead, and you don't need to change anything when you want to program.
UPDI programming is impossible with the 10K resistor in place, which can be a disadvantage or an advantage, based on your requirements.