2015-11-04 02:08 PM
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 #flash2015-11-04 04:11 PM
My problem is this. I want to write data to the flash @ 0x08006000
0x08060000 ?? FLASH_Sector_7 The defines might be helpful. All the F407 parts have 1MB of FLASH on die2015-11-09 09:49 AM
2015-11-09 09:56 AM
Your defines, I have the ST ones
EEpromCheckByte, EEPROM_MAGIC, etc You shouldn't leave the main() function, put a while(1); in there so it doesn't exit. The debugger will interfere with the Flash controller, but you seem to clear the flags. I'd compile the code, but obviously I can't. They sell versions with 256KB, and 512KB tested, but all the die have 1MB. It costs a lot in tester time to validate the memory. ie I can test 4x 256KB parts in the time it would take for 1x 1MB, and the costs are passed along.2015-11-09 10:00 AM
Crossed on the wire, but your still have the sector number wrong
#define FLASH_Sector_0 ((uint16_t)0x0000) /*!< Sector Number 0 0x08000000*/ #define FLASH_Sector_1 ((uint16_t)0x0008) /*!< Sector Number 1 0x08004000 */ #define FLASH_Sector_2 ((uint16_t)0x0010) /*!< Sector Number 2 0x08008000 */ #define FLASH_Sector_3 ((uint16_t)0x0018) /*!< Sector Number 3 0x0800C000 */ #define FLASH_Sector_4 ((uint16_t)0x0020) /*!< Sector Number 4 0x08010000 */ #define FLASH_Sector_5 ((uint16_t)0x0028) /*!< Sector Number 5 0x08020000 */ #define FLASH_Sector_6 ((uint16_t)0x0030) /*!< Sector Number 6 0x08040000 */ #define FLASH_Sector_7 ((uint16_t)0x0038) /*!< Sector Number 7 0x08060000 */ #define FLASH_Sector_8 ((uint16_t)0x0040) /*!< Sector Number 8 0x08080000 */ #define FLASH_Sector_9 ((uint16_t)0x0048) /*!< Sector Number 9 0x080A0000 */ #define FLASH_Sector_10 ((uint16_t)0x0050) /*!< Sector Number 10 0x080C0000 */ #define FLASH_Sector_11 ((uint16_t)0x0058) /*!< Sector Number 11 0x080E0000 */