Hi all,
As usual, we need to performs multiple Flash Program operation during, for eg, ECU firmware updates.
Below the interface
sint16 FLASH_Program (uint32 address, uint32 size, uint8 * source)
{
sint16 res = 0;
C40_Ip_VirtualSectorsType virtualSector = 0u;
C40_Ip_StatusType C40Status = STATUS_C40_IP_SUCCESS;
/* Get virtual Sector number from address */
virtualSector = C40_Ip_GetSectorNumberFromAddress(address);
/****************************************************/
/* USE MAIN INTERFACES FOR FLASH JOBS */
/****************************************************/
/* Unlock sector if needed */
if (STATUS_C40_IP_SECTOR_PROTECTED == C40_Ip_GetLock(virtualSector))
{
C40Status = C40_Ip_ClearLock(virtualSector, FLS_MASTER_ID);
if(STATUS_C40_IP_SUCCESS != C40Status)
{
return(sint16)C40Status;
}
}
/* Write data */
C40Status = C40_Ip_MainInterfaceWrite(address,size,source,FLS_MASTER_ID);
if(STATUS_C40_IP_SUCCESS != C40Status)
{
return(sint16)C40Status;
}
do
{
C40Status = C40_Ip_MainInterfaceWriteStatus();
}
while (STATUS_C40_IP_BUSY == C40Status);
/* Re-lock sector after program operation */
C40Status = C40_Ip_SetLock(virtualSector,FLS_MASTER_ID);
if(STATUS_C40_IP_SUCCESS != C40Status)
{
return(sint16)C40Status;
}
return(res);
}
After putting the function call inside a for(;;) in the main translation unit, I try to update the address 0x500000, w/o any problem

Calling the API a second time on address 0x500070 with the same input source, this is the result

It seems like the C40 driver does not write four lines of Flash.
Then I use the address 0x5000A0, and the driver works as expected

I have repeated multiple tests using different address, and sometimes not all the flash lines are programmed as expected. In the picture below you could find the flash layout after 80 bytes programming on 0x500000/500080/500100/500160

All suggestions would be very appreciated!
B.R.
Andrea