/var/www/restricted/ssh/stm32/www/stm32circle/ STM CircleOS forum / Programing Flash HELP PLEASE

Username:     
Password:     
             

Forum

# 1   2009-02-02 16:42:48 Programing Flash HELP PLEASE

userofstm32
New member
Registered: 2009-02-02
Posts: 1

Programing Flash HELP PLEASE

Hi folks,

in a battery powered unit i am using the flash programing routines to copy a certain area of RAM to the Flash ROM so that these datas are not lost while running out of battery. As a replacement of EEPROM so to say.
My problem is that these routines work fine the first time, the second time the hole system freezes and i need to reset.

u8 CopyRAMtoROM(void){
  u8  i, RetValue;
  u16 *pData;
 
  RetValue = ErasePage(EEPROM_START_ADDRESS);
  RetValue = WriteFlashEEProm(EEPROM_STATUS1, PROGPROCESS); // Status: Update
  if(RetValue == FLASH_COMPLETE){
    pData = (u16*)&Test;                                                           // Test
    i = 0;
    while((RetValue == FLASH_COMPLETE) && (i<(MaxSizeTest/2))){
      RetValue = WriteFlashEEProm(AddressInROM+(i*2),*pData);
      pData++;
      i++;
    }
}


TFlashStatus ErasePage(u32 Address){
  TFlashStatus FlashStatus = FLASH_COMPLETE;
  //Check address space
  if((Address < PAGE0_BASE_ADDRESS) || (Address > PAGE0_END_ADDRESS)){
    FlashStatus = ADDRESS_ERROR;
  }
  else{
    FlashStatus = WaitForLastOperation(EraseTimeout);
   
    if(FlashStatus == FLASH_COMPLETE){     // Is Flashmodul busy?
      FLASH->AR = Address;                 // Page address
      FLASH->CR|= CR_PER_Set;        // Operation: Page Erase
     $1
     
      FlashStatus = WaitForLastOperation(EraseTimeout);
     
      if(FlashStatus != FLASH_BUSY){
    FLASH->CR &= CR_PER_Reset;            // Reset Earse when done
      }
    }
  }
  return FlashStatus;
}

The problem accures when i start page erase for the second time (see boldes line)


Has anybody any hints ?

Offline

 

# 2   2009-02-06 09:05:38 Programing Flash HELP PLEASE

Socrates
New member
From: Germany
Registered: 2008-07-29
Posts: 5

Re: Programing Flash HELP PLEASE

Hi UserOfSTM32,

i've had a similiar problem: directly after the PageErase Command some timer interrupts seems to be suppressed. The reason was: during the PageErase cycle (20ms) Timer mets the CCR Value but didn't serve the ISR. So the system seems to be frozen until the CCR mets again (next complete cycle).
If your Copy2ROM function is part of a ISR...

Offline

 

# 3   2011-01-27 20:23:46 Programing Flash HELP PLEASE

sfenwick76
New member
Registered: 2010-01-07
Posts: 3

Re: Programing Flash HELP PLEASE

I believe this is because you cannot program flash memory while executing from flash memory.  First you must copy the FLASH_ProgramWord routines to RAM and execute them from RAM.  I am working on doing this now in a project.  Message me if you are interested in this still.

Offline

 

# 4   2011-01-28 07:01:19 Programing Flash HELP PLEASE

yrt
Administrator
From: Grenoble-France
Registered: 2008-06-11
Posts: 520
Website

Re: Programing Flash HELP PLEASE

I disagree with the last post : it is possible to program flash memory pages from a routine executed also in flash, in another page. It is the principle of bootloader for update program in IAP mode.

Offline

 

# 5   2011-04-25 05:49:01 Programing Flash HELP PLEASE

mickamark
New member
Registered: 2011-04-25
Posts: 5

Re: Programing Flash HELP PLEASE

i have a car stereo/sat nav unit which has been updated using the wrong software cd, since then it has crashed and nothing works, i am trying to put the correct software disc but i cant do that because the headunit/cd player doesn't respond anymore.
i have done some research on the net and found that the chips will have to be reprogrammed.
i have opened the unit and found the two chips on the motherboard, they are Q flash memory, made by Micron MT28F640J3 RG 115ET.
i am including a photo with this post for you to see.Please help me!!! whit what program i can edit firmware and flash sony ericsson vivaz?

Offline

 

# 6   2012-03-14 10:11:08 Programing Flash HELP PLEASE

saurabh.bansal.90
New member
Registered: 2012-02-08
Posts: 5

Re: Programing Flash HELP PLEASE

i am new to this kind of platform.
i am enable to erase & write the data to DATA EEPROM memory in STM32F103RBT6 on Keil uVision 3 IDE. Whenever this code is run, the uC freezes & even not work after RESET. Please help me to get out of this problem.
i am using the following code...

FLASH_Unlock();
FLASH_ClearFlag(FLASH_FLAG_BSY | FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPRTERR);
while(FLASHStatus != FLASH_COMPLETE)
    FLASHStatus = FLASH_ErasePage(FLASH_Start_Address);
while(FLASHStatus != FLASH_COMPLETE)
    FLASHStatus = FLASH_ProgramHalfWord(FLASH_Start_Address, 0xABAB);

FLASH_Status FLASH_ErasePage(u32 Page_Address)
{
  FLASH_Status status = FLASH_COMPLETE;

  /* Check the parameters */
  assert(IS_FLASH_ADDRESS(Page_Address));

  /* Wait for last operation to be completed */
  status = FLASH_WaitForLastOperation(EraseTimeout);
 
  if(status == FLASH_COMPLETE)
  {
    /* if the previous operation is completed, proceed to erase the page */
    FLASH->CR|= CR_PER_Set;
    FLASH->AR = Page_Address;
    FLASH->CR|= CR_STRT_Set;
   
    /* Wait for last operation to be completed */
    status = FLASH_WaitForLastOperation(EraseTimeout);

    if(status != FLASH_BUSY)
    {
      /* if the erase operation is completed, disable the PER Bit */
      FLASH->CR &= CR_PER_Reset;
    }
  }
  /* Return the Erase Status */
  return status;
}
FLASH_Status FLASH_ProgramHalfWord(u32 Address, u16 Data)
{
  FLASH_Status status = FLASH_COMPLETE;

  /* Check the parameters */
  assert(IS_FLASH_ADDRESS(Address));

  /* Wait for last operation to be completed */
  status = FLASH_WaitForLastOperation(ProgramTimeout);
 
  if(status == FLASH_COMPLETE)
  {
    /* if the previous operation is completed, proceed to program the new data */
    FLASH->CR |= CR_PG_Set;
 
    *(vu16*)Address = Data;
    /* Wait for last operation to be completed */
    status = FLASH_WaitForLastOperation(ProgramTimeout);

    if(status != FLASH_BUSY)
    {
      /* if the program operation is completed, disable the PG Bit */
      FLASH->CR &= CR_PG_Reset;
    }
  }
  /* Return the Program Status */
  return status;
}

Offline

 

Board footer