AnsweredAssumed Answered

STM32F103 Flash Erase Error

Question asked by sharma.vineet on Jan 2, 2016
Latest reply on Jan 5, 2016 by kk
My Flash is divided into 3 parts first part of code only decide that which part 
is active b/w the remaining two parts and jumps to the active part accordingly. 
The remaining inactive part is for remote firmware update. When there is remote 
update it erase the inactive part and program it and shifts to new overlay and 
mark this as active. If there is remote update again it erases the other part 
and program again in this whole process first part of code remains unchanged 
switching happens only b/w 2nd and 3rd part.


Earlier this process is working fine but now i have introduced USB in my 
application. Earlier I was working on 64 Mhz clock now I working on 72 Mhz 
because of USB requirement. After introducing 72 Mhz clock i am facing problem 
related to erasing flash.

Earlier code for 64 Mhz is


// PLL Configure for 64 MHz
     rRCC_CFGR |= 0x00380000; //PLL input Clock Multiply By 16




//PLL Turn On
     rRCC_CR |= RCC_CR_PLLON; //PLL oscillator ON
     uart1_printf_debug("PLL Turn ON\n");
     while (!(rRCC_CR & RCC_CR_PLLRDY))
//Wait Till PLL Oscillator ready
          ;
     uart1_printf_debug("PLL Stable\n");




     rRCC_CFGR |= RCC_CFGR_SW_PLL; //PLL selected as system clock




// Reinitialize UART for 72 MHz
     init_uart1_debug(64000000, 115200);
     uart1_printf_debug("\nPLL (64 MHz) In Use as System Clock\n");






New Code for 72 Mhz


     rRCC_CR |= RCC_CR_HSEON;                    // HSE oscillator ON




     uart1_printf_debug("HSE Turn ON\n");
     while (!(rRCC_CR  & RCC_CR_HSERDY))         //Wait Till HSE Oscillator 

ready
     ;
     uart1_printf_debug("HSE Stable\n");




     // PLL Configure for 72 MHz
     rRCC_CFGR |= (RCC_CFGR_PLLMULL6 |           //PLL input Clock Multiply 


By 6
     RCC_CFGR_PLLSRC);                      //Clock from PREDIV1 selected as 


PLL input clock




     //PLL Turn On
     rRCC_CR |= RCC_CR_PLLON;                    //PLL oscillator ON
     uart1_printf_debug("PLL Turn ON\n");
     while (!(rRCC_CR  & RCC_CR_PLLRDY))         //Wait Till PLL Oscillator 


ready
     ;
     uart1_printf_debug("PLL Stable\n");




     rRCC_CFGR |= RCC_CFGR_SW_PLL;               //PLL selected as system 


clock








     // Reinitialize UART for 72 MHz
     init_uart1_debug(72000000,115200);
     uart1_printf_debug("\nPLL (72 MHz) In Use as System Clock\n");




     //HSI Turn Off
     rRCC_CR &= ~RCC_CR_HSION ;
     uart1_printf_debug("HSI Turn Off\n");


after shifting to 72 Mhz when i try to erase flash my code get hang up.
but it is working fine with 64 Mhz.

Outcomes