我根据官方例程修改的,测试时全部写入20,但读出来为0,应该是写入进去了。查了几遍没查到错误,麻烦帮我看一眼。 void FLASH_Eraser() { /* Clear pending flags (if any) */ FLASH_ClearFlag(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR|FLASH_FLAG_PGSERR); /* Get the number of the start and end sectors */ StartSector = GetSector(FLASH_USER_START_ADDR); EndSector = GetSector(FLASH_USER_END_ADDR); for (SectorCounter = StartSector; SectorCounter < EndSector; SectorCounter += 8) { /* Device voltage range supposed to be [2.7V to 3.6V], the operation will be done by word */ if (FLASH_EraseSector(SectorCounter, VoltageRange_3) != FLASH_COMPLETE) { /* Error occurred while sector erase. User can add here some code to deal with this error */ while (1); } } } void FLASH_Write(aCm *Buf) { tPriint32 Value=20; // float * Ptr=(float*)Buf; FLASH_Unlock(); FLASH_Eraser(); Address = FLASH_USER_START_ADDR; while (Address < FLASH_USER_END_ADDR) { if (FLASH_ProgramWord(Address,Value) == FLASH_COMPLETE) { Address = Address + 4; } else { while (1); } } FLASH_Lock(); } tPriint32 data32=5; void FLASH_Read(aCm *Buf) { tPriint32 *Ptr=(tPriint32*)Buf; Address = FLASH_USER_START_ADDR; while (Address < FLASH_USER_END_ADDR) { data32 = *(__IO uint32_t*)Address; Address = Address + 4; } } 程序写入时没有停在while(1)处,说明已经写入进去了,但不知道为什么读出来是0 |
char* ptr = NULL
ptr = ADD_START
循环体
printf(%x\n, *ptr);
ptr++;
这是基本思路,你可以参考参考
请教一下,用JLINK把FLASH整体读出来是什么意思?我说的读出全部为0,就是debug下读取到的
不是我不愿回答这个问题,你对这一块了解的太少,我无从回答起。但我还是简单的说两句。你软件擦写FLASH,你自己是知道FLASH哪个地址的数据发生改变,打开SEGGER软件,点击target菜单里面的read back里面的entire chip。读出F4的FLASH里面所有内容,你在找到文件中相应位置对比一下看看值有没有改变。
十分感谢。我试一下