Microcontroller GPIO Default State Before Initialization – Circuit Design Guide

circuit-designenablegpiomicrocontroller

I have a microcontroller that enables an IC. This IC would be enabled when a logic 0 is set in its enable input pin. So, one microcontrollers' GPIO is connected to that pin. My question is, before initialization of all the GPIOs, they are not set to any value.
So, maybe, before setting a logic 1 in that GPIO to start with disabled state of my system before GPIO initialization there is another default value. If that value is a low level value, the MCU would enable the IC during a short period of time. How can I know which is the default
state of GPIO (before initialization)? How can I find this in the MCU's datasheet? And how I avoid this to happen in case the default state is a logic 0.

Datasheet

Best Answer

Figure 8.5 on page 62 of your data sheet shows 'GPIO pins as inputs with pullups disabled' after power up when \$\overline{XRS}\$ (the active low system reset) is asserted, before the user code starts running.

enter image description here

However, immediately following power up, there is a short period when the I/O pins are undefined, shown by the cross hatching. This does not guarrantee that they are Hi-Z, or outputting any particular state, so this diagram does not give you the assurance you want. However ...

\$\overline{XRS}\$ is stated on page 34 to be an output, and this diagram shows it staying low for the whole duration of power being applied. You can therefore use this low state to qualify the I/O, so that it's in a known state at all times.

Use a pulldown on your MCU output pin 'GPIO_peripheral_enable' so that it's low when powered off, low during most of the MCU powering-on state, and low when still not yet configured as an output. It only goes high when your code configures it as an output, and sets it high.

Now put \$\overline{XRS}\$ and 'GPIO_peripheral_enable' into a NAND gate, with its output going to your peripheral's \$\overline{ENABLE}\$ pin.

Related Topic