AnsweredAssumed Answered

CMSIS support in LPCXpresso IDE

Question asked by LPCware Support on Mar 31, 2016

The use of LPCOpen is now recommend for most LPC MCUs, rather than the 'old-style' CMSIS-CORE library projects and examples. For more details please see the LPCXpresso IDE User Manual, and visit the LPCOpen webpages.


Background on CMSIS


CMSIS - the Cortex Microcontroller Software Interface Standard - was originally a specification defined by ARM for Cortex-M based systems to provide:

  • A common way to access peripheral registers and a common way to define exception vectors.
  • The register names of the Core Peripherals and the names of the Core Exception Vectors.
  • An device independent interface for RTOS Kernels including a debug channel.


However, CMSIS has now expanded to encompass a number of other specifications (such as CMSIS-DSP), and its original focus as described above is now known as CMSIS-CORE.


By using CMSIS compliant software components, ARM's aim was that the user would be able to more easily re-use template code; CMSIS is intended to enable the combination of software components from multiple middleware vendors. Note that CMSIS is focussed on Cortex-M based MCUs. It does not support ARM7 or ARM9 based MCUs. More information on CMSIS plus the full CMSIS releases can be found at:


The standard CMSIS documentation can also be found within the LPCXpresso IDE's built in help.


Versions of CMSIS


A number of releases of CMSIS have been made, though generally, for most users, there is actually very little functional differences between different CMSIS-CORE versions. The main versions (and the changes included in them) of relevance to LPCXpresso users at the current time are:

  • v1.30
    • First mainstream release. Support Cortex-M3 and M0 parts.
  • v2.00
    • Added support for Cortex-M4
    • CMSIS-DSP library released, providing a library of DSP functions for Cortex-M4 and Cortex-M3
    • New core_cmFunc.h and core_cmInst.h files introduced, with some of the functionality previously implemented in core_cmX.c and core_cmX.h moving into these new files. As part of this change, when built using GNU tools (as used by the LPCXpresso IDE), access to much Cortex processor core functionality is now implemented using functions (which will always be inlined) defined within header files, rather than as source code (typically helping to reduce code size).
  • v2.10
    • CMSIS-DSP library extended to support Cortex-M0
  • v3.01
    • Added support for Cortex-M0+ processor.
    • Improved CMSIS-DSP library
    • Minor changes and extensions to inline functions provided to access ARM core functionality.
  • v3.20
    • Minor extensions and corrections to inline functions for accessing ARM core functionality, including addtion of __BKPT() instruction intrinsic.

For details of the latest CMSIS releases please visit ARM's website.


Note: For details of the support for CMSIS-DSP in LPCXpresso IDE, please see the FAQ "CMSIS DSP Library Support".


LPCXpresso CMSIS-CORE library projects


Within the LPCXpresso IDE examples subdirectory for a particular Cortex-M based MCU family, you will typically find one or more CMSIS library projects. Each of these CMSIS library projects contain the appropriate CMSIS header files and source code for that specific MCU family


Note that these library projects do NOT typically provide actual driver code for the peripherals on the MCU. Peripheral drivers will be provided through example code or peripheral driver libraries. Some example code and driver libraries do have the word CMSIS in their titles though, which sometimes causes confusion. This simply refers to the fact that the code has been written to use the CMSIS way of accessing the peripherals.


However where more than one library version exists for your target MCU family, you should typically use the latest version, though you may need to take into account the library version used by any other library projects that your application project will make use of.Typically CMSIS library project names are of the form:


  • CMSISv1p30_<partfamily>
    • Uses components from ARM’s CMSIS v1.30 specification.
  • CMSISv2p00_<partfamily>
    • Uses components from ARM’s CMSIS v2.00 specification.
  • CMSISv2p10_<partfamily>
    • Uses components from ARM’s CMSIS v2.10 specification.
  • CMSIS_CORE_<partfamily>
    • Uses components from ARM’s CMSIS v3.01 or later specification. See the readme within the library project for exact details.


The CMSIS library option within the LPCXpresso IDE project wizards allows you to select which (if any) CMSIS library you want to link to from the project that you are creating. Note that the appropriate CMSIS library project must have been imported into the workspace before starting the wizard, otherwise an error will be given when the wizard attempts to create your project.


Note As of LPCXpresso 6, CMSIS 3.20 based CMSIS-CORE library projects are now provided and supported in the project wizards, although many supplied example projects still build against earlier versions of the CMSIS-CORE library projects.




A summary of the source files within the library is as follows...

ARM supplied files

  • core_cmX.h
    • Header providing access to Cortex-M core's built-in peripherals. (X="0", "0plus", "3" or "4").
  • core_cmFunc.h
    • Introduced in CMSIS v2.0. Provides inline helper functions for accessing register and peripherals within the Cortex-M core.
  • core_cmInst.h
    • Introduced in CMSIS v2.0. Provides inline helper functions for accessing instructions not directly generated by compiler
  • core_cm4_simd.h
    • Provides inline functions for accessing Cortex-M4 SIMD (Single Instruction Multiple Data) instructions.
  • core_cmX.c
    • Discontinued in CMSIS v2.0. Provided helper functions now provided instead via core_cmInst.h and core_cmFunc.h

Device specific, NXP supplied files

  • <mcu>.h, for example LPC17xx.h
    • This file contains the data structures, register memory addresses, and defines for a specific MCU family - such as the LPC17xx. Definitions for peripherals like UART, GPIO, TIMERS, etc are all in here, but for detailed information on these peripherals you will typically need to refer to the MCU user manual.
  • system_<mcu>.h, for example "system_LPC17xx.h" / system_<mcu>.c, for example "system_LPC17xx.c"
    • These files contain the prototypes/implementations for the SystemInit() and SystemCoreClockUpdate() to carry out Clock setup, PLL setup, etc and initialise the variable SystemCoreClock. For the actual details of the MCU setup, you should read the code supplied in these files in conjunction with the MCU user manual. Note that the SystemInit() is called from the startup code generated by the LPCXpresso IDE project wizard (when CMSIS support is requested by the user from within the wizard).


Using CMSIS functionality


One thing that CMSIS provides is a set of headers defining the peripheral set of the MCU family that you are using. For example, the following code taken from an LPC1768 example enables the A/D converter:

#include "LPC17xx.h"  

#define ADC_POWERON (1 << 12) 

#define PCLK_ADC 24
#define PCLK_ADC_MASK (3 << 24) 

// AD0.0 - P0.23, PINSEL1 [15:14] = 01
#define SELECT_ADC0 (0x1<<14)
// Turn on power to ADC block

// Turn on ADC peripheral clock
LPC_SC->PCLKSEL0 |=  (3 << PCLK_ADC); 

// Set P0.23 to AD0.0 in PINSEL1

It also provides access to functionality contained within the Cortex-M processor core. For example, the below code snippet enables the SysTick timer built into most Cortex-M class by MCUs:

// Setup SysTick Timer to interrupt at 1 msec intervals 
if (SysTick_Config(SystemCoreClock / 1000)) {
     while (1);  // Capture error