Question
STM32f407 accessing internal flash
Posted on November 04, 2015 at 23:08
I'm using the Keil v4 IDE/Toolchain
IDE-Version:�Vision V4.70.0.0Tool Version Numbers:Toolchain: MDK-ARM Professional Version: 4.70.0.0The STM32F407VET6 is my full version. So I have 512MB flash.My image size is only about 120MB. So I want to use the last 256MB for flash storage. As I understand it, the first sectors are 4 - 16K sectors, 1-64K sector, and 3 - 128K sectors.My problem is this. I want to write data to the flash @ 0x08006000. My snip of code that I want to have this work is:int main(void)
{ // GPIO_InitTypeDef GPIO_InitStructure; /*!< At this stage the microcontroller clock setting is already configured to 168 MHz, this is done through SystemInit() function which is called from startup file (startup_stm32f4xx.s) before to branch to application main. To reconfigure the default setting of SystemInit() function, refer to system_stm32f4xx.c file */ FLASH_Status flash_status; FLASH_Unlock(); FLASH_ClearFlag(FLASH_FLAG_EOP | FLASH_FLAG_OPERR |FLASH_FLAG_WRPERR | FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR | FLASH_FLAG_PGSERR); flash_status = FLASH_EraseSector(FLASH_Sector_6, VoltageRange_3); if(flash_status == FLASH_COMPLETE) FLASH_ProgramWord(EEpromCheckByte,EEPROM_MAGIC); FLASH_Lock();}As I step from the SystemInit (from the startup_stm32f4xx.s) the FLASH->SR = 0x000000C0So I MUST be doing something wrong in the Keil startup? I've done this before on other ST's and it works fine. I never had to do anything special.What am I missing?Thanks.-stv #rewrite #stm32f #flash