ARM9 (S3C2440) IO port -- LED water lamp

Publisher:HarmonyJoyLatest update time:2016-01-19 Source: eefocusKeywords:ARM9 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
Overview

   The S3C2440A contains 130 multi-function I/O pins and they are eight ports as shown below:
– Port A (GPA): 25-bit output port
– Port B (GPB): 11-bit input/output port
– Port C (GPC): 16-bit input/output port
– Port D (GPD): 16-bit input/output port
– Port E (GPE): 16-bit input/output port
– Port F (GPF): 8-bit input/output port
– Port G (GPG): 16-bit input/output port
– Port H (GPH): 9-bit input/output port
– Port J (GPJ): 13-bit input/output port
   Each port can be easily configured by software for various system configurations and design requirements. You must define the function of each pin used before starting the main program. If the alternate function of a pin is not used, the pin can be configured as an I/O port.

IO port control register

Port Configuration Registers (GPACON to GPJCON)
   In S3C2440A, most ports are multiplexed pins. Therefore, it is necessary to decide which function is selected for each pin. PnCON (Pin Control Register) determines
which function is used for each pin.
Port Data Registers (GPADAT to GPJDAT) If the port is configured as an output port, data can be written to the corresponding bit of PnDAT. If the port is configured as an input port, data
   can be read from the corresponding bit of PnDAT . Port Pull-up Registers (GPBUP to GPJUP) The port pull-up register controls the enable/disable of pull-up resistors for each port group. When the corresponding bit is 0, the pull-up resistor of the pin is enabled. When it is 1, the pull-up resistor is disabled. If the pull-up resistor is enabled, the pull-up resistor is independent of the pin function setting (input, output, DATAn, EINTn, etc.) Miscellaneous Control Registers This register controls the sleep mode, USB pins and the data port pull-up resistor selected by CLKOUT. External Interrupt Control Register 24 external interrupts are triggered by various signal methods. The EXTINT register configures the signal trigger mode for the external interrupt request as low level trigger, high level trigger, falling edge trigger, rising edge trigger or both edge trigger. Since each external interrupt pin contains a digital filter, the interrupt control can confirm whether the request signal is longer than 3 clocks. EINT[15:0] is used for wake-up source


   

   

   
   
   

 

   This LED running light experiment uses GPB5-PGB8 of PB port to control 4 LEDs to light up in a cycle. It adopts common anode connection, that is, when the port bit is low level, the LED is on, and when it is high level, the LED is off.

 

step:

1. Initialize the IO port and set the GPBCON and GPBUP registers.

Here, GPB5-PGB8 of the PB port is used as a general IO port to realize the output function, so the GPB5-PGB8 bits of GPBCON should be 01 respectively, that is, GPBCON[17:10] is 01010101; the initial state of GPBUP is all 0, even if the pull-up resistor function is enabled, it does not need to be set, and it is set here.
The I/O port is generally connected to the peripheral device through optoelectronic isolation or other isolation devices. If it is directly connected, it must be confirmed that the load cannot exceed 4 NAND gates. Optoelectronic isolation can protect the microprocessor, perform level conversion, and distribute certain signals, so it is usually added.
2. The control idea is relatively simple. Let the 5-8 bits of the PB port cyclically become a low level (high level at other times), and the running light can be realized, and a delay is added between the two level conversions.

3. Procedure

#define rGPBCON    (*(volatile unsigned *)0x56000010)  //Port B control
#define rGPBDAT    (*(volatile unsigned *)0x56000014)  //Port B data
#define rGPBUP     (*(volatile unsigned *)0x56000018)  //Pull- up control B


#define  LED1_ON  (rGPBDAT &=~(1<<5))   //GPB5 bit cleared to 0
#define  LED1_OFF  (rGPBDAT |=(1<<5) )   //GPB5 position 1
#define  LED2_ON  (rGPBDAT &=~(1 <<6))
#define  LED2_OFF  (rGPBDAT |=(1<<6))
#define  LED3_ON  (rGPBDAT &=~(1<<7))
#define  LED3_OFF  (rGPBDAT |=(1<<7))
#define  LED4_ON  (rGPBDAT &=~(1<<8))
#define  LED4_OFF  (rGPBDAT |=(1<<8))

 

void Delay(void)
{
 int i;
 for(i=0;i<1000000;i++);
}

