How to store and read last data from non-volatile memory?

表示  限定  | 次の代わりに検索 

How to store and read last data from non-volatile memory?

Contributor III

Hello everyone,


This is Ozan and I am using S32K144, mbdt v4.2 and Matlab 2020a. I try to modify the BMS example in the toolbox. The example model provides several information such as cell voltages, pack voltage, cell temperature and pack current. 

I want to built a model which acts as simple Coulomb counter. The main goal is sum the pack current over period of time sample, subtract this summed value from remaining capacity and divide this over total capacity and store this data as packSOC (after multiplying with 100 for %). The model details and ss are provided below.

After calculating the packSOC I want to store this value in non-volatile memory in case the board is powered off. And I want to read this value and start SOC calculation from this stored lastSOC value. 

I observe non-sense and constantly floating values from Freemaster when I upload this model. I think the problem is related with initialization. 

I stuck with this problem quite a while and any help will be appreciated. Thanks in advance. 

The model ss:






0 件の賞賛
1 返信

NXP Employee
NXP Employee

Hello @oeren5 ,


Well, from the screenshot you have attached, it looks like you are reading the data stored every time when the model executes the step function. 

I think you should only read once, at the beginning of the program, the value stored for the CC_SOC. To do that, I would declare a flag variable with an IF statement to be executed only once at the beginning of the step function.


After each new computation of the CC_SOC, you can store the new value in flash just like you already do.

Hope this helps,



0 件の賞賛