FlexCase

Simulink Basics

  • Install processor toolbox for MATLAB
  • Connect FlexCase blocks to Simulink Models
  • Build microcontroller code for the FlexCase

Prerequisites

  • Complete quick-start guide
  • Check that you have the required Mathworks products: MATLAB, Simulink, MATLAB Coder, Simulink Coder, Embedded Code
  • Download Audesse Simulink samples

Install MBDT

  • Create an account or login to NXP to install the toolbox
  • Download version 4.3.0 in .zip format and change the file extension to .mltbx
  • MATLAB will open an installer for the toolbox. Walk through that process to install the required software. After the toolbox is installed, it will appear in the Add-ons manager. Make a note of the toolbox file location, which will be needed for adding the license
  • Follow instructions provided for NXP for generating a license file for the toolbox

  • Restart MATLAB after installing the free toolbox license

Power Up and Connect

Connect to the FlexCase using S32DS and VirtualHere in the same manner as the quick-start guide.

Open the Sample Model

  • Change the MATLAB directory to the folder with the provided example file Buzzer.slx
  • Open the Buzzer.slx model in Simulink, which should look like the image below:

The sample models are built from the EmptyProject template, which is provided as a base function set for working with the FlexCase. The template has many features preconfigured to work out of the box so that you can start developing right away.

Apart from the base functions included in the template, the only additional content required to get the buzzer beeping periodically is found in the Inputs, Code and Outputs sections: a pulse generator that writes to the Buzzer boolean variable. There is a type conversion block to make the Simulink default type (double) compatible with the NXP output block (in the Default Control Functions subsystem).

Build the Model

Click on the Audesse Hardware Modules Config subsystem and ensure the Init Processor function matches your processor variant:

Press CTRL+B to begin building the model. After approximately 30 seconds the project should be built to the same MATLAB directory as a folder labeled “Buzzer_mbd_rtw”. Within this folder is the file “Buzzer.elf” which is the binary used to program the FlexCase.

The ELF file is exactly the same as the one used in the Quick-Start guide to flash the FlexCase.

Flash a Precompiled Example File

Flashing the model is done similarly to the Quick-Start guide. Using S32DS, select the recently compiled “Buzzer.elf” as the C/C++ Application.

You can review the Quick-Start guide to see the step by step process if required.

Success!

You have successfully flashed the program.

You can try modifying the program to see how easy it is to work with. For example, change the Period of the pulse generator in the inputs section to modify the timing of the beeps. Recompile and re-flash to observe the result. You will always hear a short beep to confirm the board has been flashed, reset, and is running the chosen program.

Next Steps

You are now prepared to begin building your own projects. Use the provided template Simulink models and start adding your own code.

For increased stability, use of single precision floats is strongly recommended. Simulink’s default data type is double, so extra care must be taken to ensure doubles are converted to single.