S32K1xx EEPROM HardFault

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

S32K1xx EEPROM HardFault

2,337件の閲覧回数
zorz
Contributor II

HI 

I have a project running FreeRTOS, UART, SPI, I2C ... and using S32DS.  All of this is running ok. Now I need to store some data to EEPROM. 

I used  flash_partitioning example to get to know the driver to write to EEPROM.

First I initialise the driver 

/* Always initialize the driver before calling other functions */
ret = FLASH_DRV_Init(&Flash_InitConfig0, &flashSSDConfig );
/* Config FlexRAM as EEPROM if it is currently used as traditional RAM */
if (flashSSDConfig.EEESize == 0u)
{
/* Configure FlexRAM as EEPROM and FlexNVM as EEPROM backup region,
         * DEFlashPartition will be failed if the IFR region isn't blank.
* Refer to the device document for valid EEPROM Data Size Code
* and FlexNVM Partition Code. For example on S32K116:
* - EEEDataSizeCode = 0x03u: EEPROM size = 2 Kbytes
* - DEPartitionCode = 0x03u: EEPROM backup size = 32 Kbytes */
ret = FLASH_DRV_DEFlashPartition(&flashSSDConfig, 0x03u, 0x03u, 0x0u, false, true);
 
 
/* Re-initialize the driver to update the new EEPROM configuration */
ret = FLASH_DRV_Init(&Flash_InitConfig0, &flashSSDConfig);
 
 
/* Make FlexRAM available for EEPROM */
ret = FLASH_DRV_SetFlexRamFunction(&flashSSDConfig, EEE_ENABLE, 0x00u, NULL);
}

 

 

Than I write to eeprom 

if (flashSSDConfig.EEESize != 0u)
{
address = flashSSDConfig.EERAMBase;
FLASH_DRV_EEEWrite( &flashSSDConfig, address, 4, write_E_data );
 
 
if (*((uint32_t *)write_E_data) != *((uint32_t *)address))
{
/* Failed to write data to EEPROM */
// exit_code = 1u;
return 1;
}
 
What happens is: 
1. if I RUN this code .. the applicaton hit the HardFault_Handler() ..always.. and this is happening in the FLASH_DRV_EEEWrite() function 
2. if i SINGLE step the FLASH_DRV_EEEWrite() function the application works OK .. it is NOT hitting the HardFault_Handler()
3. I can see the data stored in the EEPROM 
 
Does anybody have any idea why this is happening? I am using J-link if this plays any role in the equation.
 
Br zorz
 
0 件の賞賛
返信
5 返答(返信)

2,316件の閲覧回数
Senlent
NXP TechSupport
NXP TechSupport

Hi@zorz

Please turn off all interrupts before writing to EEPROM and try again.

0 件の賞賛
返信

2,313件の閲覧回数
zorz
Contributor II

HI 

 

Tested .. does NOT help 

 

BR zorz

0 件の賞賛
返信

2,309件の閲覧回数
Senlent
NXP TechSupport
NXP TechSupport

Hi@zorz

could you please provide the demo code,

you can take a look the application note first, and I will help you to test it next week.

https://www.nxp.com/docs/en/application-note/AN11983.pdf 

0 件の賞賛
返信

2,245件の閲覧回数
zorz
Contributor II

HI 

I have "found" the solution .. but I do NOT understand why that is the case

What i found is if I install the 

pCallBack = (flash_callback_t)CCIF_Callback;
flashSSDConfig.CallBack = pCallBack;

before the 

FLASH_DRV_Init

I get the FAULT !

 

but if 

FLASH_DRV_Init is done  and than 

pCallBack = (flash_callback_t)CCIF_Callback;
flashSSDConfig.CallBack = pCallBack;

it works fine .. i do not understand why.

 

br zorz

 

0 件の賞賛
返信

2,206件の閲覧回数
Senlent
NXP TechSupport
NXP TechSupport

Hi@zorz

modifed the code as you did,the hardware base on S32K142EVB, the demo name is "flash_partitioning_s32k142"  

here you can see it works fine on myside,

Senlent_0-1699236038808.png

 

0 件の賞賛
返信