S3C2440 bare metal review ------ GPIO

Publisher:760802csyLatest update time:2022-01-25 Source: eefocusKeywords:S3C2440 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

After reading the S3C2440 bare metal for the first time, I have forgotten some of them, so I will select a few to review, starting with GPIO.


1 Schematic

First, we need to look at the schematic diagram. We can see that we can light up LED1 by setting GPF4 to a low level.

 

2 Chip Manual

From the chip manual, we can see that we need to set [9:8] of the GPFCON register to 01, and then set [4] of the GPFDAC to 0.


3 Assembly language lights up LED

3.1 start.S

.test

 

.global _start

    mov 0x56000050 #0x100

    mov ox56000054 #0x10

 

.halt

    b halt

 3.2 Makefile

all:

arm-linux-gcc -c start.S -o start.o

arm-linux-ld -Ttext 0 start.o -o start.elf

arm-linux-objcopy -O binary -S start.elf start.binary

clean:

rm *.bin *.o *.elf

3.3 Compile and debug

Compilation found various errors

 Text is written as test, "halt:" is written as ".halt". And the mov assignment is also wrong.


The modified start.S is as follows


.text

 

.global _start

 

    /*Configure GPF4 as output*/

    ldr r0,=0x56000050

    ldr r1, =0x100

    str r1,[r0]

 

    /*Configure GPF4 to output low level*/

    ldr r0,=0x56000054

    ldr r1, =0xff

    str r1,[r0]

 

halt:

    b halt

 

4 C language lights up LED

Next, use C language to light up the LED, and add the code to close the door, and set the stack to support both nandflash startup and norflash startup.


First modify start.S


.text

 

.global _start

 

    /*turn off watchdog*/

    ldr r0, =0x53000000

    ldr r1, =0x0

    str r1,[r0]

 

    /*Set up the stack,

    Write 0 to address 0, and then read it out. If 0 is obtained, it means that the content at address 0 has been modified, then NOR is started.

    Otherwise, nand starts*/

 

    mov r1, #0

    ldr r0, [r1] /*Read out the original value backup*/

    str r1, [r1]

    ldr r2,[r1]

    cmp r1,r2

    ldr sp,=0x40000000+4096 /*Assume that nand is started*/

    moveq sp,#4096

    streq r0,[r1] /*Restore the original value*/

 

    bl main

 

halt:

    b halt

 

Then led.c


#include "s3c2440_soc.h"

 

void delay(volatile int d)

{

while (d--);

}

 

/*Loop to light up the LED*/

int main(){

    

    int val = 0;

    int temp = 0;

 

    /*First configure GPIO as output*/

    GPFCON &= ~((3<<8) | (3<<10) | (3<<12)); // Clear

    GPFCON |= ((1<<8) | (1<<10) | (1<<12));

    while(1){

        temp = ~val; //We want all three lights to be off when the value is 0, but they are actually on when the level is low, so we invert it.

        temp &= 7; //We only care about three bits, and ignore the other bits.

        GPFDAT &= ~(7<<4); // clear to zero first

        GPFDAT |= (temp<<4);

        delay(100000);

        val++;

        if(8 == val)

            val =0;

    }

}

Keywords:S3C2440 Reference address:S3C2440 bare metal review ------ GPIO

Previous article:How to burn the system of Xunwei 6818 development board
Next article:S3C2440 bare metal -------SPI_FLASH programming

Recommended ReadingLatest update time:2024-11-23 02:42

S3C2440 clock system
The default working main frequency of S3C2440 is 12MHz and 16.9344MHz, which is the frequency of our crystal oscillator. However, 12MHz crystal oscillator is more commonly used. Fin refers to the frequency of the crystal oscillator we connect. As we all know, the frequency of S3C2440 after power-on and normal operation
[Microcontroller]
S3C2440 clock system
Design of ECG monitor based on Linux and MCU
  As people's pace of life accelerates and the population gradually ages, heart disease has become one of the major diseases that endanger human health and life. The ECG monitoring system provides an effective means for the diagnosis and treatment of heart disease patients, and is of great significance to the preventi
[Microcontroller]
Design of ECG monitor based on Linux and MCU
S3C2440 Development Board Bare Metal Program Series 03 - Timer
1. S3C244 clock system Keywords related to clock: Fin – external input crystal frequency, TQ2440 external crystal frequency is 12MHz; FCLK – for CPU core, i.e. the frequency of CPU core; HCLK – used for devices on the AHB (Advanced High Performance Bus) bus, including memory controllers, LCD controllers, DMA, etc.
[Microcontroller]
S3C2440 Development Board Bare Metal Program Series 03 - Timer
S3C2440 clock system notes
1. Overall Architecture The main clock source of S3C2440 can be an external resonator (XTIpll) or an external input clock (EXTCLK), which generates a high-frequency clock signal through the phase-locked loop MPLL and UPLL, and is distributed and transmitted to the AHB bus, APB bus, USB device, and kernel. Among
[Microcontroller]
S3C2440 clock system notes
ARM History 4 - LCD
    It has been 10 days since I last wrote about my journey. It was the National Day holiday, so I gave myself a few days off - I played some games, chess, etc.     In fact, it took a lot of time and brainpower to write the touch screen driver and understand the interrupt process in ARM. I will simply share the cond
[Microcontroller]
cortex m0 lpc1114 gpio output function
GPIO is a must-have function for every microcontroller. The operation of the microcontroller and the peripheral circuits is mostly controlled by GPIO. To learn any new microcontroller, you need to learn how to control the pin level and read the level. Commonly used communication protocols such as I2C and SPI can be si
[Microcontroller]
cortex m0 lpc1114 gpio output function
STm32 uses stm32cube GPIO to light up the LED
1. API Description The HAL library contains a total of 6 IO operation functions:  1. Read the level status of a pin:  HAL_GPIO_ReadPin()  2. Write the level status of a pin:  HAL_GPIO_WritePin()  3. Flip the level status of a pin:  HAL_GPIO_TogglePin()  4. Lock the configuration status of a pin (until the next reset):
[Microcontroller]
STm32 uses stm32cube GPIO to light up the LED
Design of free swing plate control system based on S3C2440 and acceleration sensor
The focus of this design is to collect the angle information of each joint through the acceleration sensor MMA7455, and control the operation of the stepper motor according to the obtained angle value and task requirements, complete the adjustment of the attitude of the flat plate at the end of the free swing arm, and
[Microcontroller]
Design of free swing plate control system based on S3C2440 and acceleration sensor
Latest Microcontroller Articles
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号