cancel
Showing results for 
Search instead for 
Did you mean: 

stm32f100rb flash programing

TARHAN SAMAH
Senior
Posted on September 25, 2017 at 14:23

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 MEMORY

flash32_data=HAL_FLASHEx_OBGetUserData(0x08007C00U);

// flash_data=0x0001411;

//key=(flash_data & 0x0000FF00 )>> 8;//high byte

key=flash32_data & 0x000000FF;//low byte

lcd_clear();

//write key to lcd//

lcd_write_char(key+48,1,1,8);

thanks plz help needed urgently 

0 REPLIES 0