Arm9-hardware interface learning 3 gpio

Source: Internet
Author: User

Gpio Port 1 is an important concept. You can use the gpio port to interact with hardware (such as UART) and control hardware (such as led and buzzer) read the hardware Working Status Signal (such as the interrupt signal. The gpio port is widely used.S3C2410 has a total of 8 gpio ports and 117 pins from GPA to gph..

Most of these I/O ports are reusable and can be used as input, output, and special function ports (such as interrupt signals ). You can use the configuration register (gpxcon) of the corresponding port to select different functions. After the gpio port is configured, you can read/write data in the corresponding data register gpxdat. gpxup is used to determine whether internal pull-up resistance is used. (Note: When I/O ports are defined as input, the pull-up resistance is usually used to avoid incorrect values due to signal interference .)

When the PIN is set as input, read this register to see that the status of the corresponding PIN is high or low; when the PIN is set as output, write the corresponding bit of this register to make this pin output low or high. Gpxup: When a value is 0, the corresponding PIN is not pulled internally; when the value is 1, the corresponding PIN is pulled internally.

NOTE: For the addresses and functions of gpio ports of S3C2410, see Chapter I/O Ports of datasheet 9th.

Keypad-controlled ledLamp display experiment:

When a button in the K1-K4 is pressed, the corresponding led in the LED1-LED4 is lit. To complete this experiment, we can take two steps:

1. Read the Board circuit diagram and determine which CPU pins are used.


The above is the circuit diagram corresponding to the armsys2410 led part of the Development Board. It can be seen that the armsys2410 LED0-LED3 corresponds to the I/O port GPF4-GPF7.

So how to control the LED light to turn off? It can also be seen in the circuit diagram. The left side of the led diode is a high voltage (vdd33v). Therefore, you only need to input a low level and turn on the circuit at the GPF Port Pin corresponding to the right side of the LED, and the LED will be on. That is, to make a light on, the corresponding PIN outputs a low level (off: high level ).

Here is the diagram of the keyboard K1-K4 part. You can see from the gpio datasheet section that eint0 corresponds to gpf0, eint2 corresponds to gpf2, and eint19 corresponds to gpg11. That is, K1 corresponds to gpf0, K2 corresponds to gpf2, K3 corresponds to gpg3, K4 corresponds to gpg11.

 

2. Configure the corresponding gpio Port

Configure the gpio port corresponding to the keypad KEY1-KEY4 as the input port, by reading the corresponding status signal of the port, you can judge whether the button is pressed. Configure the gpio port for the LED0-LED3 as the output port. Use the input data to control the flashing of LED lights. The following shows how to control the led by assigning the corresponding value to the Register.

test Code : http://www.cnblogs.com/heiyue/admin/Files.aspx

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.