In fact, configuring a module often requires the following steps:
(1) According to the schematic diagram, clarify the wiring method of the module. For Nand flash, just check which GPIO the Nand flash is connected to, and then configure the corresponding GPIO as Nand function.
(2) Read the S5PV210 manual to understand the functions, operation methods, and register configurations of the relevant module controllers.
(3) Read the module chip manual and understand the module’s access control timing.
We follow the above steps to configure. First, the module GPIO configuration. My development board is TQ210, the Nand flash chip is K9K8G08U0B, and the wiring method is as follows:
in:
(1) The eight pins Xm0FRnB0~Xm0FRnB3, Xm0FCLE, Xm0FALE, Xm0FWEn, and Xm0FREn are connected to MP0_3. By checking the MP0_3 control register, we can see that MP0_3CON needs to be configured to 0x22222222;
(2) The four pins Xm0CSn2~Xm0CSn5 are connected to the 2~5 pins of MP0_1, so the 8~23 bits of MP0_1CON should be configured as 0x3333;
(3) The eight pins Xm0DATA0~Xm0DATA7 are connected to MP0_6, so MP0_6 should be configured as 0x22222222;
In this way, the GPIO is configured. Next, we configure the control register of Nand flash. After a general review of the register functions of Nand flash, we can find that if the ECC function is not used, only the NFCONF and NFCONT registers can be configured. Our Nand flash is an SLC type Nand with a Page size of 2048. It takes 5 cycles to write the address (these can be easily found in the Nand flash chip manual), so NFCONF should be configured as follows:
NFCONF=(3<<23)|(1<<12)|(2<<8)|(0<<4)|(1<<1); // In order: disable ECC, TACLS, TWPRH0, TWPRH1, SLC, 2K, 5 cycles.
Among them, TACLS, TWPRH0 and TWPRH1 need to be determined by reading the manual. Teacher Wei Dongshan explained the determination method. However, when I configured it completely according to the minimum time setting in the manual, I was not able to access it normally. I tried it myself. First, I set all three parameters to 7, then slowly reduced them, and finally tested them to be set to 1, 2, and 0. However, this is not necessarily the most stable. Generally speaking, a slightly larger value will be more stable, but in order not to affect the access efficiency, this value cannot be set too large. Set it according to the minimum situation first, and then appropriately increase the parameter value when a read error or other unstable phenomenon is found.
Then there is the NFCONT register. The configuration of NFCONT is even simpler. We do not set ECC, but only need to set bits 0 and 1:
NFCONT = (1<<1)|(1<<0); //Disable chip select and enable Nand
In this way, the initialization function of Nand flash comes out:
- void nand_init(){
- NFCONF = (3<<23)|(1<<12)|(2<<8)|(0<<4)|(1<<1);
- NFCONT = (1<<0)|(1<<1);
- MP0_1CON &= ~(0xffff<<8);
- MP0_1CON |= 0x3333<<8;
- MP0_3CON = 0x22222222;
- MP0_6CON = 0x22222222;
- nand_reset();
- }
In this way, Nand flash is initialized. However, to access Nand flash, it is necessary to operate it according to the timing. When Nand mode is started, only the read operation of Nand flash needs to be implemented. For this reason, only a few read-related operations are listed here:
(1) Nand flash reset
- static void nand_reset(){
- nand_select_chip();
- nand_cmd(0xff);
- nand_wait();
- nand_deselect_chip();
- }
- static void nand_addr(unsigned long page_addr, unsigned long page_offset){
- NFADDR = (page_offset>>0) & 0xFF;
- NFADDR = (page_offset>>8) & 0x7;
- NFADDR = (page_addr) & 0xFF;
- NFADDR = (page_addr>>8) & 0xFF;
- NFADDR = (page_addr>>16) & 0x07;
- }
- void nand_read_id(char id[]){
- int i;
- nand_select_chip();
- nand_cmd(0x90);
- NFADDR = 0;
- for (i = 0; i < 5; i++)
- id[i] = nand_read();
- nand_deselect_chip();
- }
- void nand_read_page(unsigned char* buf, unsigned long page_addr){
- int i;
- nand_select_chip();
- nand_cmd(0);
- nand_addr(page_addr, 0);
- nand_cmd(0x30);
- nand_wait();
- for(i = 0; i != PAGE_SIZE; ++i){
- *buf++ = nand_read();
- }
- nand_deselect_chip();
- }
The above are several important Nand flash read-related operation functions. At this point, you can add the referenced small functions to perform Nand flash operations normally. I uploaded the code I wrote to my CSDN resources, and you can refer to it if you need it. In addition, if you need to write Nand flash write operation code, you can refer to the 6410 Nand flash configuration part in my blog and the Nand flash chip manual. The principles are the same.
Previous article:S5PV210 (TQ210) study notes - kernel transplantation and file system construction
Next article:S5PV210 (TQ210) study notes - memory configuration (DDR2)
Recommended ReadingLatest update time:2024-11-16 15:30
- Popular Resources
- Popular amplifiers
- Android embedded system program development (based on Cortex-A8)
- Detailed explanation of embedded Linux software and hardware development based on S5PV210 processor
- Embedded system development tips, a novice\'s growth log and a project manager\'s recipe
- Detailed explanation of embedded Linux software and hardware development based on S5PV210 processor
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Problems encountered during ads2020 installation
- RF power testing is that simple when explained thoroughly!
- How to import pictures in AD19 version and run script software crash
- JD642 SDRAM bus matching pre-simulation and pcb download
- [STM32WB55 Review] 6# Use of STM32WB development board UART
- [New Year's Taste Competition] + New Year's Eve dinner + New Year's 7 days of fun, I wish you all a prosperous New Year, smooth sailing and a good start.
- Sell TI POS Kit Chip
- cc2530 zigbee-zha modification supports serial port 1 position 1 P0_4 P0_5
- EEWORLD University ---- Learn myRIO with me
- Classic MATLAB simulation model for parameter identification of three-phase asynchronous motor