NAND Flash (k9f5608) Driver Programming

Source: Internet
Author: User
NAND Flash (k9f5608) Driver Programming
1. NAND Flash pins
The important ones of NAND Flash are as follows:
I/O pin: For this flash chip I/O pin, there are 8 0-7, and some chips have 16 0-15
CLE: instruction transmission enabling (the instruction can be locked in the instruction register of nand flash)
Ale: Address Transmission enabling (the address can be locked in the Address Register of nand flash)
CE: Slice selection, low efficiency
2. NAND Flash Control
Nand
Flash is controlled by transmitting data to I/O. There are two types of data to be transmitted: one is the command to be transmitted first, and the other is the address to be transmitted later.

3. k9f5608 Address Transmission
K9f5608 is a 32 MB 8-bit Nand
Flash chip. Three cycles are required to transmit the address to NAND through I/O
Flash chip.
First, let's take a look at the storage layout. The bottom layer is the page, which consists of a 512-byte data block and a 16-byte OOB block. The data block is used to store data, and the OOB block is used to store the flash page information. The middle layer is a block, which consists of 32 pages. The top layer is a device, which consists of 2048 blocks.

Next we will describe its address transmission. We have mentioned that it needs to be transferred in multiple cycles.
First, the offset of the transfer page: the inner offset of the bottommost page. The size of a page is 512 bytes, so the maximum value is 511.

The following transfer page address is sent in three cycles
0-7 characters of the 1st periodic transmission page addresses.
The 9-16 bits of the 2nd Periodic transmission page addresses.
17-24 characters of the 3rd Periodic transmission page addresses.
It should be noted that the 8th bits are determined by the instruction and do not need to be transmitted. For details, refer to the instruction transmission instructions below.

4. k9f5608 Command Transmission
The k9f5608 instruction set contains 12 commands. For details, refer to the chip description. Here is just a summary.

Commands can be divided into one period and two periods. One cycle only needs to be transferred once, and two cycles need to be transferred twice.

For example, page
The program command has two cycles. To implement the function of this command, we first transmit 80 h and then 10 h. Because I/O is 8 bits.

For another example, the reset command has one cycle and only needs to transmit FFH.
Here we will focus on the read1 and read2 commands. Read1 is a one-cycle instruction, but there are two instructions: 00h and 01 and. For k9f5608 with a page size of 512 bytes, the 8-bit addressing space is 256. Therefore, we use 256 h to address the first 256 bytes of space, and h to address the last bytes. In this way, it corresponds to the first 8th bytes transmitted by the previous page address. If it is the first 256 bytes space, it is set to 0 automatically. If it is the last 256 bytes space, it is set to 1 automatically. Therefore, the 8th-bit page address is determined by the instruction and does not need to be transmitted. Read2 is a one-cycle instruction used to read OOB. Other commands are relatively simple. You just need to check the corresponding manual.

5. Driving programming ideas
Based on the above analysis, driver programming involves the following points:
(1) to implement the Read and Write Functions, you must first transmit the instruction and then transmit the address, write the data in Buf to flash, or read the data in flash into Buf. If ECC is defined here, read2 is used to read OOB. OOB records ECC information. For more information, see the manual.

(2) due to some Nand
The size of the flash chip page is 256, and some pages are 512. Therefore, make a judgment before running the command.
(3) The functions of read1 and read2 are not only to read data. After reading the data, it points the pointer to the first byte of the region.
When running commands such as program, run the READ command to let the pointer point to the first byte in the region.

This is so much for the time being that it is annoying to see others. :)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.