Dear community,

I am developing a motor control application on the TMS320F28335. I have the application to work properly as standalone and within CCS.

I am now working on the configuration part (some parameters may have to be tuned) and I do that with MODBUS, everything works fine.

When I have my parameters ready once and for all I would like to save them in FLASH and eventually recover them upon next reset. To do that I take advantage of the FlashAPI library. I can store and recover the parameters while the board is attached to CCS but in standalone mode something in the data recovery from Flash goes wrong (I think I read all 0xFFFF but I cannot be too sure as I have nothing to really "debug"  the thing while the board is disconnected).

To make the system standalone in the first place I used the tutorial on "Copy compiler sections from Flash to RAM on the TMS320F28xxx DSCs" (spraau8). And I have the feeling that there could be something missing in that document for data that have to born live and die in Flash memory.

To save the parameters in Flash and restore them I use the following code:

.cmd:

ModbusRegsFlashFile    : > FLASHE,        PAGE = 0

modbus.c:

Uint16 mbWriteRegsIntoFlash(void){
    FLASH_ST ProgStatus,EraseStatus;
    Uint16 Status;

    Status = Flash_Erase(SECTORE,&EraseStatus); //Please, check the sector in .cmd file
    if(STATUS_SUCCESS!=Status){
        puts("Flash erase sector B error");
    }else{
        Status = Flash_Program((Uint16 *) &ModbusRegsFlash[0],(Uint16 *) &ModbusRegs[0],MB_REG_FLASH_SIZE,&ProgStatus);
        if(STATUS_SUCCESS!=Status){
            puts("Flash program error");
        }
    }

    return Status;
}

main.c:

#pragma DATA_SECTION(ModbusRegsFlash,"ModbusRegsFlashFile");
int16 ModbusRegsFlash[MB_REG_FLASH_SIZE];

[...]

void copy_values_to_ram(void)
{
    int i;

    //Copy everything to RAM!

    for(i=0; i < MB_REG_FLASH_SIZE; i++)
    {

        ModbusRegs[i] = ModbusRegsFlash[i];

   }

}

 

Any help on this issue is really appreciated, many thanks for your precious time!

Andrea