I flashed a model in simulink using NXP MPC57xx toolbox, the built-in OpenSDA debugger, S32 Design Studio. Now I want to test that model on the board. Does the NXP MPC 57xx toolbox provide some means of sending inputs to the model flashed and getting output out of it?
Is there a manual or a tutorial on how to use Matlab's Processor-In-the-Loop (PiL) method for testing and verification of the flashed code that was generated from the model and deployed on NXP-MPC5748G board?
We already have an example in the MBDT Toolbox but I will attach and present here a short tutorial.
So PIL works like this: you need to create two models: the main one and a referenced one. For the main model I will name it 'top' (sim_pil_top_TC_mpc574x) and I will name the referenced model as 'target' (sim_pil_tg_TC_mpc574x).
This examples emulates HALL sensors signals, providing to the target the rotation Direction and PWM Duty Cycle, while the target will return back to the host the computed PWM representation.
For the top model, the example uses a model reference, the one which will be run on the board. The top model will run on the host and will exchange data through UART connection.
The following model is the target model, the one which will run on the MCU. Here you can see that it contains the config block, and the program that it will execute.
What is it important here is the config block. Here you need to select the target mcu type, package and sram size. Obviously you need to select in the Build Toolchain the compiler you want to use.
Target Connection tab is the most important one when it comes to PIL. You need to select the PIL Download mode.
The Serial subsystem provides the computer port on which the board is connected. For me, the board was linked to COM21, but it will choose another board on your PC. The baudrate represents the speed used for board flashing. Before you run this, you need to program the board with a bootloader. This means that you need to open Design Studio for PA and flash the right rbf for your board. You can find the rbf in the toolbox installation under the following path src\tools\BootLoader\RBF_Files.
The Pil settings represents the board Serial on which will communicate with the host PC. I used the MPC5748G-DEVKIT and the settings are Serial2 PC8/PC9.
Now you need to save and close the target model.
Go back to the top model, and if you are working to a new model, you need to set the referenced model to PIL mode. For the model attached it is not necessary, because I already did that. To set, you need to select the referenced model, go to Tools and select, as in the image, 'To PIL Mode on MPC574x'.
All this been set, now you need to run the code. Press the 'RUN' button and wait to generate and build the code. When the code has been compiled, a window will appear. Now you need to reset the board and press the OK button.
The bootloader will erase and flash the board. After this process is complete. The code will be run and the data transferred back to the host.
When the process is complete, if you open the Scope, the same results as in the attached image will be displayed.
Obviously this is a simple example, but the workflow for your need will be the same.
If you have any other questions, feel free to reply here.
Another nice tool you can use is the FreeMaster. But you should choose it depending to your use case.
Hope this helps,
For all the parts that NXP MPC57xx toolbox supports, you can achieve the communication you need in two ways:
1. Using the Matlab's Processor-In-the-Loop (PIL) method in which the model automatically generates, compiles, flashes the code on the board and exchanges data with the board for later results comparison or code profiler. You can find a some examples in the pil example folder. This method uses the UART serial communication.
2. Using NXP's FreeMASTER Run-Time Debugging Tool | NXP which comes with MBD toolbox. This is a real-time debug monitor and data visualization tool, enabling run time configuration and tuning of applications. Most of our application examples already comes integrated with FreeMaster for data visualization on the user's computer. The communication can be achieved over Serial communication or CAN.
Hope this helps,