2017-09-25 05:23 AM
hello every body , im new with the stm32 im using discovery kit , i try to read and write to flash memory one byte ,using keil ,
can you tell me where can i write can i use the 128 pages (0------>127) ? or it is used just for my application prgm
or i can just write in the option byte area ?
during the application i need to write or read a byte save it ,,even i reset my device i need to keep it for later use ,
because im using this prgm looks not working right :
// /********************FLASH MEMORY******************************/
//WRITE DATA TO FLASH MEMORY /* Unlock the Flash to enable the flash control register access *************/ if(HAL_FLASH_Unlock()==HAL_OK){ BUZZER_LED_ON_LONG(); if(HAL_FLASH_OB_Unlock()==HAL_OK) { BUZZER_LED_ON_LONG(); if(HAL_FLASHEx_OBErase()==HAL_OK) { BUZZER_LED_ON_LONG(); // FLASH_PageErase(31);//uint32_t PageAddress erasing page 31 FLASH_Program_HalfWord(0x08007C00U, 0x0000); }} HAL_FLASH_OB_Lock();HAL_FLASH_Lock(); //HAL_FLASH_OB_Launch(); //resets the prgm // READ THE DATA FROM FLASH MEMORYflash32_data=HAL_FLASHEx_OBGetUserData(0x08007C00U); // flash_data=0x0001411; //key=(flash_data & 0x0000FF00 )>> 8;//high byte key=flash32_data & 0x000000FF;//low bytelcd_clear();
//write key to lcd//
lcd_write_char(key+48,1,1,8);thanks plz help needed urgently