cancel
Showing results for 
Search instead for 
Did you mean: 

TRAVEO™ T2G

mandar_bhat
New Contributor

Hi ,

I am using sample code from TVII_Sample_Driver_Library_7.2.0 library example code of work flash

it is storing some data in workflash and reading data from work flash. ( I want to use this to store some application specific settings data similar to eeprom).

I implemented the sample function in my application and found that fault is generated and my call stack list is lost, as soon as i execute Erase API => (Cy_FlashSectorErase(SectorAddr, CY_FLASH_DRIVER_BLOCKING))

or also may be any other API related to work flash

As my call stack is lost , so after exiting this BasicWorkFlashBlockingTest function, my stack pointer cannot return to the place where this function was invoked, so sytem fault is generated.

I am running this code from M4 code-flash.

Microcontroller's M0+ Core is also initialized.

//***************************************************************************************

// Initialization
Cy_FlashInit(false /*blocking*/);

 

// Test for Small Sector
BasicWorkFlashBlockingTest(TEST_W_SS_ADDR, CY_WORK_SES_SIZE_IN_BYTE);

//***************************************************************************************

// In this routine, whole one sector erased/written/read/verified
void BasicWorkFlashBlockingTest(uint32_t SectorAddr, uint32_t SectorSizeInByte)
{
uint32_t* p_TestFlsTop = (uint32_t*)SectorAddr;

uint32_t SectorSizeInWord = SectorSizeInByte / 4ul;

/** Erasing **/
// Erase
Cy_FlashSectorErase(SectorAddr, CY_FLASH_DRIVER_BLOCKING);

// Verify
Cy_WorkFlashBlankCheck(SectorAddr, CY_FLASH_DRIVER_BLOCKING);

/** Programming **/
for(uint32_t i_addr = SectorAddr, i_addrOffset = 0; i_addr < SectorAddr + SectorSizeInByte; i_addr+=4, i_addrOffset+=4)
{
uint32_t i_dataPos = i_addrOffset % PROGRAM_DATA_SIZE_IN_BYTE;

// Flash
Cy_FlashWriteWork(i_addr, (uint32_t*)&programData[i_dataPos], CY_FLASH_DRIVER_BLOCKING);
}

// Verify
uint32_t* pProgramData = (uint32_t*)programData;
for(uint32_t i_wordId = 0; i_wordId < SectorSizeInWord; i_wordId++)
{
uint32_t i_dataPos = i_wordId % PROGRAM_DATA_SIZE_IN_WORD;
CY_ASSERT(p_TestFlsTop[i_wordId] == pProgramData[i_dataPos]);
}

/** Erasing Again **/
// Erase
/*Cy_FlashSectorErase(SectorAddr, CY_FLASH_DRIVER_BLOCKING); */

// Verify
/*Cy_WorkFlashBlankCheck(SectorAddr, CY_FLASH_DRIVER_BLOCKING); */
}

 

Please suggest any ideas to make it work.

Thanks in Advance.

 

 

 

0 Likes
1 Solution
yanf
Moderator
Moderator

Hi Mandar,

 

If I understand you correctly, you are using your own board design and a MCU from Infineon, right?

That will make some difference but for this particular instance, I think they are still the same if you use internal flash, which is implemented in MCU. 

I would suggest you use the address in SDL demo project first to do the test. Because there are some addresses that are forbidden to write on (or even read). Please refer to the TRM, Chapter 4.3.

And you should also change the project configuration profile (on the left upper in IAR) to rev_c according to your MCU.

Screenshot (27).png

 Then, the linker file should have been changed to " $PROJ_DIR$\..\..\linker_directives_tviibe.icf " now. You can double check it. 

Have a try if these settings bring it back to work.

Best Regards,

Finn

View solution in original post

0 Likes
10 Replies