Getting started with NXP i.MX RT1xxx Simulink Toolbox

cancel
Showing results for 
Search instead for 
Did you mean: 

Getting started with NXP i.MX RT1xxx Simulink Toolbox

No ratings

Getting started with NXP i.MX RT1xxx Simulink Toolbox

1.  Introduction

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:

nxa11767_0-1622534922260.png

 

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.

2.  Start creating your model

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:

nxa11767_2-1622535469407.png

 

Step 2: Create a Simulink Blank Model.

nxa11767_1-1622535442991.png

 

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

nxa11767_3-1622535512950.png

        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.

nxa11767_4-1622535577272.png

After the target is set, the workspace will be populated with new files and folders:

  • A file with extension <model_name>Config.mex – this is the file created with MCUX Configuration Tool that is used for pins, clock, and peripherals initialization. This configuration file will have enabled the peripherals that are supported by the toolbox. Starting from this, the user can change the default configuration for any of the peripheral instances (add new instances, disable instances, etc.) and also any of the configured pins.

 

  • A folder with naming pattern <model_name>Config -  this folder will have a structure that is similar to the MCUXpresso IDE projects, and will contain the SDK files that are needed to build the model and generate a binary application that will run on the board.
nxa11767_5-1622535725292.png

The user can now add Simulink blocks in the model from the NXP i.MXRT1xxx Simulink library from Simulink Library Browser:

nxa11767_6-1622535957130.png

 

Choose the desired block to add to the model:

nxa11767_7-1622538863797.png

 

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. 

3.  Modify default platform initializations and settings values

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.

nxa11767_8-1622539059863.png

This action will open the MCUX Configuration Tool.

nxa11767_9-1622539100429.png

 

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.

nxa11767_11-1622539943937.png

 

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.

nxa11767_10-1622539812924.png

 

 

4.  Deploy on NXP Hardware

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.

nxa11767_14-1622540196085.png

 

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.

nxa11767_15-1622540278016.png

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.

nxa11767_16-1622540415753.png

Congratulations! You have successfully created and deployed your Simulink model to the hardware.

Version history
Revision #:
1 of 1
Last update:
‎06-01-2021 02:42 AM
Updated by: