This user's guide describes the Math Library (MLIB) for the family of ARM Cortex
M4ARM Cortex M33ARM Cortex M33F core-based microcontrollers. This library
contains optimized functions.
1.1.2
Data types
MLIB supports several data types: (un)signed integer, fractional, and accumulator. 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 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
of 1
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
MLIB User's Guide, Rev. 5, 12/2020
NXP Semiconductors7
Introduction
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
MLIB 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
1.1.4Supported compilers
MLIB for the ARM Cortex M4ARM Cortex M33ARM 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
MLIB User's Guide, Rev. 5, 12/2020
8NXP Semiconductors
Chapter 1 Library
For the MCUXpresso IDE, the library is delivered in the mlib.a file.
For the Kinetis Design Studio, the library is delivered in the mlib.a file.
For the IAR Embedded Workbench, the library is delivered in the mlib.a file.
For the Keil µVision, the library is delivered in the mlib.lib file.
The interfaces to the algorithms included in this library are combined into a single public
interface include file, mlib.h. This is done to lower the number of files required to be
included in your application.
1.1.5
MLIB for the ARM Cortex M4ARM Cortex M33ARM 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.
Library configuration
1.1.6
1. The equations describing the algorithms are symbolic. If there is positive 1, the
2. The library functions that round the result (the API contains Rnd) round to nearest
1.2
NXP Semiconductors9
Special issues
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.
(half up).
Library integration into project (MCUXpresso IDE)
MLIB User's Guide, Rev. 5, 12/2020
Library integration into project (MCUXpresso IDE)
This section provides a step-by-step guide on how to quickly and easily include MLIB
into any MCUXpresso SDK example or demo application projects using MCUXpresso
IDE. This example uses the default installation path (C:\NXP\RTCESL
\CM4CM33CM33F_RTCESL_4.6_MCUX). If you have a different installation path, use
that path instead.
1.2.1PowerQuad 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 .
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.
MLIB User's Guide, Rev. 5, 12/2020
10NXP Semiconductors
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.
Chapter 1 Library
See the device reference manual to verify whether the device contains the PowerQuad
DSP Coprocessor and Accelerator support.
1.2.2
Library 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.
MLIB User's Guide, Rev. 5, 12/2020
NXP Semiconductors11
Library integration into project (MCUXpresso IDE)
Figure 1-3. Project properties
3. Click the New… button in the right-hand side.
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\CM4CM33CM33F_RTCESL_4.6_MCUX.
Click OK.
MLIB User's Guide, Rev. 5, 12/2020
12NXP Semiconductors
Chapter 1 Library
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
\CM4CM33CM33F_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.
MLIB User's Guide, Rev. 5, 12/2020
NXP Semiconductors13
Library integration into project (MCUXpresso IDE)
MLIB User's Guide, Rev. 5, 12/2020
14NXP Semiconductors
Chapter 1 Library
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.
MLIB User's Guide, Rev. 5, 12/2020
NXP Semiconductors15
Library integration into project (MCUXpresso IDE)
Figure 1-6. Folder link
Figure 1-7. Projects libraries paths
1.2.4
Library path setup
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.
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, you will see the path added into the list. See Figure 1-9.
MLIB User's Guide, Rev. 5, 12/2020
16NXP Semiconductors
Figure 1-8. Library path inclusion
Chapter 1 Library
Figure 1-9. Library paths
7. After adding the library path, add the library file. Click the Libraries tab. See Figure
1-11.
8. Click the Add… button on the right, and a dialog appears.
9. Type the following into the File text box (see Figure 1-10): :mlib.a
10. Click OK, and you will see the library added in the list. See Figure 1-11.
MLIB User's Guide, Rev. 5, 12/2020
NXP Semiconductors17
Library integration into project (MCUXpresso IDE)
Figure 1-10. Library file inclusion
Figure 1-11. Libraries
11. In the right-hand dialog, select the Includes tab, and click GNU C in the Languages
list. See Figure 1-13.
12. Click the Add… button on the right, and a dialog appears. See Figure 1-12.
13. Look for the RTCESL_LOC variable by clicking Variables…, and then finish the
path in the box to be: ${RTCESL_LOC}\MLIB\Include
14. Click OK, and you will see the path added in the list. See Figure 1-13. Click OK.
Figure 1-12. Library include path addition
MLIB User's Guide, Rev. 5, 12/2020
18NXP Semiconductors
Chapter 1 Library
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
line into the #include section:
#include "mlib_FP.h"
When you click the Build icon (hammer), the project is compiled without errors.
1.3
Library integration into project (Kinetis Design Studio)
This section provides a step-by-step guide on how to quickly and easily include MLIB
into an empty project or any MCUXpresso SDK example or demo application projects
using Kinetis Design Studio. This example uses the default installation path (C:\NXP
\RTCESL\CM4CM33CM33F_RTCESL_4.6_KDS). If you have a different installation
path, use that path instead. If you want to use an existing MCUXpresso SDK project (for
example the hello_world project) see Library path variable. If not, continue with the next
section.
MLIB User's Guide, Rev. 5, 12/2020
NXP Semiconductors19
Library integration into project (Kinetis Design Studio)
1.3.1Library path variable
To make the library integration easier, create a variable that will hold the information
about the library path.
1. Right-click the MyProject01 or MCUXpresso SDK project name node in the lefthand 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-14.
Figure 1-14. Project properties
3. Click the New… button in the right-hand side.
4. In the dialog that appears (see Figure 1-15), 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\CM4CM33CM33F_RTCESL_4.6_KDS.
Click OK.
MLIB User's Guide, Rev. 5, 12/2020
20NXP Semiconductors
Chapter 1 Library
Figure 1-15. 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-16), type this variable name into the Name
box: RTCESL_LOC.
9. Type the library parent folder path into the Value box: C:\NXP\RTCESL
\CM4CM33CM33F_RTCESL_4.6_KDS.
10. Tick the Add to all configurations box to use this variable in all configurations. See
Figure 1-16.
11. Click OK.
12. In the previous dialog, click OK.
Figure 1-16. Environment variable
MLIB User's Guide, Rev. 5, 12/2020
NXP Semiconductors21
Library integration into project (Kinetis Design Studio)
1.3.2Library folder addition
To use the library, add it into the Project tree dialog.
1. Right-click the MyProject01 or MCUXpresso SDK project name node in the lefthand 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 option Link to alternate location (Linked
Folder).
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-17.
5. Click Finish, and you will see the library folder linked in the project. See Figure
1-18.
Figure 1-17. Folder link
MLIB User's Guide, Rev. 5, 12/2020
22NXP Semiconductors
Chapter 1 Library
Figure 1-18. Projects libraries paths
1.3.3Library path setup
1. Right-click the MyProject01 or MCUXpresso SDK project name node in the lefthand part and click Properties, or select Project > Properties from the menu. A
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-20.
4. Click the Add… button on the right, and a dialog appears.
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-19): ${RTCESL_LOC}\MLIB.
6. Click OK, and the path will be visible in the list. See Figure 1-20.
Figure 1-19. Library path inclusion
MLIB User's Guide, Rev. 5, 12/2020
NXP Semiconductors23
Library integration into project (Kinetis Design Studio)
Figure 1-20. Library paths
7. After adding the library path, add the library file. Click the Libraries tab. See Figure
1-22.
8. Click the Add… button on the right, and a dialog appears.
9. Type the following into the File text box (see Figure 1-21): :mlib.a
10. Click OK, and you will see the library added in the list. See Figure 1-22.
Figure 1-21. Library file inclusion
Figure 1-22. Libraries
11. In the right-hand dialog, select the Includes tab, and click GNU C in the Languages
list. See Figure 1-24.
12. Click the Add… button on the right, and a dialog appears. See Figure 1-23.
13. Look for the RTCESL_LOC variable by clicking Variables…, and then finish the
path in the box to be: ${RTCESL_LOC}\MLIB\Include
14. Click OK, and you will see the path added in the list. See Figure 1-24. Click OK.
MLIB User's Guide, Rev. 5, 12/2020
24NXP Semiconductors
Figure 1-23. Library include path addition
Chapter 1 Library
Figure 1-24. Compiler setting
Type the #include syntax into the code. Include the library into the main.c file. In the lefthand dialog, open the Sources folder of the project, and double-click the main.c file.
After the main.c file opens up, include the following line in the #include section:
#include "mlib.h"
When you click the Build icon (hammer), the project will be compiled without errors.
1.4
Library integration into project (Keil µVision)
This section provides a step-by-step guide on how to quickly and easily include MLIB
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
\CM4CM33CM33F_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.
MLIB User's Guide, Rev. 5, 12/2020
NXP Semiconductors25
Library integration into project (Keil µVision)
1.4.1NXP pack installation for new project (without MCUXpresso
SDK)
This example uses the NXP MKV46F256xxx15LPC55s69 part, and the default
installation path (C:\NXP\RTCESL\CM4CM33CM33F_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-25.
7. When installed, the button has the "Up to date" title. Now close the Pack Installer.
Figure 1-25. Pack Installer
MLIB User's Guide, Rev. 5, 12/2020
26NXP Semiconductors
Chapter 1 Library
1.4.2New 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-26.
Figure 1-26. Create New Project dialog
4. In the next dialog, select the Software Packs in the very first box.
5. Type 'kv4' into the Search box, so that the device list is reduced to the KV4x devices.
6. Expand the KV4x node.
7. Click the MKV46F256xxx15LPC55s69 node, and then click OK. See Figure 1-27.
MLIB User's Guide, Rev. 5, 12/2020
NXP Semiconductors27
Library integration into project (Keil µVision)
Figure 1-27. Select Device dialog
8. In the next dialog, expand the Device node, and tick the box next to the Startup node.
See Figure 1-28.
9. Expand the CMSIS node, and tick the box next to the CORE node.
Figure 1-28. Manage Run-Time Environment dialog
MLIB User's Guide, Rev. 5, 12/2020
28NXP Semiconductors
Chapter 1 Library
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-29.
Figure 1-29. Project
11. In the main menu, go to Project > Options for Target 'Target1'…, and a dialog
appears.
12. Select the Target tab.
13. Select Not UsedUse Single Precision in the Floating Point Hardware option. See
Figure 1-29.
MLIB User's Guide, Rev. 5, 12/2020
NXP Semiconductors29
Library integration into project (Keil µVision)
Figure 1-30. FPU
1.4.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-31.
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.
MLIB User's Guide, Rev. 5, 12/2020
30NXP Semiconductors
Loading...
+ 115 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.