int Main()
{
 rGPBCON &=~((3<<10)|(3<<12)|(3<<14)|(3<<16));  //Clear GPBCON[10:17]
 rGPBCON |=((1<<10)|(1<<12)|(1<<14)|(1<<16));  //Set GPB5~8 as outputrGPBUP
 &=~((1<<5)|(1<<6)|(1<<7)|(1<<8));   //Set the pull-up function of GPB5~
 8rGPBDAT |=(1<<5)|(1<<6)|(1<<7)|(1<<8);    //Turn off LED
 
 while(1)
 {
  LED1_ON;Delay();LED1_OFF;
  LED2_ON;Delay();LED2_OFF;
  LED3_ON;Delay();LED3_OFF;
  LED4_ON;Delay();LED4_OFF;
 }
 return 0;
}

4. Program description: The program uses #define LED1_ON (rGPBDAT &=~(1<<5)) to set the register. Compared with the direct assignment method, this representation method is easier to observe which bit of the register has changed, and ensures that except for the bit that needs to be changed, other bits remain unchanged!

Keywords:ARM9 Reference address:ARM9 (S3C2440) IO port -- LED water lamp

Previous article:How to turn on and off total interrupt in stm32
Next article:TQ2440 FCLK, HCLK, PCLK, UCLK clock frequency settings

Recommended ReadingLatest update time:2024-11-16 15:21

U-Boot patch for S3C2440
# tar xvf u-boot-1.1.6.tar.bz2 //Decompression # cd u-boot-1.1.6/ Creating a patch file # diff -urN u-boot-1.1.6 u-boot-1.1.6.new u-boot-1.1.6_jz2440.patch Patch # patch -p1 u-boot-1.1.6_jz2440.patch p1: Ignore the content before the first "/" in the patch file (that is, as follows: u-boot-1.1.6) # head
[Microcontroller]
Transplantation of RT3070 on S3C2440 platform
1. Download the original driver from the official website http://www.ralinktech.com/en/04_support/license.php?sn=5016 and put the driver code in the directory /home/tango/code/linux-2.6.32.2/drivers/net/wireless/ Where /home/tango/code/linux-2.6.32.2 is the path to the linux2.6.32.2 kernel source code.
[Microcontroller]
S3C2440 development board practice (9): poll mechanism
Kernel: linux-2.6.22.6 The kernel executes the poll process From the code point of view, the poll mechanism is to call the poll() function through the application. The usage of the poll() function can be viewed through man poll. It can be rewritten in accordance with the final program. I will not repeat it here. It
[Microcontroller]
S3C2440 development board practice (9): poll mechanism
s3c2440 external interrupt
The hardware operation of s3c2440 is nothing more than configuration registers, and interrupts are no exception: Registers that need to be set: GPGCON: Pin configuration register, set to the second function, interrupt pin; EINTPEND: Interrupt pending register. When an interrupt occurs and is not masked, the corr
[Microcontroller]
s3c2440 external interrupt
IIS of s3c2440 (2) I2S audio bus learning - digital audio technology
IIS Audio Bus Learning (I) Digital Audio Technology 1. Basic Concepts of Sound     Sound is a continuous wave that propagates through a certain medium. Important indicators: Amplitude: The volume of the sound Period: The time interval between recurrences Frequency: refers to the number of times a signal changes
[Microcontroller]
S3C2440 startup code execution sequence
A table showing the execution order of the mini2440 startup code    
[Microcontroller]
S3C2440 startup code execution sequence
Use of S3C2440 NAND Flash
1. Basic knowledge NAND flash: fast speed, erase and write within 5ms; bit flip probability is relatively high, about 10%; large capacity, block capacity is more than 8K, erase and write times are high; interface is IO interface NOR flash: Slow speed, 5S erasing time; bit flip probability is lower than NAND flash; sma
[Microcontroller]
S3C2440 bare metal -------LCD_Abstract important structures
1.lcd.h We define a structure in lcd.h to represent the parameters required by the LCD. #ifndef _LCD_H #define _LCD_H     enum { NORMAL = 0, INVERT = 1, };   /* NORMAL : normal polarity  * INVERT : Invert polarity  */ typedef struct pins_polarity { int vclk; /* normal: get data on the falling edge*/ int rgb;
[Microcontroller]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号