本帖最后由 vvhhbc1 于 2015-11-22 21:45 编辑 stm32f030c8 内部flash空间区域为: 0x8000000 ~ 0x8001000 我的页定义为: #define PAGE_SIZE (uint16_t)0x400 /* Page size = 1KByte */ #define EEPROM_START_ADDRESS ((uint32_t)0x0800f400) /* Pages 0 and 1 base and end addresses */ #define PAGE0_BASE_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + 0x000)) #define PAGE0_END_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + (PAGE_SIZE - 1))) #define PAGE1_BASE_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + PAGE_SIZE)) #define PAGE1_END_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + (2 * PAGE_SIZE - 1))) 初始化时, 去对页0写VALID_PAGE标志: HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD, PAGE0_BASE_ADDRESS, VALID_PAGE); 最终是调用下面接口, 在地址0x0800f400处写入VALID_PAGE, static void FLASH_Program_HalfWord(uint32_t Address, uint16_t Data) { /* Clean the error context */ pFlash.ErrorCode = HAL_FLASH_ERROR_NONE; /* Proceed to program the new data */ SET_BIT(FLASH->CR, FLASH_CR_PG); /* Write data in the address */ *(__IO uint16_t*)Address = Data; //////////////////这里, 写无效////////////////////// } 请问为什么会写入无效呢??? 盼用的朋友能指点迷津, 谢谢!!!!!!! |
Flash_Program.rar
2015-11-19 14:05 上传
点击文件名下载附件
下载积分: ST金币 -111.18 KB, 下载次数: 127, 下载积分: ST金币 -1