This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

freezing during hal_flash_program

With a bit of assistance from Keil I implemented a smaller version of the eeprom emulation. Essentially we just left a gap in sector 0. Then changed the start vector to jump to sector 1. Then I was able to write make fake eeprom data to sector 0 but noticed a small header of code. Keil could not offer an explanation to what this was. So I figured I could just leave it in tack. and write beyond it. This is my function for doing so.

uint32_t FLASH_ADDRESS = 0x08000000;
void _EEPROM_WRITE(  int offset, uint8_t Data )
{
        HAL_FLASH_Unlock();
        //read and restore the current code.
        static int h[0x3000];
        for (int f=0;f<0x3000;f++)    h[f]=*(__IO uint8_t *)FLASH_ADDRESS+f;
        FLASH_Erase_Sector(FLASH_SECTOR_0, VOLTAGE_RANGE_3);
  for (int t=0;t<0x3000;t++) //freezing here.
        HAL_FLASH_Program(FLASH_TYPEPROGRAM_BYTE, FLASH_ADDRESS+t, h[t]);

        //write new data, not sure how big the header codde is so this may have to move....
        HAL_FLASH_Program(FLASH_TYPEPROGRAM_BYTE, EEPROM_ADDRESS+offset, Data);

        HAL_FLASH_Lock();
}


This did work when I created it but now it is freezing on me. I guess I'd like to know two things.

1) What is this code? this code is 2c4 bytes from 0x08000000 and does change.
2) Why is my write back freezing. It freezes on the first HAL_FLASH_Program.

This is on the stm32f205 chip using the hall driver. Aside from my code it also uses middle-ware usb and can.