-
FMC_Erase擦除错误
请问大家,为什么FMC_Erase返回总是-1,主函数中PE0,PE1,PE2是我的三个按键,我主要是想实验对flash的擦写,将数据存到flash中,实现掉电数据不丢失,但现在一个插除页都是失败的,还请大家解惑。#include#include"Nano100Series.h"#defineDATA_FLASH_TEST_BASE0x12400;int32_tu32Addr=DATA_FLASH_TEST_BASE;uint32_tu32Pattern=0xA5A5A5A5;uint32_tu32data;voiddataflash_test(){SYS_UnlockReg();FMC_Open();FMC_Erase(u32Addr);if(FMC_Erase(u32Addr)==-1){printf("erase--error\r\n");}FMC_Write(u32Addr,u32Pattern);u32data=FMC_Read(u32Addr);if(u32data!=u32Pattern){printf("datadifferent");}printf("one--u32pattern--%x\r\n",u32Pattern);printf("one--dihzi--%x\r\n",&u32Addr);printf("one--u32data--%x\r\n",u32data);printf("one--dizhi--%x\r\n",&u32data);FMC_Write(u32Addr+4,u32Pattern);u32data=FMC_Read(u32Addr+4);if(u32data!=u32Pattern){printf("dataerror-----u32addr+4\r\n");}printf("two----%x----u32pattern\r\n",u32Pattern);printf("two----%x----dizhi\r\n",&u32Addr);printf("two----%x----u32data\r\n",u32data);printf("two----%x----dizhi\r\n",&u32data);SYS_LockReg();}voiddataflash_test_read(){u32data=FMC_Read(u32Addr);printf("one--u32data--%x\r\n",&u32Addr);printf("one--u32data--%x\r\n",&u32data);}voidSYS_Init(void){SYS_UnlockReg();CLK_EnableXtalRC(CLK_PWRCTL_HIRC_EN_Msk);CLK_WaitClockReady(CLK_CLKSTATUS_HIRC_STB_Msk);CLK_SetHCLK(CLK_CLKSEL0_HCLK_S_HIRC,CLK_HCLK_CLK_DIVIDER(1));CLK_EnableModuleClock(UART0_MODULE);CLK_SetModuleClock(UART0_MODULE,CLK_CLKSEL1_UART_S_HIRC,CLK_UART_CLK_DIVIDER(1));SystemCoreClockUpdate();SYS->PA_H_MFP&=~(SYS_PA_H_MFP_PA14_MFP_Msk|SYS_PA_H_MFP_PA15_MFP_Msk);SYS->PA_H_MFP|=(SYS_PA_H_MFP_PA14_MFP_U
2021-10-22 4