完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
你好:
咨询一个问题:我用STM32H743IIT6芯片,STM32CubeIDE,使用FMC驱动NAND FLASH,NAND FLASH ID读取正常。但是有几个问题:
|
|
相关推荐
1个回答
|
|
这是我的测试代码:
void NAND_Erase_Chip(void){ HAL_StatusTypeDef err_code = HAL_OK; NAND_AddressTypeDef addr = {0}; for(uint16_t i = 0; i < nand_dev.block_totalnum; i++) { addr.Block = i; printf("Erase block %drn", i); err_code = HAL_NAND_Erase_Block( hnand1, addr); if(err_code) { printf("Erase %d block fail!! Error code is %drn", i, err_code); } }}uint8_t Test_Read_Page(uint16_t block_num, uint16_t page_num){ static uint8_t first_time_exe = 0; uint8_t *pbuf; uint8_t sta = 0; uint16_t i = 0; NAND_AddressTypeDef addr = {0}; addr.Block = block_num; addr.Page = page_num; printf("rn ========Read block %d page %d ========rn", block_num, page_num); if(first_time_exe == 0) {// printf("Start to erase chip...rn");// NAND_Erase_Chip();// printf("Erase chip finished...rn"); printf("Start to erase block %d...rn", block_num); sta = HAL_NAND_Erase_Block( hnand1, addr); if(sta) { printf("Erase block failed...rn"); } else { printf("Erase block finished...rn"); } first_time_exe = 1; NAND_Delay(100); } pbuf = My_Malloc(SRAM1, hnand1.Config.PageSize); sta = HAL_NAND_Read_Page_8b( hnand1, addr, pbuf, 1); if(sta == HAL_OK) { printf("read block %d page %d data is: rn", addr.Block, addr.Page); for(i = 0; i < hnand1.Config.PageSize; i++) { printf("%x ", pbuf); } printf("rn"); } My_Free(SRAM1, pbuf); return sta;}uint8_t Test_Write_Page(uint16_t block_num, uint16_t page_num){ uint8_t *pbuf; uint8_t sta = 0; uint16_t i = 0; NAND_AddressTypeDef addr = {0}; pbuf = My_Malloc(SRAM1, hnand1.Config.PageSize); addr.Block = block_num; addr.Page = page_num; for(i = 0; i < hnand1.Config.PageSize; i++) { pbuf = i; } printf("Start to write page...rn"); sta = HAL_NAND_Write_Page_8b( hnand1, addr, pbuf, 1); printf("Write page finished. Error code is %drn", sta); My_Free(SRAM1, pbuf); return sta;}void Test_Nand(void){ NAND_IDTypeDef pNAND_ID; HAL_NAND_Reset( hnand1); HAL_NAND_Read_ID( hnand1, pNAND_ID); printf("NAND ID is: 0x%x-%x-%x-%xrn", pNAND_ID.Maker_Id, pNAND_ID.Device_Id, pNAND_ID.Third_Id, pNAND_ID.Fourth_Id); Test_Read_Page(10, 10); Test_Write_Page(10, 10); printf("Read data again...rn"); Test_Read_Page(9, 9); Test_Read_Page(10, 10); Test_Read_Page(11, 11);} |
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
1339 浏览 0 评论
STM32配合可编程加密芯片SMEC88ST的防抄板加密方案设计
1162 浏览 0 评论
2602 浏览 1 评论
AD7686芯片不传输数据给STM32,但是手按住就会有数据。
2378 浏览 3 评论
5030 浏览 0 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-1-6 18:29 , Processed in 0.386651 second(s), Total 44, Slave 38 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号