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.

TMS320F28388D: A question about the "Fapi_doBlankCheck" function

Part Number: TMS320F28388D

Hi,


I am using the controlCARD board (TMDCNCD28388D) and trying to write one 16-bit word of "0xFFFF" on a part of the flash memory. Then, I try to use the "Fapi_doBlankCheck" function to check whether this specific part of the memory (that I wrote 0xFFFF on) is blank (erased) or not. However, in this situation, when I read the output of this function, it says this part of the memory is not blank (erased state) while it actually has the value of 0xFFFF. So, it seems that this function only detects the fact that whether the flash is erased or not while it does not tell us anything about the fact that whether we can write on that part of the memory or not. I know that from the perspective of the Flash API, it is not a blank area because a value of 0xFFFF has already been written on that area. But, for my application, even this area with written 0xFFFF on them could be considered as the blank areas that have the capability of being written on them. So, is there any function or a way in the Flash API that I can use to detect the "erased and writable" part of memory?

Kind Regards,
Alex

  • Hi Alex,

    What is the address and length that you passed to the blank check function?  Please note that the length parameter is supposed to be a multiple of 32-bit word.  

    Also, could you send me a snapshot of the memory window showing 0xFFFF for that length?

    Thanks and regards,
    Vamsi

  • Hi Vamsi, 

    Thank you for your reply. On the flash of CPU1, the address and length that I passed are 0x08000 and 1 bytes, respectively. I try to write the following array on the address 0x80000 of flash memory: 

         uint16_t data[8] = {0x0001, 0x0002, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF};

    The picture below is a snapshot of memory when writing the array "uint16_t data[8]":

    And then use the blank check function as the following (for addresses 0x80001, 0x80002, and 0x80008):


    address = 0x80001;
    oReturnCheck_0 = Fapi_doBlankCheck((uint32_t*)address, 1, &oFlashStatusWord_0);
    address = 0x80002;
    oReturnCheck_1 = Fapi_doBlankCheck((uint32_t*)address, 1, &oFlashStatusWord_1);
    address = 0x80008;
    oReturnCheck_2 = Fapi_doBlankCheck((uint32_t*)address, 1, &oFlashStatusWord_2);

    As for the results, the function says the address 0x80001 is not blank but addresses 0x80002 and 0x80008 are blank. Then, I try to write a value on the address 0x80002 (which the blank check function has already confirmed that it is erased or blanked). However, after doing this, I can see that there is nothing has been written on that the 0x80002 of the memory. More specifically, I get the "Fapi_Error_AsyncIncorrectDataBufferLength" error from the write operation.

    Best,

    Alex

  • Alex,

    You mentioned "the address and length that I passed are 0x08000 and 1 bytes, respectively" - I hope you meant 0x80000 and not 0x8000.

    Coming to the addresses that you mentioned.  0x80002 and 0x80008 are blank but not 0x80001 - that is correct as per the screenshot that you posted.  Not sure what is incorrect here?  Please let me know if I am missing anything.  

    Regarding the error that you got:  Please search for "How many bits can be programmed at a time using Fapi_issueProgrammingCommand()? " in this FAQ page: https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/951668/faq-faq-on-flash-api-usage-for-c2000-devices 

    Thanks and regards,
    Vamsi

  • Vamsi,

    You mentioned "the address and length that I passed are 0x08000 and 1 bytes, respectively" - I hope you meant 0x80000 and not 0x8000

    Yes, you are right. It was a typo on my side and sorry for that.

    Coming to the addresses that you mentioned.  0x80002 and 0x80008 are blank but not 0x80001 - that is correct as per the screenshot that you posted.  Not sure what is incorrect here?  Please let me know if I am missing anything. 

    The thing that is incorrect here is that I wrote 0xFFFF on the address 0x80002 and the blank check function says that it is blank. So, after checking this address of the memory with the blank check function, I try to write another value (for example 0x0002) on this address (0x80002), but I get an error and also I can see on the memory browser window that nothing is written in this address. Despite the fact that the blank check function says this address is blank, it cannot be written by any value. So, my question is that how can I detect the "erased and writable" part of memory using Flash API or any other way?

    Note: I think I did not have to add other addresses in my above explanation and it seems made you confused. I am sorry for that. My focus was only on the 0x80002 where I wrote a 16-bit value of 0xFFFF and I faced the issue explained above.

    Regarding the error that you got:  Please search for "How many bits can be programmed at a time using Fapi_issueProgrammingCommand()? " in this FAQ page: https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/951668/faq-faq-on-flash-api-usage-for-c2000-devices 

    Thanks for sharing this link. However, I know how many bits can be programmed at a time using Flash API. Because I have been trying so many times to successfully write values on the flash. I think this problem is related to the issue that I explained above which is consequently related to the blank check function.

     Best,

    Alex

  • Alex,

    You are not able to program there because you might have programmed ECC using Fapi_AutoEccGeneration.  Even though the data is 0xFFFF, you might have programmed ECC - after programming ECC, you won't be able to program the data unless you are changing 1 -> 0 through your program command.

    Regarding the error that you got: You might have given a wrong data length for the given address - this is why I asked you to review that FAQ.  Can you tell the address and the length of the data that you used?  

    Thanks and regards,
    Vamsi

  • Vamsi,

    You are not able to program there because you might have programmed ECC using Fapi_AutoEccGeneration.  Even though the data is 0xFFFF, you might have programmed ECC - after programming ECC, you won't be able to program the data unless you are changing 1 -> 0 through your program command.

    Thanks for the explanation. Yes, I have exactly done the program command using "Fapi_AutoEccGeneration". Now, it is clear to me. So, can you please mention how I can use change the ECC from 1 -> 0? I can also see in the code that there are other types of program commands. Are these might be related to my issue as well? I mean should I change the program command that I use for the write operation to solve this issue?

    Regarding the error that you got: You might have given a wrong data length for the given address - this is why I asked you to review that FAQ.  Can you tell the address and the length of the data that you used?  

    The address is 0x80002 and the length of the data is 8.

    Best,

    Alex

  • Vamsi,

    Basically, what I am asking is how to know if an address whose content is {0xFFFF 0xFFFF 0xFFFF ...} is writable? What way do I have to distinguish the difference between an "erased" 0xFFFF and "previously written" 0xFFFF? 

    Thanks,

  • Alex,

    That is the reason then.  Thank you for the confirmation.

    An 8-bit ECC is calculated for every 64-bits of the flash data (aligned on 64-bit boundary).  Hence, once you program the flash data along with the ECC, you won't be able to program the data again in those 64-bits unless both the data and the ECC changes include only a 1->0 transition.  This is not practical in most cases.  Hence, I suggest you to erase it and reprogram as you need.  

    Please note that you should program at least 64-bits (aligned) at-a-time. If you can't program all the 64-bits at once, you can do this: First program 16-bits or 32-bits using Fapi_DataOnly mode.  In the second step, use Fapi_AutoEccGeneration mode, program the remaining data of that 64-bits along with the previously programmed data (in that 64-bits).  You should not give program command for more than two times for any given 64-bits of the flash (aligned). 

    Address of 0x80002 and the data length of 8 will cause the error that you mentioned previously.  And the reason is already given in the FAQ that I mentioned.

    Thanks and regards,
    Vamsi

  • Alex,

    Regarding your question on how to distinguish between erased and programmed flash:  You can check the corresponding ECC address for this.  If the ECC is not all 1s for the given 64-bit aligned flash, then you know you already programmed the ECC for it.

    Thanks and regards,
    Vamsi