Gpio and Gate Circuits

Source: Internet
Author: User

1. GPIO 1.1 Introduction

GPIO, General Purpose I/O, universal input/output interface, is the simplest digital input/output pin
-As output can have two states: 0 and 1
-as input, it receives the digital signal 1.2 function of the outside input

Gpio can be used for input, output, or other special functions
These functions are typically selected via the Register configuration pin feature
-Input: The level of the pin can be determined by reading a register; If you are reading a key, press the
-Output: A register can be written to allow the pin to output high or low level; such as for controlling the state of the lamp
-Other special functions: there are additional registers to control them; such as interrupt function, the PIN is input function, but also can interrupt the CPU 1.3 pull-up resistor

Pull-up resistors and NPN transistors, pull-down resistors, and PNP transistors
The function of the pull/pull-down resistor is to determine the status of the dangling pin level
When the Gpio pin is in a third State (that is, not the output high level, not the output low, but a high impedance state, that is, the equivalent of the chip is not received)
Its level state is determined by the pull-up resistor, the pull-down resistor

such as pull-up resistors, for input pins, can be used to determine the level state (high, low) 1.4 s3c2410

Take s3c2410 as an example, a total of 117 I/O ports, divided into A~h total 8 groups: GPA, GPB 、...、 GPH
You can set a register to determine whether a pin is used for input, output, or other special functions

Related registers are
-Gpxcon for pin function selection
-Gpxdat for read/write PIN data
-Gpxup is used to determine if the internal pull-up resistor is used

(TIP: Not all pins have a pull-up resistor) 1.4.1 Register

Gpxcon Register: It is used to configure (Configure) the Select Pin function.
Each of the two bits in the Gpxcon control one pin: 00 for input, 01 for output, 10 for special functions, and 11 for reserved.

Gpxdat Register: For read/write Pins
When the pin is set to input, this register indicates whether the level state of the corresponding PIN is high or low
When PIN is set to output, write this register corresponding bit can make this pin output high level or low level

Gpxup Register: A bit is 1 o'clock, the corresponding pin has no internal pull-up resistor, for 0 o'clock, the corresponding pin using the internal pull-up resistor 1.4.2 Gpio pin use

There are 3 types of s3c2440 pin operation: output high and low level, detection pin status, interrupt

To light led for example, mini2440 led1-4 respectively corresponds to gpb5-8
If we want to control these LEDs, we first need to set the gpb5-8 corresponding bit in the Gpbcon register as the output function.
Then write the corresponding bits of the Gpbdat register so that the 4 pins output high and low levels

Generally low-level active
-The LEDs are off at high power
-led lit at low power

Use the following code to let the GPB5 output low, light LED1

/*   * s3c2440 datasheet and Gpbcon register address   */  #define  Gpbcon (* (volatile  unsigned long  *) 0x56000010)  #define  Gpbdat (* (volatile  unsigned long  *) 0x56000014) /*   two bit control a pin, then GPB5 is Gpbcon's [11:10] bit   1 shifts left 10 bits, then [11:10] is 01, which means GPB5 is output   */  #define  Gpb5_out (1<< (5*2)) Gpbcon = Gpb5_out; /*   * 1 Left 5 bit reversed, then 5th bit 0, that is GPB5 output low, lit LED1   */ Gpbdat &= ~ (1<<5); 
2. Gate Circuit

Gate circuit includes non-gate, with door, or door, with non-gate, or non-gate

Gpio and Gate Circuits

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.