stm32f2xx HAL_FLASH_Program返回废话

时间:2017-08-29 15:48:12

标签: c stm32 flash-memory

我正在尝试写入闪存,但返回错误不在可接受的范围内。

示例:

uint32_t Address = 0x0800C000;
uint8_t Data = 0x01;

HAL_FLASH_Unlock();
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR | FLASH_FLAG_PGSERR);
FLASH_Erase_Sector(FLASH_SECTOR_3, VOLTAGE_RANGE_3); //sector3 0x800C000 0x800CFFF
printf("---%u\n", HAL_FLASH_Program(FLASH_TYPEPROGRAM_BYTE, Address, Data));

if ( HAL_FLASH_Program(FLASH_TYPEPROGRAM_BYTE, Address, Data)==HAL_OK       ) printf("---%u\n", 0);
if ( HAL_FLASH_Program(FLASH_TYPEPROGRAM_BYTE, Address, Data)==HAL_ERROR    ) printf("---%u\n", 1);
if ( HAL_FLASH_Program(FLASH_TYPEPROGRAM_BYTE, Address, Data)==HAL_BUSY     ) printf("---%u\n", 2);
if ( HAL_FLASH_Program(FLASH_TYPEPROGRAM_BYTE, Address, Data)==HAL_TIMEOUT  ) printf("---%u\n", 3);
if ( HAL_FLASH_Program(FLASH_TYPEPROGRAM_BYTE, Address, Data) > 0x03)  printf("---none\n");

HAL_FLASH_Lock();

请原谅邋code的代码,但要进行测试。我总是得到一个>的回报3.如果跟踪它是1073888268,但结构说

typedef enum 
{
  HAL_OK       = 0x00,
  HAL_ERROR    = 0x01,
  HAL_BUSY     = 0x02,
  HAL_TIMEOUT  = 0x03
} HHAL_StatusTypeDef;

这怎么可能?

0 个答案:

没有答案