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/TMS320F28379S: NMI ISR being triggered after Calling WDCR Reset.

Part Number: TMS320F28379S
Other Parts Discussed in Thread: C2000WARE

Tool/software: Code Composer Studio

Hey,

I have a device that utilizes the flash API on the TMS320F28379S. However, whenever I call a these two lines to reset the microprocessor:

WdRegs.WDCR.all = 0x28;
WdRegs.WDCR.all = 0x00;

The device eventually ends up frozen in the NMI ISR routine.

There are several errors in the Flash0EccRegs after attempting to overwrite the flash, as an example, ERR_STATUS reads 0x00060002. SINGLE_ERR_ADDR_LOW reads 0x00088008. SINGLE_ERR_ADDR_HIGH reads 0x00088004. The code to write the flash is listed below, it is largely taken from the example in control suite.

void Program_FlashAPI(void)
{
	Fapi_StatusType oReturnCheck;
	volatile Fapi_FlashStatusType oFlashStatus;
   Fapi_FlashStatusWordType oFlashStatusWord;
	uint32 u32Index = 0;
    uint16 i = 0;

	EALLOW;
	PUMPREQUEST = 0x5A5A0002;           // Give pump ownership to FMC0(Bank0)

	oReturnCheck = Fapi_initializeAPI(F021_CPU0_W0_BASE_ADDRESS, 194);
	if(oReturnCheck != Fapi_Status_Success)
	{Example_Error(oReturnCheck);}

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

	oReturnCheck = Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector, (uint32 *)FLASH_SectorE_start);

	while(Fapi_checkFsmForReady() != Fapi_Status_FsmReady){}
	
	oReturnCheck = Fapi_doBlankCheck((uint32 *)FLASH_SectorE_start, FLASH_64KSectorE_u32length, &oFlashStatusWord);
	if(oReturnCheck != Fapi_Status_Success)
	{Example_Error(oReturnCheck);}

	// Program Sector E
	for(i=0, u32Index = FLASH_SectorE_start; (u32Index < (FLASH_SectorE_start + WORDS_IN_FLASH_BUFFER)) &&
	(oReturnCheck == Fapi_Status_Success); i+= 8, u32Index+=8)
	{
		//
		// Issue program command
		//
		oReturnCheck = Fapi_issueProgrammingCommand((uint32 *)u32Index, (uint16 *)EEPROM_52.Buffer+i, 8, 0, 0, Fapi_DataOnly);
		//
		// Wait until the Flash program operation is over
		//
		while (Fapi_checkFsmForReady() != Fapi_Status_FsmReady){}
		if(oReturnCheck != Fapi_Status_Success)
		{Example_Error (oReturnCheck);}
		oFlashStatus = Fapi_getFsmStatus();
		if(oFlashStatus != 0)
		{
			//
			//Check FMSTAT and debug accordingly
			//
			//FMSTAT_Fail();
		}
		//
		// Verify the programmed values
		//
//		oReturnCheck = Fapi_doVerify((uint32 *)u32Index, 4, FLASH_SectorE_start + i, &oFlashStatusWord);
//		if(oReturnCheck != Fapi_Status_Success)
//		{
			//
			// Check Flash API documentation for possible errors
			//
//			Example_Error(oReturnCheck);
//		}
	}

	PUMPREQUEST = 0x5A5A0000;
	EDIS;
//
// Example is done here
//
///Example_Done();
}

There also appears to be several errors reading the flash, where a location will have 0x0000 stored, will be read as 0x0200. While reading the flash, I simply have this subroutine to read the information that is pointed to:

void Load_Flash_Buffer(void)
{
	Uint16  i;
	Uint16  *Flash_ptr;     // Pointer to a location in flash
	Flash_ptr = (Uint16*)EEPROM_Copy;
	for (i=0; i < 256; i++)
	{
		EEPROM_52.Buffer[i] = (((unsigned char)*Flash_ptr) & 0xFF);
		Flash_ptr++;
	}
}

Is there any particular reason why these errors are being thrown, and is there a standard code I should follow besides the control suite example for writing and reading to a certain location in flash?

  • Robert,

    When programming Flash, you need to program ECC as well. As per your code snippet, you are not programming ECC.  Hence are the errors.

    In your code, the last parameter sent to Fapi_issueProgrammingCommand() is Fapi_DataOnly. 

    You can use Fapi_AutoEccGeneration instead. This will cause Flash API to calculate and program the ECC for you. You might have noticed the same in the example provided in C2000Ware.

    Note that you need to program either 64-bits or 128-bits at-a-time (ECC gets calculated for every 64-bits and the max number of bits that you can program in a single program function call is 128-bits) on a 64-bit or 128-bit aligned memory.

    You can read more about it in below resources:

    1. F2837xS Flash API (V1.55) reference guide link: http://www.ti.com/lit/pdf/spnu630

    2. Flash API and ECC wiki: http://processors.wiki.ti.com/index.php/C2000_Flash_FAQ

    Let me know if you have further questions on this.

    Thanks and regards,

    Vamsi

  • Vamsi,

    Thank you, the Fapi_AutoEccGeneration seems to have fixed the FLASH read and writes. The program is no longer getting caught in the NMI ISR.

    However, I have tried a couple of iterations of sending the reset command to the microprocessor after a successful initialization. The first microprocessor reset appears successful, but a second reset seems to lock up the microprocessor in code that I cannot view.

    The code I am calling is as mentioned below, it is tied to receiving a specific I2C command:

    WdRegs.WDCR.all = 0x28; 
    WdRegs.WDCR.all = 0x20; 

    To clarify, I wait for initialization to finish, call this reset command; then wait for initialization to finish again, and call this command, causing the microprocessor to lock up.

    The strange thing about the second microprocessor reset is that the WDCR in WdRegs reads 0x00C0. Despite the fact my commands are not affecting that 'reserved' spot in the register. Is there any reason for this?

  • Robert,

    I would suggest to start a new thread on this question. We will assign it to the SystemControl expert to help you further.

    Thanks and regards,
    Vamsi