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.

FlashProgram() failed on the chip of tm4c1294ncpdt in ti-rtos.

Hi all,

   The ti-rtos for tiva doesn't supply function drivers about  flash.So I use the tivaware driver abou the flash(diverlib/flash.h).Here is my code :

int32_t flash_test(uint32_t *pData, uint32_t Address, uint32_t Count)
{
int32_t result;
SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480),1200000);
FlashErase(Address);
result = FlashProgram(pData, Address, Count);
SysCtlDelay(1000000);
return result;
}

Void flashtestFxn(UArg arg0, UArg arg1)
{
uint32_t pui32Data[2];
pui32Data[0] = 0x12345678;
pui32Data[1] = 0x56789abc;
uint32_t add = 0x800;

while (1) {
flash_test(pui32Data, add , sizeof(pui32Data));

Task_sleep((unsigned int)arg0);
GPIO_toggle(Board_LED0);
}
}

int main(void)
{
Task_Params taskParams;
/* Call board init functions */
Board_initGeneral();
Board_initGPIO();

Task_Params_init(&taskParams);
taskParams.arg0 = 1000;
taskParams.stackSize = TASKSTACKSIZE;
taskParams.stack = &task0Stack;
Task_construct(&task0Struct, (Task_FuncPtr)flashtestFxn, &taskParams, NULL);

System_printf("Starting the example\nSystem provider is set to SysMin");
System_flush();

BIOS_start();

return (0);
}


When I run the code on my board,set the brakpoint  on the step of   FlashErase() and FlashProgram() but the step can not go to  FlashProgram().The whole project  run fly when it is go to the  FlashProgram().

Is there is any other requirements for run the fuction of  FlashProgram()?How can  i write and erease an address of  flash? 

  • Hello Nancy,

    The sector size on TM4C129x devices is 16KB or 0x4000. The function call

    Void flashtestFxn(UArg arg0, UArg arg1)
    {
    uint32_t pui32Data[2];
    pui32Data[0] = 0x12345678;
    pui32Data[1] = 0x56789abc;
    uint32_t add = 0x800;

    while (1) {
    flash_test(pui32Data, add , sizeof(pui32Data));

    Task_sleep((unsigned int)arg0);
    GPIO_toggle(Board_LED0);
    }
    }

    seems to be erasing sector-0 where your code would be executing.... Please check the size of the program being run and the last sector being used. Once that is known you can use the next address for Program/Erase operations.

    Regards
    Amit
  • Hi Amit,

       Thanks!The flashtestFnx is write according to the example programing of the TivaWare™ Peripheral Driver Library user's guide 12.3:

    uint32_t pui32Data[2];

    //

    // Erase a block of the flash.

    //

    FlashErase(0x800);

    //

    // Program some data into the newly erased block of the flash.

    //

    pui32Data[0] = 0x12345678;

    pui32Data[1] = 0x56789abc;

    FlashProgram(pui32Data, 0x800, sizeof(pui32Data));

    You means that:my add may be in the area where my  projerct code are loaded in flash.I will modify my add to a valid add in valid sector.

     

  • Hello Nancy

    Also it is mentioned in the same section, that this is an example for TM4C123x device.

    Regards
    Amit
  • Hi Amit,
    Thanks a lot!
    I take a look at the .map file which is made from my project.The 0x800 is an address in my code area in flash.So I change the address to an address which is not used.The FlashProgram() can run sucessfully.
  • Hello Nancy

    Also do note that the address of flash erase is a function of the sector size, which in turn is dependent on the device:TM4C123 or TM4C129