TX2440 bare metal program - LED

Publisher:不见南师久Latest update time:2019-11-25 Source: eefocusKeywords:TX2440 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1. GPIO Description


GPIO (General Purpose I/O ports) is a general purpose input/output port. In practical applications, whether it is connecting an LCD, connecting a keyboard, controlling a running light, etc., it is inseparable from the operation of I/O. It can be said that GPIO operation is the basis of all hardware operations.


S3C2440 has 130 I/O ports, divided into nine groups: GPA, GPB, ..., GPJ. We can operate these IOs through registers. S3C2440 has three registers: GPxCON, GPxDAT, and GPxUP. GPxCON is used to select pin functions; GPxDAT is used to read/write pin data; GPxUp is used to determine whether to use internal pull-up resistors. It should be noted that Group A does not have a GPAUP register, that is, Group A I/O ports do not have a pull-up resistor selection function


1、GPxCON


The GPxCON of the A group I/O port is special. Each bit in GPACON corresponds to a pin (a total of 23 pins). When a bit is set to 0, the corresponding pin is an output pin. Otherwise, the corresponding pin is an address line or used for address control. In this case, GPADAT is useless.


The I/O of Group B to Group J are identical in register operation. Every two bits in GPxCON control one pin: 00 indicates input, 01 indicates output, 10 indicates special function, and 11 is reserved.


2、GPxDAT


GPxDAT is used to read/write pin data: when the pin is set to output, writing the corresponding bit of its register can make the pin output high or low level; when the pin is set to input, reading the corresponding bit of this register can determine whether the level state of the pin is high or low.


3、GPxUP


GPxUP is used to set whether the corresponding pin uses a pull-up resistor. When a bit is 0, a pull-up resistor is used; when a bit is 1, a pull-up resistor is not used.


2. Development Environment


IDE environment: ADS1.2


Development board: TX2440


Hardware wiring diagram:

LED1---GPF0, common anode connection, to light up the LED, just give the corresponding low level.

LED2---GPF1

LED3---GPF2

LED4---GPF3

3. Source code and analysis


//======================================================================

// Project name: LED.mcp

// Function description: Use GPIO to control four LEDs

// IDE environment: ADS v1.2

// Component file: main.c

//======================================================================

//====================================================

// Include header file area

//====================================================

#include "2440addr.h"

#include "2440lib.h"

#include "option.h"

#include "def.h"

#include "uart.h"

 

 

#define LED1ON 0xFE //LED1 lighting value is 0xFE (low level lighting)

#define LED2ON (LED1ON<<1) //LED2 lighting value is LED1 shifted left by 1 bit

#define LED3ON (LED1ON<<2) //LED3 light value is LED2 shifted left by 1 bit

#define LED4ON (LED1ON<<3) //LED4 lighting value is LED3 shifted left by 1 bit

 

extern unsigned int PCLK;

 

void usDelay(unsigned long time)

{

U32 i,j;

for (i = time; i > 0; i--)

for (j = 50; j > 0; j--);

}

 

void Main(void)

{

   rGPFCON = (rGPFCON | 0xFFFF) & 0xFFFFFF55; //GPF0--GPF3 are set to output       

   rGPFUP  =  0xFFFF;

   rGPFDAT = 0x0F; //GPF lower 4 bits are initialized to 1

   while(1)

    {

          

    rGPFDAT = LED1ON; //Turn on LED1

        usDelay(10000);

       

      

        rGPFDAT = LED2ON; //Turn on LED2

         usDelay(10000);

      

        rGPFDAT = LED3ON; //Turn on LED3

        usDelay(10000);

             

         rGPFDAT = LED4ON; //Turn on LED4   

         usDelay(10000);       

    }

}

Test result: LED1--4 light up in sequence, all go out, and then light up in sequence.

Keywords:TX2440 Reference address:TX2440 bare metal program - LED

Previous article:TX2440 Bare Metal Clock-PWM
Next article:s3c2440 NAND and NOR boot methods detailed explanation + personal verification

Recommended ReadingLatest update time:2024-11-16 09:00

51 MCU controls LED lights through WIFI module ESP8266
1. System Solution The mobile phone APP controls the switch of the LED light through the ESP8266 WIFI module and the 51 single-chip microcomputer. The lower computer is composed of the single-chip microcomputer, ESP8266 module and LED light, and the upper computer is the Android mobile phone APP. We send the switch
[Microcontroller]
51 MCU controls LED lights through WIFI module ESP8266
The Mini LED TV market is about to explode, is OLED TV in danger?
After Skyworth officially released the MiniLED backlit TV, another TV manufacturer has launched a new MiniLED backlit TV. Recently, Samsung officially launched the MiniLED backlit LCD TV - Neo QLED TV, and TCL Electronics and LG Electronics are also preparing to release OD ZeroTM Mini LED backlit TV and QNED TV. In 20
[Mobile phone portable]
How to use microcontroller LED light-emitting diode to display "love"
1. Hardware diagram 2. Components list 4. Procedure (reference) #include reg51.h void delay(unsigned int k); void main() { unsigned char i,j,h,y,w,e,t,s; while(1) { w=0x80; e=0x01; t=0x00; s=0xff; for(i=0;i 3;i++) { if (i 1) { for (j=0;j 8;j++) { P1=w; P3=t; w =1; delay(200); } } else if
[Microcontroller]
How to use microcontroller LED light-emitting diode to display
Explanation of the onboard LED light control program based on the STC15W series
Preface Hello, everyone. I am a beginner of STC15W series microcontrollers. I am very happy to share my learning experience with you on this platform. Now let’s get back to the topic. Let’s start learning about the STC15W4K56S4 microcontroller! 1. Introduction to STC15W4K56S4 MCU    This study is based on the S
[Microcontroller]
Explanation of the onboard LED light control program based on the STC15W series
GEC210 led water lamp C language to achieve ADS engineering
Software environment: ADS1.2 Development board: GEC210 Theoretical knowledge: Refer to the introduction of LED principle Because ADS needs to be entered from assembly by default, our code first calls a short assembly and then jumps directly to C language The source code is as follows led.c #define GPJ2CON (*
[Microcontroller]
GEC210 led water lamp C language to achieve ADS engineering
Comprehensive analysis of the LED dimming system circuit of STC89C52 microcontroller
Abstract: After the field effect transistor is turned off, the cathode voltage of the LED increases, causing the LED to turn off. When the field effect transistor is turned on, the cathode voltage of the LED is pulled low, causing the LED to emit light. The PWM adjustment method makes the drive circuit simpler and red
[Microcontroller]
Comprehensive analysis of the LED dimming system circuit of STC89C52 microcontroller
Single chip microcomputer stepper motor speed control program (speed LED display)
The microcontroller source program is as follows: //Digital tube high position------low position //Four buttons to control the stepper motor: forward, reverse, plus 1, minus 1 //When the power is on, the motor starts, and the digital tube displays the minimum speed gear 1. The plus and minus gears can be displayed th
[Microcontroller]
Single chip microcomputer stepper motor speed control program (speed LED display)
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号