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;
}
}
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
- Naxin Micro and Xinxian jointly launched the NS800RT series of real-time control MCUs
- How to learn embedded systems based on ARM platform
- Summary of jffs2_scan_eraseblock issues
- Application of SPCOMM Control in Serial Communication of Delphi7.0
- Using TComm component to realize serial communication in Delphi environment
- Bar chart code for embedded development practices
- Embedded Development Learning (10)
- Embedded Development Learning (8)
- Embedded Development Learning (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
- STMicroelectronics discloses its 2027-2028 financial model and path to achieve its 2030 goals
- 2024 China Automotive Charging and Battery Swapping Ecosystem Conference held in Taiyuan
- State-owned enterprises team up to invest in solid-state battery giant
- The evolution of electronic and electrical architecture is accelerating
- The first! National Automotive Chip Quality Inspection Center established
- BYD releases self-developed automotive chip using 4nm process, with a running score of up to 1.15 million
- GEODNET launches GEO-PULSE, a car GPS navigation device
- Should Chinese car companies develop their own high-computing chips?
- Infineon and Siemens combine embedded automotive software platform with microcontrollers to provide the necessary functions for next-generation SDVs
- Continental launches invisible biometric sensor display to monitor passengers' vital signs
- Introduction to the method of board-level online compilation and downloading of C6000 DSP code
- Design of a dual DSP motor control digital platform
- Cadence Circuit Design Case Analysis
- Tiny technology, global impact: Breakthrough TI BAW resonator technology creates a new electronic heartbeat
- Automotive Distributed Safety System Based on FlexRay Network
- Could you please tell me which manufacturers produce magnetic resistance switches? I only found one.
- Verilog Golden Reference Guide Chinese version.pdf
- ais328dq three-axis acceleration sensor package and code
- [ART-Pi Evaluation] V: ATT-Pi WiFi networking and MQTT publishing and subscription evaluation in RTT Studio environment
- A chart to understand China Telecom's "5G SA Deployment Guide"