The Motor Control Universal Lab project can
be ported to other FPU and TMU enabled C2000 MCU controllers. Instructions on how to port
the lab code are described in detail in the following steps. The F28004x MCU is used as the
example for a new target C2000 MCU. To adapt a SysConfig-enabled version of the lab, replace
universal_motorcontrol_lab with
universal_motorcontrol_syscfg in all below instructions.
- Browse to the
<install_location>\solutions\universal_motorcontrol_lab
folder and select one of the existing device-specific lab folders. The "f28002x" folder
will be used in this example, but any can be utilized.
- Create a copy of the selected
device-specific lab in the same universal_motorcontrol_lab folder, changing the name to
"f28004x".
<install_location>\solutions\universal_motorcontrol_lab\f28004x
will be the location of your final ported lab, and will be referred to as
<f28004x_lab_location> below.
- The compiler uses cmd files to map the
memory of the C2000 MCU. Browse to the
<f28004x_lab_location>\cmd folder and update the name of the
f28002x_flash_lib_is.cmd files to reflect the new f28004x device. Note that there
are several other cmd files present in this folder- these are unused by default and can be
ignored.
- The Universal Motor Control Lab utilizes
the pin definitions present in the C2000Ware device driver files, device.c/h. These
must be updated for the new device.
- Navigate to the C2000Ware common
device support folder for the new C2000 MCU, located at
<install_location>\c2000ware\device_support\f28004x.
Locate the device.h file in the ...\common\include
subfolder.
- Copy the device.h file into
the <f28004x_lab_location>\drivers\include folder,
replacing the existing file.
- Navigate back to the C2000Ware common
device support folder for the new C2000 MCU. Locate the device.c file in the
...\common\source subfolder.
- Copy the device.c file into
the <f28004x_lab_location>\drivers\source folder, replacing
the existing file.
- Browse to the
<f28004x_lab_location>\ccs\motor_control folder and use an
editor to open the projectspec file. This file is used by CCS to generate the project
folder in the user workspace and includes references to device-specific C2000Ware source
files.
- If the SysConfig-enabled version of
the lab is being used, update the bolded text below to indicate the package of
your new C2000 MCU. This line of text can be found within the device definition
section of the file, which should be the first
section.
sysConfigBuildOptions --product ${C2000WARE_ROOT}/.metadata/sdk.json --device F28002x --package 80QFP --part F28002x_80QFP"
- Some C2000
MCUs have different capabilities than others. Update the file to reflect these
differences. For example, the F28002x MCU has Fast Integer Division (FINTDIV) support,
while the F28004x does not. The relevant processor option is the 'idiv_support' term.
Find and delete all instances of "--idiv_support=idiv0" since the F28004x doesn't
support this function.
- If you are uncertain what changes
may need to be made, refer to the TMS320C28x Optimizing C/C++ Compiler v22.6.0.LTS User's Guide, section
2.3 Changing the Compiler's Behavior with Options, table 2-1 Processor
Options, which describes in detail what each option is used for.
- Determine what differences exist
between the that device and the new C2000 MCU that you have chosen. For assistance
in this process, refer to the C2000
Real-Time Control Peripheral Reference Guide, which describes the
differences between devices and peripheral versions.
- Make adjustments as necessary in
the projectspec file.
- Find and replace all instances of
"28002x" with "28004x" in the file.
- Find all instances of "280025C" in
the file.
- The first result should be near
the beginning of the file, specifying the project device. Update the text in bold
to correctly show the new C2000 MCU chosen for this
project.
<project
name="universal_motorcontrol_lab_f28004x"
device="TMS320F280025C"
- The final two results should be
in the final section of the file. The following excerpts can be found in the
'path' for the ccxml file 'copy file'
actions.
/TMS320F280025C_LaunchPad.ccxml
/TMS320F280025C.ccxml
- Update the text in bold to
correctly indicate the generic target configuration files for the new C2000 MCU's
family of devices, which can be found in the previously referenced device support
folder, in the ...\common\targetConfigs subfolder. For all
F28004x devices, the bolded text should be changed to
"TMS320F280049C".
- All other results for "280025C"
should be in comments. Updating these is suggested for documentation accuracy, but
is not critical.
- Import the
"universal_motorcontrol_lab_f28004x" project into CCS.
- Note that when the project is
imported, CCS may present an error indicating that the
f28004x_headers_nonbios.cmd file was not found. This error does not impact
performance, although it may increase difficulty in debugging. The memory allocations
performed in this file are utilized only by the debug environment watch window,
described in Section 3.5.1.2 in
the incrememental build stages.
- In order to utilize the debug
environment watch window fully, follow all instructions in this section related to the
f28002x_flash_lib_is.cmd file with the f28002x_headers_nonbios.cmd
file as well.
- Open the cmd file(s) and change the
memory map according to the device chosen. For those entirely unfamiliar with this type of
file, refer to the TI Linker Command File Primer for an in-depth introduction and
basic usage guide.
- It may be easier to adapt one of the
generic C2000Ware cmd files, such as the 28004x_generic_flash_lnk.cmd file,
than it is to adapt the cmd file for the old device. These files are located in the
...\common\cmd subfolder of the device support folder. In this
case, the original cmd file for the project should be used as a reference.
- If using the
f28004x_headers_nonbios.cmd file, the generic C2000Ware cmd file is located
in the ...\headers\cmd subfolder of the device support
folder.
- Modify the GPIO, PWM, ADC, and CMPSS
modules and defines in the hal.h file as described in Section 4.1.2 for the F28004x based hardware kit.
- Rebuild the lab project. Any errors or
warnings in the project will be displayed in the CCS Console window. Follow the message
prompts to fix any errors or warnings. There are a few differences in the driverlib APIs
between devices which must be accounted for at this point.
- To add functions to configure and use
peripherals that are present in the new C2000 MCU that were not present in the original
C2000 MCU source for these files, refer to the example functions in C2000Ware or the
MotorControlSDK. For example, the F28004x has a Programmable Gain Amplifier (PGA), while
the F28002x does not.
- Run the project incrementally using the
different build levels to test and verify functionality.
- If this project will be imported multiple
times, it is a good idea to update the project's source files so that these changes will
only need to be done once. Navigate to the
<f28004x_lab_location> folder.
- In the ...\cmd
subfolder, replace the f28004x_flash_lib_is.cmd file with the updated file in
your imported F28004x project.
- In the
...\drivers\source subfolder, replace the hal.c file
with the updated file in your imported F28004x project.
- In the
...\drivers\include subfolder, replace the hal.h file
with the updated file in your imported F28004x project.