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.

Compiler/TMS570LS1114: How to achieve flash read and write data based on TMS570LS1114

Part Number: TMS570LS1114
Other Parts Discussed in Thread: HALCOGEN

Tool/software: TI C/C++ Compiler

Hello:

I want to program the flash whose address is  from 0x000FE000 to 0x000FE3E8.At the first step ,I test the bank0 ,sector0,but I find the error appearing when I operate the flash acrrording to the step as like eeprom as the ooperation.I open the memory Broser whose dispay is not matching with my writing buffer.

The main function is follow:

int main()

{

Fapi_initializeFlashBanks(GCLK_FREQ);
Fapi_setActiveFlashBank(Fapi_FlashBank0);
Fapi_enableMainBankSectors(0);//0x0000_0000-0x0000_3FFF sector0

Fapi_FLASH_save(0x00000000,API_flash_save_data,16);
Fapi_FLASH_read(0x00000000,API_flash_read_data,16);

while(1);

}

uint8 Fapi_FLASH_save(uint32_t *Flash_Start_Adress, uint32_t *Datas_Start_Adress,uint8_t Datas_SizeInBytes)

{


register uint32_t ESA=Flash_Start_Adress;
register uint32_t DSA=Datas_Start_Adress;
register uint8_t DSB=Datas_SizeInBytes;
while(Datas_SizeInBytes>0)
{
if(Fapi_Status_FsmReady == Fapi_checkFsmForReady())
break;
}
Fapi_issueProgrammingCommand((uint32_t*)ESA, (uint8_t*)DSA, DSB, 0, 0, Fapi_AutoEccGeneration);
// Fapi_doVerifyByByte((uint8_t*)ESA,(uint32_t)DSB,uint32_t DSA,Fapi_Status_Success);
}

uint8 Fapi_FLASH_read(uint32_t *Flash_Start_Adress, uint32_t *Datas_Start_Adress,uint8_t Datas_SizeInBytes)
{

register uint32_t ESA=Flash_Start_Adress;
register uint32_t DSA=Datas_Start_Adress;
register uint8_t DSB=Datas_SizeInBytes;
while(1)
{
if(Fapi_Status_FsmReady == Fapi_checkFsmForReady())
break;
}
Fapi_doMarginReadByByte((uint32_t*)ESA, (uint8_t*)DSA,(uint8_t)DSB,Fapi_NormalRead);

}

  • Hello Qiu,

    1. The flash API related code has to be copied to SRAM and executed in SRAM. You can not erase/program the flash sector by executing the flash operation code in the same flash bank.
    2. Fapi_enableMainBankSectors(0): you need to enable the sector 13 (0xE0000 ~ 0xFFFFF). But you only enabled the sector 0
    3. Fapi_FLASH_save(0x00000000,API_flash_save_data,16): you write the data to 0x0 instead of 0xFE000. Actually you cannot write your data to 0x0. This address is for the interrupt vector table.
  • Hello QJ Wang:

    Thank you for your enthusiastic response.

    I read and write FLASH , based on the F021 FLASH API, founding that the write data is normal, but when read, there is no data. My steps are:

    1 Divide an area in the CMD

    2 for the division of the area to write data

    3 for the divided area to read data

    I have been tested and found three problems. The first problem is that I can write data, but the data is not correct, whether my method  is wrong  in the process, how do I modify it? The second problem is that I transplanted flash yesterday wrote a new project into the process and found that some can be achieved FLASH data write, and some are not? Of course, I was based on HALCogen generated code, the failure to write and halcogen configuration related?

    Regarding what you mentioned 1 yesterday, what should I do in the program?

    About 2 and 3 you mentioned yesterday have been changed.

    MEMORY
    {
    /*VECTORS (X) : origin=0x00000000 length=0x00000020
    FLASH0 (RX) : origin=0x00000020 length=0x000FFFE0
    STACKS (RW) : origin=0x08000000 length=0x00001500
    RAM (RW) : origin=0x08001500 length=0x0001EB00*/
    VECTORS (X) : origin=0x00000000 length=0x00000020
    FLASH0 (RX) : origin=0x00000020 length=0x000F5FE0
    CAL_ROM (RX) : origin=0x000FE000 length=0x000003E8//length=0x00002000
    STACKS (RW) : origin=0x08000000 length=0x00001500
    RAM (RW) : origin=0x08001501 length=0x0001CFFF
    CAL_RAM (RW) : origin=0x0801E500 length=0x00001000

    void Fapi_FLASH_init(void)
    {
    Fapi_initializeFlashBanks(GCLK_FREQ);
    Fapi_setActiveFlashBank(Fapi_FlashBank0);
    Fapi_enableMainBankSectors(0xFFFFF);//0x0000_0000-0x0000_3FFF

    }

    uint8 Fapi_FLASH_save(uint32_t *Flash_Start_Adress, uint32_t *Datas_Start_Adress,uint8_t Datas_SizeInBytes)

    {

    uint16 i = 50000;
    register uint32_t ESA=Flash_Start_Adress;
    register uint32_t DSA=Datas_Start_Adress;
    register uint8_t DSB=Datas_SizeInBytes;
    while(i--)
    {
    if(Fapi_Status_FsmReady == Fapi_checkFsmForReady())
    break;
    }
    Fapi_issueProgrammingCommand((uint32_t*)ESA, (uint8_t*)DSA, DSB, 0, 0, Fapi_AutoEccGeneration);

    // Fapi_doVerifyByByte((uint8_t*)ESA,(uint32_t)DSB,uint32_t DSA,Fapi_Status_Success);
    }

    uint8 Fapi_FLASH_read(uint32_t *Flash_Start_Adress, uint32_t *Datas_Start_Adress,uint8_t Datas_SizeInBytes)
    {
    uint16 i = 20000;
    register uint32_t ESA=Flash_Start_Adress;
    register uint32_t DSA=Datas_Start_Adress;
    register uint8_t DSB=Datas_SizeInBytes;
    while(i--)
    {
    if(Fapi_Status_FsmReady == Fapi_checkFsmForReady())
    break;
    }
    Fapi_doMarginReadByByte((uint32_t*)ESA, (uint8_t*)DSA,(uint8_t)DSB,Fapi_NormalRead);


    }

    int main(void)
    {
    /* USER CODE BEGIN (3) */
    /*************************2017/12/27********FAPI Operate FLASH *******************************************
    *********************************************************************************************************/
    Fapi_FLASH_init();
    Fapi_FLASH_save(0x000FE100,API_flash_save_data,16);
    Fapi_FLASH_read(0x000FE200,API_flash_read_data,16);
    while(1);

    I am looking forward to your replay.

      Qiuchi

    2017/12/28

  • Hello Qiu,

    Please refer to my example code for flash operation using flash API:

    3324.bl_flash.c

    6404.flash_defines.h

  • Hello QJ Wang:
    Thank you for your enthusiastic response.
    these code is very useful for me. But I have a problem about the flash operation.In fact,I init the flash,next I write the flash ,finalally I read the flash .I find the program only running in the read step and can not continue to run.