S32K344 - Use Fee_Write and Fee_Read with Simulink

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

S32K344 - Use Fee_Write and Fee_Read with Simulink

2,125件の閲覧回数
rishikesh_c
Contributor III

I am trying to use the Fee APIs in AUTOSAR 4.4 with the NXP #S32K344 processor. On S32 Design Studio I found an example project called Fee_Example_S32K344 which does exactly what I am trying to do. However, my application is built with the MBDToolbox for the S32K3x series and I need to implement the functionality of this example project in my application. The MBDToolbox does not have any blocks for the FEE drivers.

I basically need to call the Fee_Write and Fee_Read calls from Simulink instead of a C code like in the example project.

How would I do this? 

0 件の賞賛
返信
10 返答(返信)

1,810件の閲覧回数
rishikesh_c
Contributor III

So I have managed to get the custom C code into my model thanks to @BillDuley's answer to the topic. But now I am facing a problem with the NVM read function. In the original Fee_Example_S32K344 provided by NXP, the Fls_MainFunction() and Fee_MainFunction() are called, after which the Fee_Status() is called and only once the status is read as MEMIF_IDLE the Fee_Read() or Fee_Write() calls can be made. Below is the code as in the example project as well is in the custom code (MATLAB function) block in my model

rishikesh_c_0-1708691651206.png

I am debugging my code line by line through S32 Design Studio, and the status variable in my model never goes to 1 (i.e MEMIF_IDLE). What can be the issue and how can I solve it?

0 件の賞賛
返信

1,957件の閲覧回数
BillDuley
Contributor III

My colleague identified the issue with my NVM code. I didn't utilize pointers correctly. Functional NVM code attached.

0 件の賞賛
返信

1,741件の閲覧回数
rishikesh_c
Contributor III

After testing the model for a while, I found the following issues and resolved them to make the model work properly. 

1 - The line coder.ceval('MemIf_StatusType status'); when converted to c code (since I was using S32 Design Studio for flashing the model on my board) translates to MemIf_StatusType status(); which caused errors since status() was being compiled as a function call. Removing this line from the MATLAB function block, the errors mentioned in the reply to this answer thread were resolved

2 - Not an issue from the model shared but rather on my end - you need to configure the FLS External Drivers the same way as in the model shared (also in the example code provided by NXP). Since I had not done this in my model, the Fee_GetStatus() never returned an idle state. This is why after following step 1, @BillDuley 's model worked on my board but my own did not.

I used S32 Design Studio version 3.4 for the MCAL configurations. Simulink version R2022a

1,950件の閲覧回数
rishikesh_c
Contributor III
Thanks for your answer. I am trying to follow your example, but I cannot find a .slx file in the folder you shared. Could you please share that? I want to know how the C code was implemented from the Simulink model.

Thanks a lot
0 件の賞賛
返信

1,888件の閲覧回数
BillDuley
Contributor III

The model is not an SLX, but .mdl. Then the C code is shown when you double click on the custom code blocks.

0 件の賞賛
返信

1,879件の閲覧回数
rishikesh_c
Contributor III

Thanks! I can open the model and access the custom code blocks now. 

However, I am facing some new problems. I exported the model to S32 Design Studio to build the code from there and I'm getting this error (attached image).

rishikesh_c_0-1708594776939.png


However, following the exact same process on the project folder you had shared, I did not encounter any errors. Are there any configurations I am missing? I followed the same structure as your project with the HeaderFile_NVM folder and put the path of this folder in the custom code blocks.

Regards

0 件の賞賛
返信

1,848件の閲覧回数
BillDuley
Contributor III

Once the project was in Simulink, I exclusively used FreeMaster and the included .pmpx. to debug and view the variables.

0 件の賞賛
返信

2,074件の閲覧回数
dragostoma
NXP Employee
NXP Employee

Hi, @rishikesh_c ,

Thank you for your interest into Model-Based Design Toolbox for S32K3.

Currently, the S32K3 Toolbox does not include support for Flash EEPROM Emulation (FEE) component.

Since we provide the complete RTD driver package, you may still implement the component Fee in our toolbox and access the Fee's API using custom code blocks.

Moreover, you have some examples in our toolbox (s32k3xx_isr_custom_code_ebt and s32k344_mc_bldc_ebt) where the application is using custom code. Beside the custom code examples, you should also check the following threads related to custom code usage:

https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/PWM-Capture-for-S32K3-in-Simulink/m-p/1...

https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/SENT-Protocol-Support-in-S32K3-MBDT/m-p...

You can also check the following topic How to use your own C code in our Toolbox (Battery Management System example). Here you will find an additional method of using custom code inside our toolbox.

 

Best regards,

Dragos

0 件の賞賛
返信

1,992件の閲覧回数
rishikesh_c
Contributor III

Hi @dragostoma,
I am trying to follow the examples provided. Here are the steps I have taken so far:

1 - From one of my NXP blocks in the model, I opened the configuration in S32 Design Studio and under Peripherals -> MCAL, added the Fee and Fls components.

2 - From my simulink configurations, under Hardware Implementation -> Hardware Board Settings -> Target Hardware Resources -> Tools Path, clicked on export.

3 - In S32 Design Studio, I imported this project so now the workspace in both S32 DS and Simulink is the same.

4 - In S32 DS I clicked on build project and here is the error I am getting:

../RTD/include/Fls_Types.h:51:10: fatal error: MemIf_Types.h: No such file or directory
51 | #include "MemIf_Types.h"
| ^~~~~~~~~~~~~~~
compilation terminated.
make: *** [src/subdir.mk:21: src/mbdt_board_init.o] Error 1

What am I missing? I haven't added any custom code blocks to my model yet

タグ(3)
0 件の賞賛
返信

1,972件の閲覧回数
BillDuley
Contributor III

I have the same goal - NVM in Simulink with C function calls. Attached is a zip file of my progress with Simulink calling C code (per the S32DS Fee example):

BillDuley_0-1708362065319.png

 

Perhaps someone can help me see why the values I attempt to write do not present in my Fee read function (I'm trying to read them in FreeMaster). (I did my work in the initialize block to limit my NVM cycles):

BillDuley_1-1708362365244.png

FreeMaster:

BillDuley_2-1708362515706.png

The Return_Write and Return_Read return a value of zero (happy), but my ReadNVM returns my default value off 0xAAFF, not the expected values per: "DataBlock0 = uint8([0x00, 0x01, 0x02, 0x03]);"

 

I don't want to hijack the thread, but I think we're on the same path... A little help with my code and we'll all be happy?

0 件の賞賛
返信