The NXP i.MX RT1xxx Toolbox enables automatic code generation for peripherals and applications prototyping from MATLAB/Simulink for NXP’s i.MX RT 117x, 106x & 101x Series of crossover MCUs.
The toolbox can be installed from Matlab add-ons page:
The novelty of this NXP toolbox is the integration with MCUX Configuration Tool for platform initialization. This configuration tool is being leveraged for pins settings, clock configuration and peripheral initialization. The toolbox is also integrated with the MCU SDK and will use the SDK API for code generation.
This article details the steps to start building new models and deploy them on the i.MX RT106x,
i.MX RT1010 & i.MX RT 117x MCU, showcasing also the integration with the MCUX Configuration Tool.
Below are the steps to start creating a Simulink model that will be deployed on the i.MX RT1xxx boards.
Step 1: Better to start on clean so first lets create folder to be used as workspace and switch MATLAB current folder to point to this workspace location:
Step 2: Create a Simulink Blank Model.
Step 3: Save and name your new model (E.g. mytest.slx).
Step 4 : Choose the NXP IMXRT hardware board from the Model Settings in the MODELING tab.
Step 4.1: Open Model Settings -> Hardware Implementation menu
Step 4.2: Select the NXP target from Hardware Board. This selection should match the evaluation kit you plan to test the code for. After the selection is made, press the Apply button.
After the target is set, the workspace will be populated with new files and folders:
The user can now add Simulink blocks in the model from the NXP i.MXRT1xxx Simulink library from Simulink Library Browser:
Choose the desired block to add to the model:
Alternatively, if the user will add in his/her model a peripheral block without configuring the target, a default one will be set that the user can change it afterwards.
As mentioned at the beginning of this article, the platform initialization, including pins, clock and peripherals settings is done using the MCUX Configuration Tool.
As seen in the previous chapter, when a Simulink model is being created with one of the NXP IMXRT targets, the workspace will be populated with a file having the extension .mex – this is the configuration file that will be used in the initialization code of the platform.
The user has the option to modify the default selections found in the .mex file. For this, open any peripheral block within the model and press the Configure button.
This action will open the MCUX Configuration Tool.
From MCUX Configuration Tool, the user can change default settings of the peripherals – enable or disable instances, from Pins view, it can configure/update pins settings of the platform.
After the user is done with configuration in MCUX Configuration Tool, he/she must go back in Simulink and press the Update button in the same block, for the changes to be visible in Simulink also.
The new initialization settings, will be included in the Build Model step. The Toolbox will trigger a code generation starting from the .mex file. The generated files will be saved in the <model_name>Config folder, in board folder.
Note, that is not a prerequisite for the user to have MCUX Configuration Tool installed, the toolbox incorporates all the tools that are need for the user to create, configure, build and deploy the model.
The default MCUX Configuration Tool used can be changed from Model Settings/Hardware Parameters / Tools Path, and the user can provide his/her own installation of the tool. Same approach is used with the SDK platform. The toolbox incorporates the release version of the SDK for the IMXRT1xxx targets. Also this path can be changed by the user, but it must consider possible integration issues of the toolbox with the user specified SDK.
After the Simulink model is completed, follows the build and deployment of the model on the target board. Before Build and Deploy, the user must set the download method of the application.
Step 1: Select the Download method from Hardware Implementation in Model Settings.
The default Download method (without the need for additional software and/or hardware probes) is OpenSDA. For this, the user must select the Drive on his/her machine where the OpenSDA firmware of the board is mapped after the NXP evaluation board is plugged in via USB.
Step 2: Build & Deploy Model
Step 3: After the code is generated and downloaded on the board a window will pop up and tell you to restart the evaluation board. Restart the board and then press OK.
Congratulations! You have successfully created and deployed your Simulink model to the hardware.