This user's guide describes the General Motor Control Library (GMCLIB) for the family
of ARM Cortex M33F core-based microcontrollers. This library contains optimized
functions.
1.1.2
GMCLIB supports several data types: (un)signed integer, fractional, and accumulator,
and floating point. The integer data types are useful for general-purpose computation;
they are familiar to the MPU and MCU programmers. The fractional data types enable
powerful numeric and digital-signal-processing algorithms to be implemented. The
accumulator data type is a combination of both; that means it has the integer and
fractional portions.The floating-point data types are capable of storing real numbers in
wide dynamic ranges. The type is represented by binary digits and an exponent. The
exponent allows scaling the numbers from extremely small to extremely big numbers.
Because the exponent takes part of the type, the overall resolution of the number is
reduced when compared to the fixed-point type of the same size.
The following list shows the integer types defined in the libraries:
• Unsigned 16-bit integer —<0 ; 65535> with the minimum resolution of 1
• Signed 16-bit integer —<-32768 ; 32767> with the minimum resolution of 1
• Unsigned 32-bit integer —<0 ; 4294967295> with the minimum resolution of 1
• Signed 32-bit integer —<-2147483648 ; 2147483647> with the minimum resolution
Data types
of 1
GMCLIB User's Guide, Rev. 4, 12/2020
NXP Semiconductors5
Introduction
The following list shows the fractional types defined in the libraries:
• Fixed-point 16-bit fractional —<-1 ; 1 - 2
• Fixed-point 32-bit fractional —<-1 ; 1 - 2
-15
> with the minimum resolution of 2
-31
> with the minimum resolution of 2
-15
-31
The following list shows the accumulator types defined in the libraries:
• Fixed-point 16-bit accumulator —<-256.0 ; 256.0 - 2-7> with the minimum
resolution of 2
The following list shows the floating-point types defined in the libraries:
• Floating point 32-bit single precision —<-3.40282 · 1038 ; 3.40282 · 1038> with the
minimum resolution of 2
1.1.3
API definition
-23
GMCLIB uses the types mentioned in the previous section. To enable simple usage of the
algorithms, their names use set prefixes and postfixes to distinguish the functions'
versions. See the following example:
• lss—the types of the function inputs; if all the inputs have the same type as the
output, the inputs are not marked
The input and output types are described in the following table:
Table 1-1. Input/output types
TypeOutputInput
frac16_tF16s
frac32_tF32l
acc32_tA32a
float_tFLTf
GMCLIB User's Guide, Rev. 4, 12/2020
6NXP Semiconductors
Chapter 1 Library
1.1.4Supported compilers
GMCLIB for the ARM Cortex M33F core is written in C language or assembly language
with C-callable interface depending on the specific function. The library is built and
tested using the following compilers:
• MCUXpresso IDE
• IAR Embedded Workbench
• Keil µVision
For the MCUXpresso IDE, the library is delivered in the gmclib.a file.
For the Kinetis Design Studio, the library is delivered in the gmclib.a file.
For the IAR Embedded Workbench, the library is delivered in the gmclib.a file.
For the Keil µVision, the library is delivered in the gmclib.lib file.
The interfaces to the algorithms included in this library are combined into a single public
interface include file, gmclib.h. This is done to lower the number of files required to be
included in your application.
1.1.5
Library configuration
GMCLIB for the ARM Cortex M33F core is written in C language or assembly language
with C-callable interface depending on the specific function. Some functions from this
library are inline type, which are compiled together with project using this library. The
optimization level for inline function is usually defined by the specific compiler setting. It
can cause an issue especially when high optimization level is set. Therefore the
optimization level for all inline assembly written functions is defined by compiler
pragmas using macros. The configuration header file RTCESL_cfg.h is located in:
specific library folder\MLIB\Include. The optimization level can be changed by
modifying the macro value for specific compiler. In case of any change the library
functionality is not guaranteed.
Similarly as optimization level the PowerQuad DSP Coprocessor and Accelerator support
can be disable or enable if it has not been done by defined symbol RTCESL_PQ_ON or
RTCESL_PQ_OFF in project setting described in the PowerQuad DSP Coprocessor and
Accelerator support cheaper for specific compiler.
GMCLIB User's Guide, Rev. 4, 12/2020
NXP Semiconductors7
Library integration into project (MCUXpresso IDE)
1.1.6Special issues
1. The equations describing the algorithms are symbolic. If there is positive 1, the
number is the closest number to 1 that the resolution of the used fractional type
allows. If there are maximum or minimum values mentioned, check the range
allowed by the type of the particular function version.
2. The library functions that round the result (the API contains Rnd) round to nearest
(half up).
1.2Library integration into project (MCUXpresso IDE)
This section provides a step-by-step guide on how to quickly and easily include GMCLIB
into any MCUXpresso SDK example or demo application projects using MCUXpresso
IDE. This example uses the default installation path (C:\NXP\RTCESL
\CM33F_RTCESL_4.6_MCUX). If you have a different installation path, use that path
instead.
1.2.1
PowerQuad DSP Coprocessor and Accelerator support
Some LPC platforms (LPC55S6x) contain a hardware accelerator dedicated to common
calculations in DSP applications. This section shows how to turn the PowerQuad (PQ)
support for a function on and off.
1. In the MCUXpresso SDK project name node or in the left-hand part, click Properties
or select Project > Properties from the menu. A project properties dialog appears.
2. Expand the C/C++ Build node and select Settings. See .
3. On the right-hand side, under the MCU C Compiler node, click the Preprocessor
node. See .
GMCLIB User's Guide, Rev. 4, 12/2020
8NXP Semiconductors
Chapter 1 Library
Figure 1-1. Defined symbols
4. In the right-hand part of the dialog, click the Add... icon located next to the Defined
symbols (-D) title.
5. In the dialog that appears (see ), type the following:
• RTCESL_PQ_ON—to turn the PowerQuad support on
• RTCESL_PQ_OFF—to turn the PowerQuad support off
If neither of these two defines is defined, the hardware division and square root
support is turned off by default.
Figure 1-2. Symbol definition
6. Click OK in the dialog.
7. Click OK in the main dialog.
8. Ensure the PowerQuad moduel to be clocked by calling function
RTCESL_PQ_Init(); prior to the first function using PQ module calling.
GMCLIB User's Guide, Rev. 4, 12/2020
NXP Semiconductors9
Library integration into project (MCUXpresso IDE)
See the device reference manual to verify whether the device contains the PowerQuad
DSP Coprocessor and Accelerator support.
1.2.2Library path variable
To make the library integration easier, create a variable that holds the information about
the library path.
1. Right-click the MCUXpresso SDK project name node in the left-hand part and click
Properties, or select Project > Properties from the menu. A project properties dialog
appears.
2. Expand the Resource node and click Linked Resources. See Figure 1-3.
Figure 1-3. Project properties
3. Click the New… button in the right-hand side.
GMCLIB User's Guide, Rev. 4, 12/2020
10NXP Semiconductors
Chapter 1 Library
4. In the dialog that appears (see Figure 1-4), type this variable name into the Name
box: RTCESL_LOC.
5. Select the library parent folder by clicking Folder…, or just type the following path
into the Location box: C:\NXP\RTCESL\CM33F_RTCESL_4.6_MCUX. Click OK.
Figure 1-4. New variable
6. Create such variable for the environment. Expand the C/C++ Build node and click
Environment.
7. Click the Add… button in the right-hand side.
8. In the dialog that appears (see Figure 1-5), type this variable name into the Name
box: RTCESL_LOC.
9. Type the library parent folder path into the Value box: C:\NXP\RTCESL
\CM33F_RTCESL_4.6_MCUX.
10. Tick the Add to all configurations box to use this variable in all configurations. See
Figure 1-5.
11. Click OK.
12. In the previous dialog, click OK.
GMCLIB User's Guide, Rev. 4, 12/2020
NXP Semiconductors11
Library integration into project (MCUXpresso IDE)
Figure 1-5. Environment variable
1.2.3
Library folder addition
To use the library, add it into the Project tree dialog.
1. Right-click the MCUXpresso SDK project name node in the left-hand part and click
New > Folder, or select File > New > Folder from the menu. A dialog appears.
2. Click Advanced to show the advanced options.
3. To link the library source, select the Link to alternate location (Linked Folder)
option.
4. Click Variables..., select the RTCESL_LOC variable in the dialog, click OK, and/or
type the variable name into the box. See Figure 1-6.
5. Click Finish, and the library folder is linked in the project. See Figure 1-7.
GMCLIB User's Guide, Rev. 4, 12/2020
12NXP Semiconductors
Chapter 1 Library
Figure 1-6. Folder link
Figure 1-7. Projects libraries paths
1.2.4
Library path setup
GMCLIB requires MLIB and GFLIB to be included too. These steps show how to
include all dependent modules:
1. Right-click the MCUXpresso SDK project name node in the left-hand part and click
Properties, or select Project > Properties from the menu. The project properties
dialog appears.
2. Expand the C/C++ General node, and click Paths and Symbols.
3. In the right-hand dialog, select the Library Paths tab. See Figure 1-9.
4. Click the Add… button on the right, and a dialog appears.
GMCLIB User's Guide, Rev. 4, 12/2020
NXP Semiconductors13
Library integration into project (MCUXpresso IDE)
5. Look for the RTCESL_LOC variable by clicking Variables…, and then finish the
path in the box by adding the following (see Figure 1-8): ${RTCESL_LOC}\MLIB.
6. Click OK, and then click the Add… button.
7. Look for the RTCESL_LOC variable by clicking Variables…, and then finish the
path in the box by adding the following: ${RTCESL_LOC}\GFLIB.
8. Click OK, and then click the Add… button.
9. Look for the RTCESL_LOC variable by clicking Variables…, and then finish the
path in the box by adding the following: ${RTCESL_LOC}\GMCLIB.
10. Click OK, you will see the paths added into the list. See Figure 1-9.
Figure 1-8. Library path inclusion
Figure 1-9. Library paths
11. After adding the library paths, add the library files. Click the Libraries tab. See
Figure 1-11.
12. Click the Add… button on the right, and a dialog appears.
13. Type the following into the File text box (see Figure 1-10): :mlib.a
14. Click OK, and then click the Add… button.
GMCLIB User's Guide, Rev. 4, 12/2020
14NXP Semiconductors
Chapter 1 Library
15. Type the following into the File text box: :gflib.a
16. Click OK, and then click the Add… button.
17. Type the following into the File text box: :gmclib.a
18. Click OK, and you will see the libraries added in the list. See Figure 1-11.
Figure 1-10. Library file inclusion
Figure 1-11. Libraries
19. In the right-hand dialog, select the Includes tab, and click GNU C in the Languages
list. See Figure 1-13.
20. Click the Add… button on the right, and a dialog appears. See Figure 1-12.
21. Look for the RTCESL_LOC variable by clicking Variables…, and then finish the
path in the box to be: ${RTCESL_LOC}\MLIB\Include
22. Click OK, and then click the Add… button.
23. Look for the RTCESL_LOC variable by clicking Variables…, and then finish the
path in the box to be: ${RTCESL_LOC}\GFLIB\Include
24. Click OK, and then click the Add… button.
25. Look for the RTCESL_LOC variable by clicking Variables…, and then finish the
path in the box to be: ${RTCESL_LOC}\GMCLIB\Include
26. Click OK, and you will see the paths added in the list. See Figure 1-13. Click OK.
GMCLIB User's Guide, Rev. 4, 12/2020
NXP Semiconductors15
Library integration into project (MCUXpresso IDE)
Figure 1-12. Library include path addition
Figure 1-13. Compiler setting
Type the #include syntax into the code where you want to call the library functions. In
the left-hand dialog, open the required .c file. After the file opens, include the following
lines into the #include section:
When you click the Build icon (hammer), the project is compiled without errors.
GMCLIB User's Guide, Rev. 4, 12/2020
16NXP Semiconductors
Chapter 1 Library
1.3Library integration into project (Keil µVision)
This section provides a step-by-step guide on how to quickly and easily include GMCLIB
into an empty project or any MCUXpresso SDK example or demo application projects
using Keil µVision. This example uses the default installation path (C:\NXP\RTCESL
\CM33F_RTCESL_4.6_KEIL). If you have a different installation path, use that path
instead. If any MCUXpresso SDK project is intended to use (for example hello_world
project) go to Linking the files into the project chapter otherwise read next chapter.
1.3.1
NXP pack installation for new project (without MCUXpresso
SDK)
This example uses the NXP LPC55s69 part, and the default installation path (C:\NXP
\RTCESL\CM33F_RTCESL_4.6_KEIL) is supposed. If the compiler has never been
used to create any NXP MCU-based projects before, check whether the NXP MCU pack
for the particular device is installed. Follow these steps:
1. Launch Keil µVision.
2. In the main menu, go to Project > Manage > Pack Installer….
3. In the left-hand dialog (under the Devices tab), expand the All Devices > Freescale
(NXP) node.
4. Look for a line called "KVxx Series" and click it.
5. In the right-hand dialog (under the Packs tab), expand the Device Specific node.
6. Look for a node called "Keil::Kinetis_KVxx_DFP." If there are the Install or Update
options, click the button to install/update the package. See Figure 1-14.
7. When installed, the button has the "Up to date" title. Now close the Pack Installer.
GMCLIB User's Guide, Rev. 4, 12/2020
NXP Semiconductors17
Library integration into project (Keil µVision)
Figure 1-14. Pack Installer
1.3.2
New project (without MCUXpresso SDK)
To start working on an application, create a new project. If the project already exists and
is opened, skip to the next section. Follow these steps to create a new project:
1. Launch Keil µVision.
2. In the main menu, select Project > New µVision Project…, and the Create New
Project dialog appears.
3. Navigate to the folder where you want to create the project, for example C:
\KeilProjects\MyProject01. Type the name of the project, for example MyProject01.
Click Save. See Figure 1-15.
Figure 1-15. Create New Project dialog
4. In the next dialog, select the Software Packs in the very first box.
5. Type '' into the Search box, so that the device list is reduced to the devices.
6. Expand the node.
7. Click the LPC55s69 node, and then click OK. See Figure 1-16.
GMCLIB User's Guide, Rev. 4, 12/2020
18NXP Semiconductors
Chapter 1 Library
Figure 1-16. Select Device dialog
8. In the next dialog, expand the Device node, and tick the box next to the Startup node.
See Figure 1-17.
9. Expand the CMSIS node, and tick the box next to the CORE node.
Figure 1-17. Manage Run-Time Environment dialog
10. Click OK, and a new project is created. The new project is now visible in the lefthand part of Keil µVision. See Figure 1-18.
Figure 1-18. Project
11. In the main menu, go to Project > Options for Target 'Target1'…, and a dialog
appears.
12. Select the Target tab.
13. Select Use Single Precision in the Floating Point Hardware option. See Figure 1-18.
GMCLIB User's Guide, Rev. 4, 12/2020
NXP Semiconductors19
Library integration into project (Keil µVision)
Figure 1-19. FPU
1.3.3PowerQuad DSP Coprocessor and Accelerator support
Some LPC platforms (LPC55S6x) contain a hardware accelerator dedicated to common
calculations in DSP applications. This section shows how to turn the PowerQuad (PQ)
support for a function on and off.
1. In the main menu, go to Project > Options for Target 'Target1'…, and a dialog
appears.
2. Select the C/C++ tab. See Figure 1-20.
3. In the Include Preprocessor Symbols text box, type the following:
• RTCESL_PQ_ON—to turn the hardware division and square root support on.
• RTCESL_PQ_OFF—to turn the hardware division and square root support off.
If neither of these two defines is defined, the hardware division and square root
support is turned off by default.
GMCLIB User's Guide, Rev. 4, 12/2020
20NXP Semiconductors
Chapter 1 Library
Figure 1-20. Preprocessor symbols
4. Click OK in the main dialog.
5. Ensure the PowerQuad moduel to be clocked by calling function
RTCESL_PQ_Init(); prior to the first function using PQ module calling.
See the device reference manual to verify whether the device contains the PowerQuad
DSP Coprocessor and Accelerator support.
1.3.4
Linking the files into the project
GMCLIB requires MLIB and GFLIB to be included too. The following steps show how
to include all dependent modules.
To include the library files in the project, create groups and add them.
1. Right-click the Target 1 node in the left-hand part of the Project tree, and select Add
Group… from the menu. A new group with the name New Group is added.
2. Click the newly created group, and press F2 to rename it to RTCESL.
3. Right-click the RTCESL node, and select Add Existing Files to Group 'RTCESL'…
from the menu.
GMCLIB User's Guide, Rev. 4, 12/2020
NXP Semiconductors21
Library integration into project (Keil µVision)
4. Navigate into the library installation folder C:\NXP\RTCESL
\CM33F_RTCESL_4.6_KEIL\MLIB\Include, and select the mlib_FP.h file. If the
file does not appear, set the Files of type filter to Text file. Click Add. See Figure
1-21.
Figure 1-21. Adding .h files dialog
5. Navigate to the parent folder C:\NXP\RTCESL\CM33F_RTCESL_4.6_KEIL\MLIB,
and select the mlib.lib file. If the file does not appear, set the Files of type filter to
Library file. Click Add. See Figure 1-22.
Figure 1-22. Adding .lib files dialog
6. Navigate into the library installation folder C:\NXP\RTCESL
\CM33F_RTCESL_4.6_KEIL\GFLIB\Include, and select the gflib_FP.h file. If the
file does not appear, set the Files of type filter to Text file. Click Add.
GMCLIB User's Guide, Rev. 4, 12/2020
22NXP Semiconductors
Chapter 1 Library
7. Navigate to the parent folder C:\NXP\RTCESL\CM33F_RTCESL_4.6_KEIL
\GFLIB, and select the gflib.lib file. If the file does not appear, set the Files of type
filter to Library file. Click Add.
8. Navigate into the library installation folder C:\NXP\RTCESL
\CM33F_RTCESL_4.6_KEIL\GMCLIB\Include, and select the gmclib_FP.h file. If
the file does not appear, set the Files of type filter to Text file. Click Add.
9. Navigate to the parent folder C:\NXP\RTCESL\CM33F_RTCESL_4.6_KEIL
\GMCLIB, and select the gmclib.lib file. If the file does not appear, set the Files of
type filter to Library file. Click Add.
10. Now, all necessary files are in the project tree; see Figure 1-23. Click Close.
Figure 1-23. Project workspace
1.3.5
Library path setup
The following steps show the inclusion of all dependent modules.
1. In the main menu, go to Project > Options for Target 'Target1'…, and a dialog
appears.
2. Select the C/C++ tab. See Figure 1-24.
3. In the Include Paths text box, type the following paths (if there are more paths, they
must be separated by ';') or add them by clicking the … button next to the text box:
When you click the Build (F7) icon, the project will be compiled without errors.
1.4
Library integration into project (IAR Embedded
Workbench)
This section provides a step-by-step guide on how to quickly and easily include the
GMCLIB into an empty project or any MCUXpresso SDK example or demo application
projects using IAR Embedded Workbench. This example uses the default installation
path (C:\NXP\RTCESL\CM33F_RTCESL_4.6_IAR). If you have a different installation
path, use that path instead. If any MCUXpresso SDK project is intended to use (for
example hello_world project) go to Linking the files into the project chapter otherwise
read next chapter.
GMCLIB User's Guide, Rev. 4, 12/2020
NXP Semiconductors25
Library integration into project (IAR Embedded Workbench)
1.4.1New project (without MCUXpresso SDK)
This example uses the NXP LPC55S69 part, and the default installation path (C:\NXP
\RTCESL\CM33F_RTCESL_4.6_IAR) is supposed. To start working on an application,
create a new project. If the project already exists and is opened, skip to the next section.
Perform these steps to create a new project:
1. Launch IAR Embedded Workbench.
2. In the main menu, select Project > Create New Project… so that the "Create New
Project" dialog appears. See Figure 1-26.
Figure 1-26. Create New Project dialog
3. Expand the C node in the tree, and select the "main" node. Click OK.
4. Navigate to the folder where you want to create the project, for example, C:
\IARProjects\MyProject01. Type the name of the project, for example, MyProject01.
Click Save, and a new project is created. The new project is now visible in the lefthand part of IAR Embedded Workbench. See Figure 1-27.
GMCLIB User's Guide, Rev. 4, 12/2020
26NXP Semiconductors
Chapter 1 Library
Figure 1-27. New project
5. In the main menu, go to Project > Options…, and a dialog appears.
6. In the Target tab, select the Device option, and click the button next to the dialog to
select the MCU. In this example, select NXP > LPC55S69 > NXP LPC55S69_core0.
Select VFPv5 single precision in the FPU option.The DSP instructions group is
required please check the DSP Extensions checkbox if not checked. Click OK. See
Figure 1-28.
Figure 1-28. Options dialog
GMCLIB User's Guide, Rev. 4, 12/2020
NXP Semiconductors27
Library integration into project (IAR Embedded Workbench)
1.4.2PowerQuad DSP Coprocessor and Accelerator support
Some LPC platforms (LPC55S6x) contain a hardware accelerator dedicated to common
calculations in DSP applications. Only functions runing faster through the PowerQuad
module than the core itself are supported and targeted to be calculated by the PowerQuad
module. This section shows how to turn the PowerQuad (PQ) support for a function on
and off.
1. In the main menu, go to Project > Options…, and a dialog appears.
2. In the left-hand column, select C/C++ Compiler.
3. In the right-hand part of the dialog, click the Preprocessor tab (it can be hidden in the
right-hand side; use the arrow icons for navigation).
4. In the text box (at the Defined symbols: (one per line)), type the following (See
Figure 1-29):
• RTCESL_PQ_ON—to turn the PowerQuad support on.
• RTCESL_PQ_OFF—to turn the PowerQuad support off.
If neither of these two defines is defined, the hardware division and square root
support is turned off by default.
Figure 1-29. Defined symbols
5. Click OK in the main dialog.
GMCLIB User's Guide, Rev. 4, 12/2020
28NXP Semiconductors
Chapter 1 Library
6. Ensure the PowerQuad moduel to be clocked by calling function
RTCESL_PQ_Init(); prior to the first function using PQ module calling.
See the device reference manual to verify whether the device contains the PowerQuad
DSP Coprocessor and Accelerator support.
1.4.3Library path variable
To make the library integration easier, create a variable that will hold the information
about the library path.
1. In the main menu, go to Tools > Configure Custom Argument Variables…, and a
dialog appears.
2. Click the New Group button, and another dialog appears. In this dialog, type the
name of the group PATH, and click OK. See Figure 1-30.
Figure 1-30. New Group
3. Click on the newly created group, and click the Add Variable button. A dialog
appears.
4. Type this name: RTCESL_LOC
5. To set up the value, look for the library by clicking the '…' button, or just type the
installation path into the box: C:\NXP\RTCESL\CM33F_RTCESL_4.6_IAR. Click
OK.
6. In the main dialog, click OK. See Figure 1-31.
GMCLIB User's Guide, Rev. 4, 12/2020
NXP Semiconductors29
Library integration into project (IAR Embedded Workbench)
Figure 1-31. New variable
1.4.4
Linking the files into the project
GMCLIB requires MLIB and GFLIB to be included too. The following steps show the
inclusion of all dependent modules.
To include the library files into the project, create groups and add them.
1. Go to the main menu Project > Add Group…
2. Type RTCESL, and click OK.
3. Click on the newly created node RTCESL, go to Project > Add Group…, and create
a MLIB subgroup.
4. Click on the newly created node MLIB, and go to the main menu Project > Add
Files… See Figure 1-33.
5. Navigate into the library installation folder C:\NXP\RTCESL
\CM33F_RTCESL_4.6_IAR\MLIB\Include, and select the mlib.h file. (If the file
does not appear, set the file-type filter to Source Files.) Click Open. See Figure 1-32.
6. Navigate into the library installation folder C:\NXP\RTCESL
\CM33F_RTCESL_4.6_IAR\MLIB, and select the mlib.a file. If the file does not
appear, set the file-type filter to Library / Object files. Click Open.
Figure 1-32. Add Files dialog
7. Click on the RTCESL node, go to Project > Add Group…, and create a GFLIB
subgroup.
8. Click on the newly created node GFLIB, and go to the main menu Project > Add
Files….
GMCLIB User's Guide, Rev. 4, 12/2020
30NXP Semiconductors
Loading...
+ 81 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.