Gpio control of S3C2440

Source: Internet
Author: User

 

1. gpio introduction: 

  Gpio (general-purpose input/output ports) is relative to the chip. If the corresponding chip has gpio pins, you can read these pins to obtain pin changes (I .e: changes in the level of the pin ).

  There are 117 I/O Ports in the S3C2410 chip, which are divided into ~ H. A total of 8 groups are GPA ~~ Gph. there are 130 I/O Ports in the S3C2440, which are divided into ~ J9 group names are GPA ~ Gpj, configure the registers (gpxcon, x = ~ H/J), the setting pin is used for input/output, or for special functions.

1.1 Access the pin through registers:

   1. gpxcon register:

       Gpxcon (x = ~~ H/J) registers are used to set whether the function of the corresponding PIN is input/output or special function or reserved.

        In terms of function configuration, Porta and portb ~ Porth/J is different. Each bit in the gpacon register corresponds to a pin (23 bits in total). When a bit is set to 0, for the output pin (which can be used for writing), we can write the gpadat register (used for writing pins, when a pin is set to 1 (the corresponding PIN is the address line/or used for control), gonadat is useless.

        Portb ~ Porth/J perform identical operations on registers. Each two bits of gpxcon correspond to one pin:

        00 -- input. 01 -- output. 10 -- special features. 11 -- reserved.

   2. gpxdat register:

       Gpxdat is used for read/write pins. When the gpxcon register is configured to set a pin as the input, read this register to learn the changes to the corresponding PIN. When the gpxcon register is configured to set a pin as the output, by writing this register, the corresponding pins can generate high and low level changes.

  3. gpxup register:

        When a pin is set to 1, the corresponding PIN has no internal pull-up resistance. If it is set to 0, the corresponding PIN uses the internal pull-up resistance;

1.2 access to gpio through software:

# Define gpbcon      (* (Volatile unsigned long *) 0x56000010)

 

# Define gpbdat       (* (Volatile unsigned long *) 0x56000014)

 

# DefineGpb_out    (1 <(2*5 ))

                   

Gpbcon = gpb_out; // you can specify gpb5 as the output.

Gpbdat& = ~ (1 <5 );// Output low level to gpb5

 Note: When design is requiredProgramWhen accessing the hardware, you can refer to the circuit schematic provided by the chip to find the used pin and further find the Register address description in the chip manual to determine the specific address of the register used.

Reprinted link:
Http://blog.csdn.net/fedora1985/archive/2009/05/10/4165350.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.