Getting Started with the LPCXpresso812-Max

Created by Ben Roloff, last modified on Jan 22, 2019

image

Introduction

NXP’s LPC 800 series is a low cost alternative to 8-bit microcontrollers. The board is also setup to take arduino shields. It has analog, timer, serial capabilities that make it a very useful small package. It has a switch matrix which adds additional pinouts for more options. It’s size, cost, and versatility make it a great entry point.

IDE

The IDE that I used was NXP’s MCUXpresso, an introduction can be found here. The board is already found in the IDE so there is no need to download a SDK from the MCUXpresso Configure. The board uses MBED for debugging. There should be no need to download any drivers but if it is having trouble you can follow instructions here.

Sample Programs

There are a few different example programs for the board which goes over the available peripherals. To get the sample programs you must import them through the file system.

Scroll down to LPCOpen Cortex-M Ports and click LPC-800. Download the latest one for the 812 Max for LPCXpresso.

Things to note about the example programs:

  • With the Wakeup Timer, you will not be able to debug new code normally. To get around this you must put a jumper between pin 13 on the Arduino rails and ground. This will allow you to flash new code.
  • With the GPIO example, it says it is for pins 0-3. I found it outputs on pins 2, 7, 8, and 9 on the Arduino rails.
  • Make sure to check the readme.txt for the Samples. They will let you know of any necessary connections or changes that need to be made to libraries for the program.
  • The schematic is very useful for seeing where pins are on the Arduino rails.

Example

For a quick example on creating a program I made a simple blinking LED program using the RGB LED.

Start a new program in the and choose the LPCXpresso812-Max. Click next. Here you will have to import the libraries for the LPC 800 core.

Browse for zip files.

The necessary zip file can be found in the Legacy > NXP > LPC 800 series. You can now select the CMSIS core and libraries from the drop down menus. Then you can just click through to finish. Now the next thing to do is right click on your project and go to properties. Go to project preferences and check lpc800_driver_lib.

Now for the simple blinky example code, the first thing to do is initialize the LEDs on the RGB LED. To find out what pins they are on PORT0, the only port on the 812, you can look at the schematic. You can easily see the pins are 7 for the red LED, 16 for the blue LED, and 17 for the green LED. First you have to initialize the clock for PORT0, then set each LED pin to output by putting a 1 in DIR0. It is also a good idea to reset them so that they start in an off state.

LED_Init

void LED_Init()
{
    LPC_SYSCON->SYSAHBCLKCTRL |= (1<<6);
 
    //red led
    LPC_GPIO_PORT->DIR0 |= (1<<7);
    LPC_GPIO_PORT->SET0 |= (1<<7);
 
    //blue led
    LPC_GPIO_PORT->DIR0 |= (1<<16);
    LPC_GPIO_PORT->SET0 |= (1<<16);
 
    //green led
    LPC_GPIO_PORT->DIR0 |= (1<<17);
    LPC_GPIO_PORT->SET0 |= (1<<17);
 
    return;
}

The main code is very simple. In an infinite loop you can toggle each LED on and then off. You can also make a very simple wait using a for loop or make a wait funtion.

Main()

int main(void) {
 
    LED_Init(); // initialize the LEDs
 
    // Force the counter to be placed into memory
    volatile static int i = 0 ;
 
    while(1) {
 
        //red led toggle on and off
        LPC_GPIO_PORT->NOT0 |= (1<<7);
        for(i = 0; i<300000; i++);
        LPC_GPIO_PORT->NOT0 |= (1<<7);
        for(i = 0; i<300000; i++);
 
        //blue led toggle on and off
        LPC_GPIO_PORT->NOT0 |= (1<<16);
        for(i = 0; i<300000; i++);
        LPC_GPIO_PORT->NOT0 |= (1<<16);
        for(i = 0; i<300000; i++);
 
        //green led toggle on and off
        LPC_GPIO_PORT->NOT0 |= (1<<17);
        for(i = 0; i<300000; i++);
        LPC_GPIO_PORT->NOT0 |= (1<<17);
        for(i = 0; i<300000; i++);
    }
    return 0 ;
}

Conclusion

This is a nice simple board that can work great for any small project. It won’t be used for any robust system running multiple processes using a RTOS, but if you need to run a few peripherals over a common serial like UART, SPI, or I2C this is a good board for that. It is also great because you are able to use the Arduino Ecosystem along with NXP’s. It is a good low cost simple solution for running some peripherals.

Resources

By Ben R

Comments

Any questions or comments please go to our TechForum