Computing stuff tied to the physical world

LPCOpen and LPCXpresso

Another option would be to use the LPCOpen library from the LPCware site by NXP.

This approach offers an extensive library of C headers and source files to access all the different hardware peripherals, available on the LPC8xx series µC’s in this case:

$ ls lpc_chip_82x/inc
acmp_8xx.h       error_8xx.h      pinint_8xx.h     spim_8xx.h
adc_8xx.h        fmc_8xx.h        pmu_8xx.h        spis_8xx.h
chip.h           gpio_8xx.h       ring_buffer.h    stopwatch.h
clock_8xx.h      i2c_common_8xx.h rom_i2c_8xx.h    swm_8xx.h
cmsis.h          i2cm_8xx.h       rom_pwr_8xx.h    sys_config.h
core_cm0plus.h   i2cs_8xx.h       rom_uart_8xx.h   syscon_8xx.h
core_cmFunc.h    iap.h            romapi_8xx.h     uart_8xx.h
core_cmInstr.h   inmux_8xx.h      sct_8xx.h        wkt_8xx.h
crc_8xx.h        iocon_8xx.h      sct_pwm_8xx.h    wwdt_8xx.h
dma_8xx.h        lpc_types.h      spi_8xx.h
error.h          mrt_8xx.h        spi_common_8xx.h

Many of these wrappers merely add a thin C interface to the raw CMSIS layer, e.g.:

static inline void
Chip_GPIO_SetPinOutHigh(LPC_GPIO_T *pGPIO, uint8_t port, uint8_t pin)
{
    pGPIO->SET[port] = (1 << pin);
}

But there is also some more substantial code, such as for setting and reading back the various clocks in the chip, and accessing the different ROM-based utility routines.

As you can see from the filenames, most of this code is specific to the LPC8xx series chips.

On the IDE side, LPCware offers a free download of their LCXpresso package, which includes a large set of tools, not just the (gcc) compiler and (gdb) debugger.

The installer is large (400+ Mb) download which includes the Eclipse IDE, and is available for Windows, Mac OSX, and Linux. Here’s a quick glance from the setup guide:

Screen Shot 2015 06 11 at 09 02 46

  1. Project Explorer / Peripherals / Registers Views
  2. Editor
  3. Console / Problems / Red Trace Views
  4. Quick Start / Variables / Breakpoints / Expressions Views
  5. Debug View

LPCXpresso needs a one-time free registration and giving your email address to LPCware.

It can all be quite overwhelming to get started. The 35 icons at the top, for example, can be pretty hard to figure out – and there are many settings and modes to adjust (or mess up):

Lpcxpresso icons

Here is the periph_blinky demo, from the LPCOpen library:

#include "board.h"
#include <stdio.h>

#define TICKRATE_HZ (10)    /* 10 ticks per second */

void SysTick_Handler (void) {
    Board_LED_Toggle(0);
}

int main (void) {
    SystemCoreClockUpdate();
    Board_Init();

    Board_LED_Set(0, false);

    SysTick_Config(SystemCoreClock / TICKRATE_HZ);

    while (1)
        __WFI();
}

It compiles to 4196 bytes in release mode. But to get this far, you’ll need to first build the subprojects it depends on: lpc_board_nxp_lpcxpresso_824 and lpc_chip_82x.

Note that underneath are still the same tools one would use from the command line, i.e. make, gcc, gdb, etc. This is merely a (sophisticated) source code editor and development environment based on top of all that. When used with hardware debugging (via SWCLK and SWDIO pins on an LPC8xx chip), you get tremendous power and access to advanced features such as breakpoints, watchpoints, live inspection of variable values, and more.

One benefit of this Eclipse-based IDE is that if you do any programming in other contexts, you may already be familiar with it, so that re-using this same tool and all its features and keyboard shortcuts for embedded projects will be a lot easier. There are lots of Eclipse configurations and plugins, for just about any programming language.

Some people will prefer this “Arduino IDE on steroids”, others will prefer a GUI-based general-purpose programmer’s editor such as Sublime Text, Atom, Notepad++, and yet others will prefer the text / command-line based editing facilities of vim or emacs.

If editing and developing code is a major activity for you, then building up habits and muscle-memory with one specific tool is likely to affect which approach you prefer.

[Back to article index]