Controlling PE2/HWBE pin on ATmega32U4

It seems there is no pin label to read/write to pin 33 (Port E 2/ HWBE) in the IDE. The datasheet for the micro states:

"HWB allows to execute the bootloader section after reset when tied to ground during external
reset pulse. The HWB mode of this pin is active only when the HWBE fuse is enable. During normal
operation (excluded Reset), this pin acts as a general purpose I/O."

Is there a clever way to use this pin as an output? I tried a library named FastGPIO, but no luck.

All my other pins are committed.


Manipulate the PORT, PIN, and DDR (Data Direction Register) directly:

PORTE |= 0x04; // Set PE2
PORTE &= 0xFB; // Clear PE2
PINE = 0x04; // Toggle PE2
val = !!(PINE & 0x04); // digitalRead PE2
DDRE |= 0x04; // pinMode PE2 OUTPUT
DDRE &= 0xFB; // pinMode PE2 INPUT

All my other pins are committed.

Are any of them being used as digital from switches ? If so, have you considered using an analogue input and a resistor ladder to provide different voltages to enable you to differentiate between different switches ?

@johnwasser: Perfect! I remember looking at manipulating the port bits directly, but somehow forgot about it. Thank you.

@UKHeliBob: My analogs are driving LEDs and other functions and the "new" pin needs to turn on a FET.

All good now... unless I need another pin. :slight_smile: