Tutorial1 2
Tutorial1 2
SFWRENG/MECHTRON 3K04
McMaster University
Michael Kehinde
kehindem@mcmaster.ca
Topics Covered
• Introduction to Simulink®
• What is code-generation?
• What is board firmware?
• Installing MATLAB Simulink® and all applicable support packages
Disclaimer: McMaster students, staff and faculty have free access to a MATLAB®
license that includes all the required toolboxes for the project. To install
MATLAB® using the McMaster campus-wide license, you will need to have
a MACID and a MathWorks® account. If you do not have a MathWorks®
account, you will be prompted to set one up during the installation.
1. Click the following link to access the McMaster University MATLAB Ac-
cess page: https://www.mathworks.com/academia/tah-portal/mcmaster-
university-31501097.html. On the webpage, click the “Sign in to get
started” button.
2. Search for the Simulink® Coder Support Package for NXP FRDM-K64F
Note: if you will need to set up the support package later, you will
be able to access the setup menu by navigating to Home Environment
Add-Ons ▽ Manage Add-Ons . Click the gear icon next to the FRDM-
K64F board support package.
9. The FRDM K64F REV E3, REV E4 and REV F is not fully configured
in the R2020a release with respect to pin D8.
As a workaround, in order to enable the pin,
i. Enter the following command on MATLAB Command window.
Copy and paste the command exactly as it appears below. Make
sure to copy both lines together.
open([codertarget.freedomk64f.internal.getSpPkgRootDir,
'/src/mw_sdk_interface.c']);
ii. Within the file that is opened, find the following line:
{ {GPIO_MAKE_PIN(GPIOA_IDX,
GPIO_MAKE_PIN(GPIOA_IDX, 0), 0),
MW_NOT_USED},// PTA0, D8
MW_NOT_USED},// PTA0, D8
and replace it with
{ {GPIO_MAKE_PIN(GPIOC_IDX,
GPIO_MAKE_PIN(GPIOC_IDX, 12), 12),
MW_NOT_USED},// PTC12, PTC12,
MW_NOT_USED},// D8 D8
Do not get any of the letters wrong. Double click the entry from the
first text field above, copy it and use the CTRL + F keys to find
the line in the file. Remove that line from the file. Then double
click the entry in the second text field above, copy it and paste it
at the same position in the file.
iii. Save and close the file.
4. On the pane on the left hand side, click “Solver”. Under Solver selec-
tion, make sure the solver type is “Fixed-step” and leave the Solver
on auto.
2. Take some time to get acquainted with the Simulink UI. (You may be
spending lots of time with Simulink this semester). Navigate through
each ribbon and get a feel for what features are available. The next
tutorial will involve building a basic model and flashing the K64F. If you
would like some additional resources, you can begin exploring Getting
Started with Simulink Coder Support Package for NXP FRDM-K64F
Board.
Note If you are having trouble with determining the path, you can
move the binary to your desktop and copy and paste the com-
mand here in Step 3 verbatim. Alternatively, you can simply copy
and paste first part of the command sudo mount -u -w -o sync
/Volumes/BOOTLOADER; cp -X into the Terminal window. Then
click and drag the binary file to the Terminal window. Then copy
and paste the /Volumes/BOOTLOADER/ part of the command.
4. Press Enter to run the command.
This error is due to a MATLAB bug. Follow the steps in this discussion
to resolve the error: https://www.mathworks.com/matlabcentral/answers/
515771-why-does-the-setup-stage-fail-for-simulink-coder-support-
package-for-nxp-frdm-k64f-board
If you are having trouble finding the makefiles, follow these steps:
1. Enter the following command on the MATLAB command line.
Make sure to copy and paste all three lines together:
open([matlabshared.supportpkg.getSupportPackageRoot,
'/toolbox/target/supportpackages/freedomk64f/src/',
'ksdk_armgcc_lib/bm/ksdk_platform_lib_bm.mk'])
open([matlabshared.supportpkg.getSupportPackageRoot,
'/toolbox/target/supportpackages/freedomk64f/src/',
'ksdk_armgcc_lib/freertos/ksdk_platform_lib_freertos.mk'])
This error is due to an issue with the Kinetis SDK installation. Either the
path you provided in the installer was invalid or the files got corrupted
when you were downloading it.
(a) Repeat the Hardware Setup and make sure the path you provided
points to the KSDK_1.2.0 folder. Try to validate the library as in
Part B — Step 7.
(b) Otherwise try to reinstall the hardware support package.