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.

CCS/TMS320F28377D: Flash reading issue from code

Part Number: TMS320F28377D


Tool/software: Code Composer Studio

Hello,

I'm developing a code that stores some data for configuration purpose into flash. I'm using the Flash F021 API. I'm able to store all the parameters I need and I can read most of them after CPU reset. The problem appears at some flash addresses where I'm able to see the correct value from the memory browser tab of the CCS but when the value is copied into a local variable, a bit is set to 1 (something that is not possible without erasing the whole flash sector):

 
    uint16_t u16TempBuf;

    u16TempBuf = *ptInstance->pu16ReadPoint;

Being pu16ReadPoint a pointer to the desired Flash address. For example, If the value in the flash is 0x0010, when it is copied to the variable u16TempBuf I'm reading a 0x0410.

This occurs only at some addresses and it is repetitive, so every time I load the code, the same addresses are being affected (I'm always storing the same data).

I need to do something special to read the content at Flash addresses for a reliable reading?

Thank you!

  • Javier,

    How are the system frequency and the wait-states configured?

    Thanks and regards,
    Vamsi
  • System frequency is 200 MHz and RWAIT is set to 3. I have tried to increase RWAIT until 8, but the result is the same.

    Also I have tried to remove data chache and prefetch, but It is still reading incorrectly.

    I will keep you updated if I figure out something.

    Thanks
  • Javier,

    You have configured the waitstates correctly as per the frequency.

    You said that you can see the correct data in Flash through the debugger memory window after you program. That tells me that you programmed correctly. But just in case, did the verify pass successfully after the program?

    Did you use AutoEccGeneration mode to program the ECC for your data?

    Thanks and regards,
    Vamsi
  • Hello Vamsi,

    First of all, thank you for your fast replies.

    I think I have fixed the issue, but I'm still verifying all the data in flash. I was not not using the AutoEccGeneration because it fails if I write twice the same bank (at different addresses) due to the autoECC generation, so I was using Data_only mode. In that mode the verification was failing but data inside the flash is ok. I was writting twice the same bank at different addresses because my application doesn't know the size of the incomming data.

    I started to think that I need to write ECC too (I'm not sure about this part), so I was writting that part once I wrote 64 bits into flash using Ecc_only mode and the Fapi_calculateEcc, but something I did wrong because verification and readings fails too.

    So finally, I have changed my code to have a small buffer of 64 bits so I write the flash only when this buffer is full and then I can use the AutoEccGeneration and verification and readings seems to work as expected.

    I will keep this solution, but just to know, is it possible to write data and ecc independently for F28377D device?
  • Javier,

    You can program data and ECC separately - However, as mentioned in SPNU629 document, there is a restriction that all the 64-bits of data should be programmed at a time.  So, if you are using Flash API on the target MCU, best way to achieve ECC is using AutoEccGeneration.

    If you want to program 64-bits of data and it's ECC separately, you can use Fapi_calculateEcc() function to calculate ECC and program using EccOnly mode.  Note that Fapi_calculateEcc() needs you to left shift the address provided to it as mentioned in SPNU629.  Again, you have to program all the 64-bits of data at a time though.

    Thanks and regards,
    Vamsi