This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Program freezing after Flash write

Other Parts Discussed in Thread: EK-TM4C1294XL

Hello all,

  I am using the EK-TM4C1294XL board to develop my project and I am facing a problem when writing on flash. Also, I am using the driverlib and ti-rtos.

  I need to persist some data on flash and, on the first load of the program, I write the data direct to the flash but, after this write, the program freezes in the next command, in my case, a simple System_printf. The debug just stops on this command and does not goes forward.  I also started a single program just to nake sure I have no other problems in the original project. My new project does almost nothing in the main.

  Please, see the attached code below.

#define FLASH_CONFIG_SECTOR 0xC0000

typedef struct {
	uint32_t programmed;			// The default value for a programmed section is 0x0000ABCD
	uint32_t serverIpAddress[4];	// Server IPAddress
	uint32_t serverPort;			// Server Port
	uint32_t localServerPort;		// Local server port
	uint32_t equipmentId[8];		// Equipment ID
	uint32_t serialNumber[14];		// Equipment SerialNumber
	uint32_t partNumber[16];		// Equipment PartNumber
	uint32_t reserved[467];			// (512 - number of items above)
} RemottaConfig;


int main(void)
{
	uint32_t clock;
	unsigned int programmed;
	RemottaConfig rc;

	// Usar 120MHZ de clock
	clock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000);

    /* Call board init functions */
    Board_initGeneral();
    Board_initGPIO();

    programmed = HWREG(FLASH_CONFIG_SECTOR);
    if (programmed == 0xFFFFFFFF) {
        System_printf("First RUN.\n");
        System_flush();

    	rc.programmed = FLASH_PROGRAMMED;
    	rc.serverIpAddress[0] = 192;
    	rc.serverIpAddress[1] = 168;
    	rc.serverIpAddress[2] = 10;
    	rc.serverIpAddress[3] = 122;
    	rc.serverPort = 5000;
    	rc.localServerPort = 8000;
    	memset(rc.equipmentId, 0, sizeof(rc.equipmentId));
    	memset(rc.serialNumber, 0, sizeof(rc.serialNumber));
    	memset(rc.partNumber, 0, sizeof(rc.partNumber));
    	memset(rc.reserved, 0, sizeof(rc.reserved));

    	FlashErase(FLASH_CONFIG_SECTOR);
	FlashProgram((uint32_t *)&rc, FLASH_CONFIG_SECTOR, sizeof(RemottaConfig));

    }

    System_printf("Here is where my code stops\n");
    System_flush();

  ...

After FlashProgram, I see in the MemoryBrowser the data correctly stored in the flash, as expected.

When I remove the code that uses flash, everything goes ok.

What m I doing wrong?

Hi,

Just to trying to do something different, I added the following code before the line: programmed = HWREG(FLASH_CONFIG_SECTOR);

protection = FlashProtectGet(FLASH_CONFIG_SECTOR);
switch(protection) {
case FlashReadWrite:
  System_printf("We can read and write on flash");
  break;
case FlashReadOnly:
  System_printf("Just for reading");
  break;
case FlashExecuteOnly:
  System_printf("just for executing");
  break;
}
System_flush();


And I am receiving the value FlashReadWrite.

Tks in advance.
Leandro