We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I try to write float values to flash memory of STM32F103RBT6. but it cannot read the value and CPU reset by IWDT. my code is in below:
char str[100]; float Val; float Data; Data=123.456; FLASH_Unlock(); FLASH_ClearFlag(FLASH_FLAG_BSY | FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPRTERR); FLASH_ErasePage(0x08002000); //write------------------------ Val = *((unsigned long*)&Data); FLASH_ProgramWord(0x08002000,Val); //Read----------------------------- float *mem = (float *)0x08002000; sprintf(str,"%f\n", *mem); uart_out_str(str);
How ever the following code wires and reads integer values
u32 Data; Data=123; FLASH_Unlock(); FLASH_ClearFlag(FLASH_FLAG_BSY | FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPRTERR); FLASH_ErasePage(0x08002000); //write------------------------ FLASH_ProgramWord(0x08002000, Data); //Read----------------------------- u32 *mem = (u32 *)0x08002000; sprintf(str,"%u\n", *mem);uart_out_str(str);