I'm trying to receive a float number through a VCP and writing it in the Flash memory of the STM32F4 discovery board, using Keil IDE. The functions used to write in the Flash memory:
FLASH_Status FLASH_ProgramDoubleWord(uint32_t Address, uint64_t Data);
FLASH_Status FLASH_ProgramWord(uint32_t Address, uint32_t Data);
FLASH_Status FLASH_ProgramHalfWord(uint32_t Address, uint16_t Data);
FLASH_Status FLASH_ProgramByte(uint32_t Address, uint8_t Data);
accept an unsigned integer value as data input, but I've managed to write a signed integer in the Flash memory using this code:
int dataflash1 = -1000;
int gain;
uint32_t Address= 0x08008000;
.......
FLASH_ProgramWord(Address,dataflash1);
.......
gain=*(int*)Address;
I still haven't managed to write a float data, though. If I change "int" with "float" (they should both be 4 bytes data, it's said in the keil compiler guide) I get numbers like 1.7345673 e-42.
Maybe it's a dumb question, but if you could give me a clue I'd really appreciate.