AnsweredAssumed Answered

STM32f407 accessing internal flash

Question asked by iribarne.steve on Nov 4, 2015
Latest reply on Nov 9, 2015 by Clive One
I'm using the Keil v4 IDE/Toolchain


IDE-Version:
µVision V4.70.0.0

Tool Version Numbers:
Toolchain:        MDK-ARM Professional  Version: 4.70.0.0

The 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 = 0x000000C0

So 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

Outcomes