GPIO Port & Control Registers ATMega328 Arduino

Arabinda Verma
Arabinda Verma
8.3 هزار بار بازدید - 6 سال پیش -
https://www.udemy.com/embedded-progra...

General purpose input output, GPIO in short, is an interface on a MCU which is used to communicate with external world. The GPIO port or pin can be used as input to read the data from peripheral device or as output to send data and control different operations on the interfaced device. The mode, input and output also known as read and write, of a pin is configured by the driver software at runtime and can be changed as per the need. The protocol used to communicate with the peripheral device is also defined by the driver software. For example, we can use GPIO port to interface liquid crystal display to communicate information to external world. In the example, the data to be displayed and the control signals are provided over GPIO port and the busy state of LCD is read over the GPIO pin.

The Atmega328p uC has 3 GPIO ports - namely PORTB, PORTC and PORTD. PORTB & PORTD are 8-bit wide whereas the PORTC is 7-bit wide.

The ports have true Read-Modify-Write functionality. This means any of the port pins can be configured from read to write mode and vice-versa. The direction (i.e. read or write configuration) of an individual pin can be changed w/o affecting that of other pins on the same port. And the same applies when enabling or disabling the pull-up resistor of respective port pin.

The output buffer of the GOIP ports have symmetrical drive characteristics. That means the output buffer is equally good at sourcing or sinking the same amount of current through the port pin when driven high or low, respectively. The output buffer of the pins uses Complementary MOSFET (CMOS) where P- and N- field effect transitor of closely matched characteristics is used to achieve such "symmetrical" performance. The Atmega328p uC can source and sink 40mA of current through its GPIO pins. We must ensure the current limit is respected while interfacing external peripherals with the uC.

However, all the pins of the GPIO ports cannot be used simultaneously as most port pins are multiplexed with alternate functions. For example, the PC6 of PORTC that is the pin 1 is used as RESET for the microcontroller. Similarly the bit 6 & 7 of PORTB can be used as Pin Change Interrupt source or timer oscillator or connected to external crystal for clock generation. We have used these pins to connect 16 Mhz Crystal oscillator to generate clock signal. Enabling the alternate function of some of the port pins does not affect the use of the other pins in the port as general purpose I/O.
6 سال پیش در تاریخ 1397/10/24 منتشر شده است.
8,319 بـار بازدید شده
... بیشتر