EEPROM functionality on S32K1xx

Showing results for 
Search instead for 
Did you mean: 

EEPROM functionality on S32K1xx

Contributor IV


we need to store some configuration parameters in non-volatile memory of S32K116. At the moment we test on S32K144 dev-kit.
Our application is very cost sensitive and we want to avoid installing additional EEPROM on the board.
The S32K has 2-4 kB of EEPROM implemented as a combination of FlexRAM and FlexNVM that can be used for that purpose.
As I see there are no ready-to-use simulink blocks for this. Am I right ?

Can I at least use DataMemWrite and DataMemRead to access FlexRAM ? This way the only thing that should be implemented by hand is the FlexNVM/FlexRAM initial configuration...
What is Your recommended way of adding such additional custom initialization ?

What are my options ?

Thanks for help

Tags (2)
3 Replies

NXP Employee
NXP Employee

Hello Maciek‌,

Unfortunately, we do not have blocks that covers this functionality, so it can be achieved by using custom code. 

However, there are multiple ways to do that:

1. Using C-Code function

This method assumes to insert an S-Function Builder block, that will call the code you need via a wrapper. You will also need to modify the  mbd_s32k_user_copy_required_files.m script that comes with the toolbox and copies the driver files for the flash. You can have a look on the following links for an example. 

2. Using Custom Code blocks from Simulink Coder

This method is easier, allowing you to directly type the C code inside one of those blocks. The problem is that this does no allows you to provide data as an usually output port of tha block,  so you will need to use a Data Store Memory block as volatile and to manually assign the value read from the EEPROM to that variable. The following thread offers a short description. You will still need to modify the mbd_s32k_user_copy_required_files.m  script as for the first method. 

3. Using MATLAB Function Block

This method lets the user to call the custom code using the Matlab Coder, from inside a Matlab Function block. And you can easily get the data read from EEPROM and provides it to an output port, just like a regular Simulink Block. The following link provides the Documentation from Mathworks.

Integrate C Code Using the MATLAB Function Block- MATLAB & Simulink 

I think the easiest method to use in this scenario, calling SDK driver functions is the third one. I will provide a tutorial on how to integrate C Code Using the Matlab Function Block soon. I will notify you when the tutorial will be published!

Hope this helps,


0 Kudos

Contributor IV

Thanks for quick answer mariuslucianandrei,

if the initialization code of the EEPROM driver is called from the separate matlab function block: is it a good idea to insert this block inside the 'Initialize' simulink block ? Or is it better to call it only once, at the start of the model using (for example) function call subsytem or stateflow ? 

And what about the DataMemWrite and DataMemRead to access FlexRAM ?

0 Kudos

Contributor II

HI ,

I also have the same concern. Please provide your suggestion.

Thanks in advance