First, let's take a look at the NANDFLASH interface:
As can be seen from the figure, there are only data ports and control ports, but no address lines, so it cannot be uniformly addressed like a network card or SDRAM. Its operation steps are as follows:
1 Enable chip
2 Send operation instructions (read, write, erase, reset)
3 Send operation address
5 Waiting for the busy signal to be released (read only)
6 Send data (write), receive data (read)
7 Waiting for busy signal, low level busy
8 Disable Chip
These control signal lines are all set by software registers, and then the hardware automatically generates control signals for other control lines;
The meanings of the operation signals are as follows:
R/B: Read/Busy status line
CE : Chip Select
CLE: Send command signal
ALE: Send address signal
WE: Write signal
RE: Read signal
Things to note here:
1 Data is transmitted in bytes, and there are exactly 8 data lines. The data register can be read directly to obtain data.
2 The address has 32 bits, but there are only 8-bit lines here, so an address needs to be sent multiple times to complete. For the sending rules, see the NANDFLASH chip manual, as shown below:
This chip needs to send the address in 4 cycles. The number of address lines depends on the size of the memory chip. When writing the driver, the address bits must be sent according to this table.
@******************************************************************************
@ File:head.s
@ Function: Set up SDRAM, copy the program to SDRAM, and then jump to SDRAM to continue execution
@******************************************************************************
.text
.global _start
_start:
@Functions disable_watch_dog, memsetup, init_nand, nand_read_ll are defined in init.c
ldr sp, =4096 @Set up the stack
bl disable_watch_dog @关WATCH DOG
bl memsetup @ Initialize SDRAM
bl nand_init @Initialize NAND Flash
@Copy the 1024-byte code starting at address 4096 in NAND Flash (compiled from main.c) to SDRAM
The @nand_read_ll function requires 3 parameters:
ldr r0, =0x30000000 @1. Target address = 0x30000000, which is the starting address of SDRAM
mov r1, #4096 @2. Source address = 4096. When linking, the code in main.c is stored at the beginning of NAND Flash address 4096.
mov r2, #1024 @3. Copy length = 1024 (bytes), which is enough for main.c of this experiment
bl nand_read @Call C function nand_read
ldr sp, =0x34000000 @Set up the stack
ldr lr, =halt_loop @Set the return address
ldr pc, =main @b instruction and bl instruction can only jump forward and backward within the range of 32M, so here we use the method of assigning value to pc to jump
halt_loop:
b halt_loop
Let's look at this startup code first. In order to use C language to set the watchdog and initialize SDRAM and other operations, you need to set the SP first, because the entry address and local variables of the C language function need to be stored in the stack.
After initialization, you can call the nandread function to read the NANDFLSH data. Here, you need to pass in three parameters. To pass parameters from assembly language to C language functions, you can only assign the parameters to R0-R4. Here, the first parameter corresponds to r0, and so on. The following code implements passing parameters to the nand_read function:
ldr r0, =0x30000000 @1. Target address = 0x30000000, which is the starting address of SDRAM
mov r1, #4096 @2. Source address = 4096. When linking, the code in main.c is stored at the beginning of NAND Flash address 4096.
mov r2, #1024 @3. Copy length = 1024 (bytes), which is enough for main.c of this experiment
bl nand_read @Call C function nand_read
Let's look at the prototype of nand_read:
void nand_read(unsigned char *buf, unsigned long start_addr, int size)
The first parameter needs to be an address, so the address passed in from the assembly is an address, and the LDR instruction is used to load the absolute address into r0
dr r0, =0x30000000 @1. Target address = 0x30000000, which is the starting address of SDRAM
The second and third parameters passed in are immediate values, which can be assigned directly using the following method
mov r1, #4096 @2. Source address = 4096. When linking, the code in main.c is stored at the beginning of NAND Flash address 4096.
mov r2, #1024 @3. Copy length = 1024 (bytes), which is enough for main.c of this experiment
Previous article:Study Notes --- S3C2440 memory device interface wiring and access principles
Next article:Study Notes --- S3C2440 DMA Operation Principle
Recommended ReadingLatest update time:2024-11-23 12:01
- 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
- Classic river crossing puzzle game
- How to Use Multimeter to Measure Ground Resistance
- Pirated copies are really hard on the eyes - do you feel the same?
- How to modify this H-bridge motor drive circuit so that the MOS tubes of the upper and lower bridge arms will not be turned on at the same time
- New Year's treasure hunt, Tektronix gives you benefits! Come and start your treasure hunt! The event has begun~
- Protel shortcut keys classic!!!
- How to achieve multi-point control of field effect tube electronic switches
- my country's mobile TV business is in the exploratory stage
- Extremely smooth OLED scrolling display
- What? Microsoft deliberately lets you install pirated software!