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.

TMS320F28379D: Internal Flash Access programming , unable to understand Fapi_doVerify API, please check my below code and give response on my query

Part Number: TMS320F28379D
Other Parts Discussed in Thread: C2000WARE

Hi ,

             This code snippet I have taken from this example path : C:\ti\c2000\C2000Ware_4_02_00_00\device_support\f2837xd\examples\dual\flash_programming\cpu01

Buffer[0] = 'A';
for(i=0, u32Index = Bzero_SectorJ_start;
(u32Index <= Bzero_SectorJ_End) &&
(oReturnCheck == Fapi_Status_Success); i+= 1, u32Index+= 1)
{ // Issue program command
oReturnCheck = Fapi_issueProgrammingCommand((uint32 *)u32Index,
Buffer,1,0,0,Fapi_DataOnly);

// Wait until the Flash program operation is over
while(Fapi_checkFsmForReady() == Fapi_Status_FsmBusy);

if(oReturnCheck != Fapi_Status_Success)
{
Example_Error(oReturnCheck);
}
// Read FMSTAT register contents to know the status of FSM after
// program command to see if there are any program operation related errors
oFlashStatus = Fapi_getFsmStatus();
if(oFlashStatus != 0)
{
// Check Flash API documentation for possible errors
Example_Error(oReturnCheck);
}

// Verify the programmed values
oReturnCheck = Fapi_doVerify((uint32 *)u32Index,
0, (uint32*)(Buffer),
&oFlashStatusWord);


if(oReturnCheck != Fapi_Status_Success)
{
Example_Error(oReturnCheck);
}
}

My Query :
1. The Data 'A' is flashed in all addresses of Sector J, and I am able to read even I do power off to ON of the microcontroller.

2. This line of statement Fapi_doVerify((uint32 *)u32Index,0, (uint32*)(Buffer),&oFlashStatusWord);   I have passed arguments by doing trail and error method, so when I have passed those arguments as 0 and (uint32*)(Buffer) then I have got Fapi_Status_Pass and the data 'A' was also programmed in flash.

I want to know the calculation or analysis, that how this has been happened, even I have followed with Flash API document( https://www.ti.com/lit/ug/spnu629a/spnu629a.pdf?ts=1681972192498&ref_url=https%253A%252F%252Fwww.ti.com%252Fproduct%252FTMS320F28379D ), but still I am unable to understand it.

3. Fapi_StatusType Fapi_doVerify( uint32 *pu32StartAddress,uint32 u32Length, uint32 *pu32CheckValueBuffer, Fapi_FlashStatusWordType *poFlashStatusWord) what this uint32 u32Length, uint32 *pu32CheckValueBuffer it means, please give me some examples for writing single word/ multiple word in flash address.

Thanks,

Sid C

  • Sid,

    1. The Data 'A' is flashed in all addresses of Sector J, and I am able to read even I do power off to ON of the microcontroller.

    Yes, once the program is complete the contents will remain from power cycle to power cycle.  To be clear, removing power from the device during programming should be avoided, any interruption of the flashing process(either XRSn or power loss) will result in undefined flash state and may be unrecoverable.

    2. This line of statement Fapi_doVerify((uint32 *)u32Index,0, (uint32*)(Buffer),&oFlashStatusWord);   I have passed arguments by doing trail and error method, so when I have passed those arguments as 0 and (uint32*)(Buffer) then I have got Fapi_Status_Pass and the data 'A' was also programmed in flash.

    I think that since a "0" value is being passed as the length of the region to check this will always pass since there is nothing for the function to check.  Realistically a passed value of 0 is not really valid

    3. Fapi_StatusType Fapi_doVerify( uint32 *pu32StartAddress,uint32 u32Length, uint32 *pu32CheckValueBuffer, Fapi_FlashStatusWordType *poFlashStatusWord) what this uint32 u32Length, uint32 *pu32CheckValueBuffer it means, please give me some examples for writing single word/ multiple word in flash address.

    So u32Length is the number of 32-bit words in flash you want to check.  Recall that C2000 is a 16-bit word MCU, so 1 32-bit words would be equivalent to a "long" here.  The *pu32CheckValueBuffer is the address of the buffer(likely in RAM or ROM) that you want to use to verify the flash contents against.

    If this function does not return a pass, the *poFlashStatusWord will contain what was read at the location that failed against the buffer match.

    Best,
    Matthew