(MCU) Lecture2 - GPIO
(MCU) Lecture2 - GPIO
LÊ TRỌNG NHÂN
[email protected]
[email protected]
Content
▪ GPIO Output Mode
▪ GPIO Input Mode
▪ Analog Mode
▪ Alternative function Mode
2
GPIO Output ▪ T1 is the PMOS
and T2 is the NMOS.
▪ T1 will be activated
Ouput HIGH Output Low and T2 will be
deactivated
▪ T1 will take
the Vcc and give it to
the GPIO pin
3
GPIO Input
▪ When input GPIO = 1,
the inverter makes it as 0
4
GPIO Input Modes
▪ High-impedance or Floating
▪ Pull-up
▪ Pull-down
5
High-impedance
▪ Whenever the microcontroller is powered
ON, the GPIO pins are by default in this
HIGH impedance state input mode.
7
Pull Down
▪ In this type, the internal
pull-down resistor is
connected to the pin. So,
the state will be Low unless
an external pull-up resistor
is used.
8
GPIO Output Modes
▪ The GPIO is used to drive the electrical signal (high or
low) to the pin when it is configured as a output. There
are primarily two configuration options for GPIO outputs:
▫ Push-pull
▫ Open-drain
9
Push-pull
▪ This state is the default state of the GPIO output mode.
The pin can “push” the signal high or “pull” it low using
the PMOS transistor or NMOS transistor.
10
Open-Drain
▪ In GPIO output mode, the output buffer is formed using the
PMOS and NMOS transistors. If you remove the PMOS
transistor, then it will be an open drain output mode.
▪ The name comes from the fact that the MOSFET’s drain isn’t
internally connected to anything. If you use BJT instead of
MOSFET, then this is called an Open collector
▪ When you turn off the NMOS, the GPIO will not be
connected to either Vcc or GND. It will be in a floating state.
So, the output will be either Low or high impedance
(floating). It can pull the pin towards the ground, but it
cannot drive it high.
12
Alternate Function Mode
▪ GPIO pins have the capability of providing an alternate
function apart from the regular three modes.
13
LED BLINKY on STM32CUBE IDE
[STM32CubeIDE]
https://www.youtube.com/watch?v=ZuBKAAFxjgk
[Proteus Simulation]
https://www.youtube.com/watch?v=b5K0uxedVDw
Software Timer