Raspberry Pi_Eng_25.2.2 GPIO Port Details


Published Book on Amazon


All of IOT Starting with the Latest Raspberry Pi from Beginner to Advanced – Volume 1
All of IOT Starting with the Latest Raspberry Pi from Beginner to Advanced – Volume 2


출판된 한글판 도서


최신 라즈베리파이(Raspberry Pi)로 시작하는 사물인터넷(IOT)의 모든 것 – 초보에서 고급까지 (상)
최신 라즈베리파이(Raspberry Pi)로 시작하는 사물인터넷(IOT)의 모든 것 – 초보에서 고급까지 (하)


Original Book Contents


25.2.2  GPIO Port Details

 

25.2.2.1    GPIO Basics

 

There are various kinds of GPIO interface pins in Raspberry Pi. Each pin has its own purpose, and several pins are used together to make a specific circuit.

 

 

   DNC (Do Not Connect )

 

First, you never connect anything to the pins marked DNC. These pins are reserved for the internal functions of the Raspberry Pi BCM2835 SoC.

 

 

   GPIO pin

 

In the Raspberry Pi B + model, 28 of the total 40 pins can be used as GPIO pins, which can be used for input or output depending on the GPIO mode setting.

 

GPIO pins have a high (+3.3V) or low (ground or 0V) state. This can correspond to 1 and 0 in a computer binary operation, and also can be handled by transmitting 1 bit of digital data. With this function, for example, you can perform an operation to turn other components on or off.

    Low           = 0V                -- 0      -- False

    High           = 3.3V              -- 1      -- True

 

 

   Power

 

The Raspberry Pi is powered externally via the micro-USB connector and supplies the necessary power to the interface via the GPIO pin. The GPIO 1 port provides 3.3V power, and the maximum allowable current is 50 mA. The GPIO 2 port provides 5V power supply. The maximum allowable current may vary depending on the power supply to Raspberry Pi. In any case, enough current must be left for the Raspberry Pi system to operate.

 

Although the Raspberry Pi provides 5V power through the GPIO 2 port, you should not use 5V power supply unless you have a special purpose. Attention should be paid to the GPIO port, as incorrect connection of 5V power supply to the GPIO pin or other pin can cause serious damage to the system.

 

All of the internal circuitry and components of the Raspberry Pi are powered by 3.3V power supply. In addition, all GPIO pins in the Raspberry Pi are directly connected to the internal BCM2835 SOC (system on a chip), so a small mistake can damage the entire Raspberry Pi system or SD card. Therefore, when creating the interface circuit using Raspberry Pi's GPIO pin, be sure to use 3.3V power from GPIO 1 port.

 

For this reason, there is a way to avoid this risk by using 3.3V logic compatible components between the Raspberry Pi and external circuitry, or by using a constant voltage circuit such as Gertboard.

 

Most micro controller devices, such as Arduino and related products, operate mainly from 5V power supply. Equipments designed for Arduino can not be used in Raspberry Pi unless a level converter or optical isolator is used. Likewise, connecting the pin of 5V microcontrollers to the GPIO port of Raspberry Pi can permanently damage Raspberry Pi.

 


 

25.2.2.2    Special Purpose GPIO

 

The GPIO pin contains two I2C interface pins, five SPI interface pins, and two serial UART interface pins. These I2C, SPI, and UART interfaces can be used as general-purpose I/O pins when not used as the original bus mode. Some of these pins can also be used for PWM output or PCM.

 

 

   I2C(Inter-Integrated Circuit) bus

 

The I2C bus is a bus-type interface device designed to communicate with a number of internal integrated circuit slave devices. Raspberry Pi can work as a master on the bus.

 

The I2C bus can be accessed via GPIO 3 pin and GPIO 5 pin. GPIO 3 pin is SDA (Serial Data) signal line and GPIO 5 pin is SCL (Seria Clock) signal line. They include a 1.8K pull-up resistor internally and do not require a separate resistor.

 

 

   SPI (Serial Peripheral Interface

 

The SPI bus is a bus-type interface device designed to communicate with a number of internal SPI devices. Raspberry Pi can only operate as a master on the bus. The SPI (Serial Peripheral Interface) bus is mainly designed for usge in ISP (in-system Programming) between microcontrollers and other.

 

Unlike UART or I2C, it consists of a bus with four wires, including a chip select line, to allow communication with more than one target device.

 

Raspberry Pi has five pins that can be used to connect SPI devices as follows:

    19 pin                    -- MOSI (SPI master output and slave input)

    21 pin                    -- MISO (SPI master input and slave output)

    23 pin                    -- SLCK (Serial clock for communication synchronization)

    24, 26pin                -- Chip select signal line that supports independent slave device.

 

 

   UART (Universal Asynchronous Receiver/Transmitter

 

The UART (Universal Asynchronous Receiver / Transmitter) is a simple 2-wire serial interface and uses a serial bus type connection.

 

The UART serial bus can be accessed via GPIO 8 pin and GPIO 10 pin. GPIO 8 pin is for sending signal, GPIO 10 pin is for receiving signal. The sending speed can be set in the "cmdline.txt" file. Usually, it is 115,200 bps (Bits per second).

 

When the serial port is set in "cmdline.txt" file, this serial bus is the port used to output the message. You can display messages from the Linux kernel by connecting Raspberry Pi's serial bus to the display. If Raspberry Pi is causing problems during the boot process and nothing is displayed on the display, this serial bus can be an easy diagnostic tool.

 

Note that these pins operate at 3.3V and the typical RS232 specification is 12V. Therefore, connecting these pins to the RS232 serial device may damage Raspberry Pi.