S32K344 EHV

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

S32K344 EHV

535 Views
CHYYDS
Contributor II

Hello everyone!!!
I encountered the following problem while using the C40 Flsah erase function of the RTD in S32K344:

The first time I called the function area to write data, the code is as follows:↓

C40Status=C40_Ip_MainInterfaceWrite(i_startAddr,i_dataLen,i_pDataBuf, 0);

On the second call, C40Status returns STATUS_ C40_ IP_ Error.
I entered the function and found that an error occurred here:↓

C40_Ip_MainInterfaceWritePreCheck()
{
......
  /* Verify that EHV may be set */
  else if (0UL != (C40_Ip_pFlashBaseAddress->MCR & (FLASH_MCR_ERS_MASK |         FLASH_MCR_PGM_MASK)))
  {
      ReturnCode = STATUS_C40_IP_ERROR;
  }
......
}

May I ask what the problem is? What is EHV? I'm a bit confused. Could you please explain, thank you very much!!!
May I ask how can I solve this situation? Thank you!!

 

0 Kudos
3 Replies

503 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi @CHYYDS 

that's expected behavior. This is asynchronous driver. Function C40_Ip_MainInterfaceWrite will only initiate the write operation and then it exits. You are supposed to call C40_Ip_MainInterfaceWriteStatus after that. You can take a look at this example:

c:\NXP\S32DS.3.5\S32DS\software\PlatformSDK_S32K3\RTD\Fls_TS_T40D34M30I0R0\examples\S32DS\S32K3XX\C40_Ip_Example_S32K344\

 

/* Write data */
C40_Ip_MainInterfaceWrite(FLS_SECTOR_ADDR, FLS_BUF_SIZE, TxBuffer, FLS_MASTER_ID);
do
{
C40Status = C40_Ip_MainInterfaceWriteStatus();
}
while (STATUS_C40_IP_BUSY == C40Status);
/* Check job result */
Fls_ExampleAssert(STATUS_C40_IP_SUCCESS == C40Status);

 

Regards,

Lukas

0 Kudos

493 Views
CHYYDS
Contributor II
0 Kudos

495 Views
CHYYDS
Contributor II

Thank you for your reply!

Your code is from C40_ Ip_ Example_ Is it in S32K344?

I referred to one of the methods, but the result was not satisfactory.

Let me share my thoughts:

I am trying CAN BOOT. The upper computer sends two frames of data, and the lower computer calls its own function FLASH every time it receives it_ HAL_ WriteData() for Flash writing. This function mainly unlocks and then writes Flash based on the amount of data written. The main writing code is as follows (see the else branch at the end for details).

 

 

 boolean FLASH_HAL_WriteData(const uint32 i_startAddr,
								   const uint8 *i_pDataBuf, 
								   const uint32 i_dataLen)
{
    boolean retstates = FALSE;
	uint8 lessWriteLen = 8u;
	uint8 aDataBuf[8u] = {0xFFu, 0xFFu, 0xFFu, 0xFFu, 0xFFu, 0xFFu, 0xFFu, 0xFFu};
	uint32 writeDataLen = 0u;
	uint8 index = 0u;
	uint32 sectorLength = 0u;
	C40_Ip_StatusType C40Status;
	C40_Ip_VirtualSectorsType VirtualSector;
	C40_Ip_VirtualSectorsType endVirtualSector;
	
	sectorLength = 8192U;
	VirtualSector = (i_startAddr - 0x400000u)/sectorLength + FLS_MAX_DATA_SECTOR;
	endVirtualSector = ((i_startAddr + i_dataLen) - 0x400000u) / sectorLength + FLS_MAX_DATA_SECTOR;

	while(VirtualSector <= endVirtualSector) 
	{
		if(STATUS_C40_IP_SECTOR_PROTECTED == C40_Ip_GetLock(VirtualSector))
		{
			C40_Ip_ClearLock(VirtualSector, 0);
		}

		VirtualSector++;
	}

	DisableAllInterrupts(); 
	if(i_dataLen  & (lessWriteLen - 1)) 
	{
		......
	}
	else 
	{
		retstates = TRUE;
		C40Status=C40_Ip_MainInterfaceWrite(i_startAddr,i_dataLen,i_pDataBuf, 0);
		do
		{
			C40Status = C40_Ip_MainInterfaceWriteStatus();
		}
		while (STATUS_C40_IP_BUSY == C40Status);

		if(STATUS_C40_IP_SUCCESS != C40Status)
	    {
	    	retstates = FALSE;
	    }

	}
	EnableAllInterrupts();
	
	return retstates;
}

 

 

But during debugging, it was found that FLASH_ HAL_ WriteData() returns a successful operation, but all the data written to the Flash area is 0xFF, which is not what I expected. In theory, this is considered a write failure, but the return value is STATUS_ C40_ IP_ SUCCESS has no problem.
I was wondering if my understanding was incorrect and there was a problem with the method of calling the function? Or is it caused by frequent unlocking of Flash. I hope you can give me some guidance, thank you very much!!!

0 Kudos