Question analysis of a universal NandFlash module suitable for STM32 and FPGA timing verification.
Different manufacturers of Nand have different brands and different processes. The stacking forms of their internal memories are very different. Traditional hardware development needs to complete the solution design work first, but the diversity of Nand will give follow-up projects Difficulties arise in software writing. In order to verify whether the timing or storage method and storage structure are suitable for this project, we designed and completed a solution verification board for testing Nands from different manufacturers, and used the commonly used Samsung and the unpopular STMicroelectronics. Nand takes it as an example to briefly explain the timing and some problems encountered in programming, and provide a feasible solution for embedded engineers in subsequent designs.
Figure 1 ST NAND structure.
Different NAND capacities and block numbers are different. For each NAND, you need to check its structure and perform programming
schematic design instructions.
The circuit diagram of the verification board is relatively simple, and it mainly leads out the functional pins of the chip.
Figure 2 Schematic diagram of the verification version of the solution.
In the verification board, U1 is a TSSOP-48 packaged Nand. The Nand function pins in this package are all the same, so each Nand on the verification version can be replaced with each other. In the development board containing Nand In order to ensure the stability of the storage function, more filter capacitors and pull-up and pull-down resistors are used. In order to consider the compatibility with STM32 and FPGA boards, this verification version reduces the pull-up and pull-down resistors. If necessary, it can be configured in STM32GPIO. On the right side is a 2x10PIN 2.54mm socket, used to bring out the function pins, and D1 is the power indicator light. The typical value of VCC in the circuit depends on the chip selection. The commonly used one is 3.3V. The low-voltage Nand chip uses 1.6V for power supply.
Figure 3 ST Nand bought from Lichuang Mall.
This Nand is a popular Nand and is difficult to buy. The model purchased this time is ST NAND02GW3B2DN6E. The chip has 2G bit storage space. Of course, it can also be replaced with NAND from other manufacturers, such as Micron, Samsung, etc., 1G-8G bit meets the storage needs of daily projects. For larger storage needs, you can consider SD cards, or faster EMMC. For smaller storage needs, you can consider NOR Flash, such as W25Q128, W25Q256, etc., which have more reliable data. The difference between the two will not be described in detail.
PCB design description
Figure 4 PCB proofing picture
Figure 5 Board drawn by Lichuang EDA
I have to say that EDA software is very easy to use. It is especially friendly for wiring and device selection. It can provide a friendly interface and simple design process for novices. For those of us For experienced engineers, it reduces the time required to find device packages and greatly improves the efficiency of design. From schematics to PCBs and spare parts, all in one stop, shortening product iteration time.
There is not much to say about the board, double-sided, copper ground, 30mil power cord.
Software description
Figure 6. The FMC controller of STM32CubeMX
uses ST’s official FMC controller, which makes programming much simpler. Controlling NAND does not require contact with the underlying NAND timing. Just write the storage structure and logic. Just follow the wiring on CUBE to test the nand function. The complete code is attached. Code block:
if(Trans_flag==0) //Ä£ÄâÕýÏÒ²¨²úÉú { Sine();// for(i=0;i<2048 ;i++)// RxBuffer[i]=0XAA; Trans_flag=1; } else if(Trans_flag==1) //¿ block_temp [1]=WriteReadAddr.Block/100%10+48; block_temp[2]=WriteReadAddr.Block/10%10+48; block_temp[3]=WriteReadAddr.Block%10+48; HAL_UART_Transmit(&huart1,block_temp,4,500) ; } Trans_flag=0; if(++WriteReadAddr.Page>63) //дÈëÒ³×Ô¼Ó { WriteReadAddr.Page=0; WriteReadAddr.Block=WriteReadAddr.Block+1; if(WriteReadAddr.Block>1020) { Trans_flag =5; HAL_UART_Transmit(&huart1,text1,12,500); //дÈëÍ£Ö¹ } } } else if(Trans_flag==2) //¿ ªÊ¼¶ÔNand¶ÁÈ¡ { if(First_data==0) //»Ö¸´³õʼµØÖ· { First_data=1; WriteReadAddr.Block=0; WriteReadAddr.Page=0; WriteReadAddr.Plane=1; }
HAL_NAND_Read_Page_8b(&hnand1,&WriteReadAddr,RxBuffer_u8,1); //¶Ánand// HAL_UART_Transmit(&huart1,text7,12,500);// page_temp[0]=WriteReadAddr.Page/10+48;// page_temp[1]=WriteReadAddr. Page%10+48;// HAL_UART_Transmit(&huart1,page_temp,2,500);// HAL_UART_Transmit(&huart1,text3,13,500);
if(WriteReadAddr.Block%30==0&&WriteReadAddr.Page==0) { block_temp[0]= WriteReadAddr.Block/100%10+48; block_temp[1]=WriteReadAddr.Block/10%10+48; block_temp[2]=WriteReadAddr.Block%10+48; HAL_UART_Transmit(&huart1,block_temp,3,500); }
USBD_CUSTOM_HID_SendReport( &hUsbDeviceFS,RxBuffer_u8,2048); //USB·¢ËÍ// HAL_UART_Transmit(&huart1,RxBuffer_u8,2048,500); if(++WriteReadAddr.Page>64) //µØÖ·×Ô¼Ó { WriteReadAddr.Page=0; WriteReadAddr .Block=WriteReadAddr.Block+1; if(WriteReadAddr.Block>1020) { Trans_flag=5; HAL_UART_Transmit(&huart1,text1,12,500); } } }
else if(Trans_flag==3) //²Á³ýNand FlashËùÓп é { HAL_UART_Transmit(&huart1,text4,13,500); for(j=0;j<1020;j++) { WriteReadAddr.Block=j; HAL_NAND_Erase_Block(&hnand1,&WriteReadAddr); } Trans_flag=5; HAL_UART_Transmit(&huart1,text4,13,500) ; WriteReadAddr.Block=0; WriteReadAddr.Page=0; WriteReadAddr.Plane=1;
}
Realize the functions of erasing, writing and reading Nand in each part.
Physical demonstration illustrates
the chip resistors, capacitors and power supply of 1206 The indicator light
Nand Flash verification board is connected to the STM32F103 core board of Zhengdian Atom (the white light of the welding is too bright without a current limiting resistor)