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.

TMS570LS0432: Use TMS570 flash memory for data (write / read during runtime)

Part Number: TMS570LS0432
Other Parts Discussed in Thread: HALCOGEN,

Dear Users,

I want to use a small part of the TMS570's flash memory to store a value (64 bit number) during runtime. If the controller is turned off an on again, the value should be restored from the flash memory. I could not find anything helpful about this topic in it's datasheet or the internet. Is there any example code for writing and reading flash memory during runtime? Any answer would be helpful.

Best regards
Michel

  • Hi Michel,

    TMS570LS0432 includes a 16KB flash memory bank for data storage (EEPROM emulation). You can find an example code project in HALCoGen's help file to work with this data flash bank.

    Regards,
    Sunil
  • Hello Sunil,

    thank you for your reply. I found an example code "C:\ti\Hercules\HALCoGen\v04.07.00\examples\TMS570LS04x_03x_02x\example_TI_Fee_Write_Read.c". I don't want to test the flash memory, so is the following code enough:

    #define BLOCK_NUMBER 0x01
    
    sint64 value = 0;
    
    void main() {
    	
    	TI_Fee_Init();
    	
    	readValue();
    	
    	// ...
    	
    	while (1) {
    		
    		if (/* value changed */) {
    			writeValue();
    		}
    		
    		// ...
    	}
    }
    
    void readValue() {
    	TI_Fee_Read(BLOCK_NUMBER, 0, &value, 8);
    }
    
    void writeValue() {
    	TI_Fee_WriteAsync(BLOCK_NUMBER, &value);
    }

    Then I'd like to ask the following questions:

    1. What's the difference between WriteSync and WriteAsync?

    2. I found that the block size is configured in ti_fee_cfg.c file, but where do I programm the adress where the value is stored in flash memory?

    3. What ist the TI_Fee_MainFunction() used for?

    Best regards

    Michel

  • Michel,

    I will forward your questions to the software team.

    Regards,
    Sunil
  • Hi Sunil,

    thank you for your answer. Since I left out this part in my software until now, I would be interested in an answer.

    Best regards
    Michel
  • Michel,

    My answers:

    1.WriteSync function completes writing of the data synchronously, i.e data is written to FlashBank 7 before the exit of the function.
    WriteAsync function accepts the write job, but actual writing of the data is done in TI_Fee_Mainfunction API.

    2.FEE driver takes care of writing to the free address in Bank 7. Application need not know the next free address to write. FEE driver takes care of moving the valid blocks to new sector(when the sector is full), erasing the sector etc.

    3. TI_Fee_MainFunction is used to complete asynchronous write/read jobs, moving the data to new sector(once the sector is full), erasing the sector and making it ready to be used.
  • Hi Vishwanath,

    so do I need to call this TI_Fee_MainFunction after calling TI_Fee_Init() like this:

    do {
    	TI_Fee_MainFunction();
    	delay();
    	Status=TI_Fee_GetStatus(0);
    }
    while(Status!= IDLE);

    Or does the init function call this itself?

    If I understood you correctly, I could use the TI_Fee_WriteSync() function in writeValue() function to avoid calling the above loop.

    Since I haven't used the EEPROM before all the space should be free.

  • Hi Michel,

    You need to call the TI_Fee_MainFunction as shown in example. TI_Fee_Init does not do it.

    Also, TI_Fee_MainFunction has to be called periodically even though you use TI_Fee_WriteSync( ). This is to make sure that once the sector is full, all valid data blocks are moved to new sector.