AnsweredAssumed Answered

STM32F030 flash read problem

Question asked by Conover.John on Oct 24, 2016
Latest reply on Oct 26, 2016 by Conover.John
Hi,

     We are using a STM32F030C8T6 and are storing configuration data at the end of flash memory. We carved off 4K of the 64K of flash(via the .ld linker file) for the storage area so our config storage is at address 0x0800F000. The data is stored there correctly when viewed from the debugger. During operation of the system we copy the data into ram, insure that the config CRC's are correct and use the data that is now in ram.
     The problem that we have is that during normal operation we insure that the ram data matches the original flash data by reading both ram and flash and comparing the bytes. During this process a byte of data that is read from the flash appears as a 0xFF and the compare fails. We are only reading from the flash so there are no writes going on. I have not found/read any reason a flash read could get corrupted so I'm looking for some help.

tempByte1 is the data from flash and tempByte2 is the data from ram. The error checking is run at random times during program execution but the failure normally occurs on the first byte read(when i = 0.) The ram byte is correct and the flash byte is showing up as 0xFF. I thought that maybe the tempByte's were getting blasted because of stack space but the error always seems to come from the flash byte read. Are there any issues doing single byte reads from flash?

Thanks,
    John C.

uint8_t read_flash_byte(uint8_t *addr_p)
{
    return(*(__IO uint8_t *)addr_p);
} // End of write_read_byte()
 
// Function where error occurs...
uint8_t tempByte1, tempByte2;
uint8_t *ptr1_p, *ptr2_p;
 
                /* Make sure the both flash copies match RAM copy we are using. */
                ptr1_p = (uint8_t *)&UL1;
                ptr2_p = (uint8_t *)&UL2;
                for(i = 0; i < sizeof(EE_UL_CRIT_DATA); i++)
                {
                    /* check this byte in Copy1 */
                    tempByte1 = read_flash_byte(ptr1_p++);
                    tempByte2 = UsedULData->Val[i];
                    if(tempByte2 != tempByte1)
                                   {
                                     /* Flash and Ram are different throw a critical Error */
                                        HandleError();
                                    }
                     
                                    /* check this byte in Copy2 */
                            tempByte1 = read_flash_byte(ptr2_p++);
                            if(tempByte2 != tempByte1)
                                    {
                                          /* Flash and Ram are different throw a critical Error */
                                          HandleError();
                                    }
                            } // End of for loop


Outcomes