DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • How To Visualize Temporal.io Workflows
  • Introduction to ESP32 for Beginners Using the Xedge32 Lua IDE
  • The Definitive Guide to Developing Portable Tizen Apps
  • Publishing Flutter Packages to JFrog Artifactory

Trending

  • Testing SingleStore's MCP Server
  • Unlocking the Benefits of a Private API in AWS API Gateway
  • Unlocking AI Coding Assistants Part 3: Generating Diagrams, Open API Specs, And Test Data
  • Beyond ChatGPT, AI Reasoning 2.0: Engineering AI Models With Human-Like Reasoning
  1. DZone
  2. Software Design and Architecture
  3. Integration
  4. Tutorial: Blinky With the NXP LPC845-BRK Board

Tutorial: Blinky With the NXP LPC845-BRK Board

Learn how you can create your own blinky application using the MCUXpresso.

By 
Erich Styger user avatar
Erich Styger
·
Feb. 14, 19 · Tutorial
Likes (3)
Comment
Save
Tweet
Share
10.3K Views

Join the DZone community and get the full member experience.

Join For Free

The NXP LPC845-BRK board is a sub-$6 breadboard-friendly development board with an ARM Cortex-M0+ on it. This tutorial is about developing a ‘blinky’ on it using MCUXpresso.

Binky on NXP LPC845-BRK Board

Binky on NXP LPC845-BRK Board

This tutorial goes through the tool installation and basics of implementing a blinky with MCUXpresso. It should give you a starting point for your own application on that board.

Installation

For this tutorial, we need:

  • NXP LPC845-BRK board (see Unboxing the NXP LPC845-BRK Board)
  • NXP MCUXpresso IDE (now V10.3.0, see New NXP MCUXpresso IDE V10.3.0 Release)
  • NXP MCUXpresso SDK for the LPC845

Download the NXP MCUXpresso IDE from http://www.nxp.com/mcuxpresso/ide and install it with the default options.

Go to http://mcuxpresso.nxp.com/ and select the LPC845 SDK (there is no SDK for the board available yet). I recommend that you configure the SDK with all available software components.

SDK for LPC845

SDK for LPC845

Start the IDE (you can use the default workspace) and import the SDK (zip file) with drag and drop into the ‘Installed SDKs’ view:

SDK for LPC845

SDK for LPC845

New Project

Create a new project:

Create New Project

Select the LPC845 and press Next:

LPC845

LPC845

Select the LPC845M301JBD48 for the Device package. Because we are going to use GPIO for the LEDs on the board, make sure that this driver is included. Then, press Finish:

SDK Wizard

SDK Wizard

With this, we have a blinky project:

Blinky Project Created

Blinky Project Created

LED Pins

Next, we configure the pins for the LED on the board. From the schematics, we get this information:

  • Green on PIO1_0
  • Blue on PIO1_1
  • Red on PIO1_2

GPIO RGB LED Pins on LPC845-BRK

GPIO RGB LED Pins on LPC845-BRK

The pins need to be muxed as GPIO output pins. Select the project and open the Pins tool:

Open Pins Tool

Open Pins Tool

Configure PIO1_0, PIO1_1, and PIO1_2 as GPIO pins. The easiest way is to double-click on the GPIO cell entries:

Configured LED GPIO Pins

Configured LED GPIO Pins

Add Identifiers to the pins, for example, LEDG, LEDB, and LEDR. We will use #defines created for the pins later in our code:

Identifiers for the Pins

Identifiers for the Pins

That’s it. Update the project sources with our changes:

Update Project

Update Project

It asks to confirm the changes. Press OK.

Updating Project

Updating Project

Switch back to the Develop Perspective (if not done automatically).

Develop Perspective

Develop Perspective

All the settings are stored in a .mex file. I can double-click on that file later to open the settings again:

MEX File

MEX File

Ungating Clocks

For the LEDs, we are using the GPIO port 1, for which we have to ungate the clocks first; otherwise, the GPIO pins won’t work.

Add the following to the includes:

#include "fsl_gpio.h"


Add the following line to ungate the clocks:

GPIO_PortInit(GPIO, 1); 
/* ungate the clocks for GPIO_1 */


Ungating GPIO 1

Ungating GPIO 1

Configuring GPIO Pins

Next, we have to configure the GPIO pins as output pins with an initial HIGH (1) value. Add the following configuration to your code:

/* configuration for LOW active GPIO output pin */
static const gpio_pin_config_t configOutput = {
 kGPIO_DigitalOutput,  /* use as output pin */
 1,  /* initial value */
};


And initialize all the pins with that configuration:

/* initialize pins as output pins */
GPIO_PinInit(BOARD_INITPINS_LEDR_GPIO, BOARD_INITPINS_LEDR_PORT, BOARD_INITPINS_LEDR_PIN, &configOutput);
GPIO_PinInit(BOARD_INITPINS_LEDG_GPIO, BOARD_INITPINS_LEDG_PORT, BOARD_INITPINS_LEDG_PIN, &configOutput);
GPIO_PinInit(BOARD_INITPINS_LEDB_GPIO, BOARD_INITPINS_LEDB_PORT, BOARD_INITPINS_LEDB_PIN, &configOutput);


Notice that I’m using the Identifier (LEDG, LEDB, and LEDR) in the macros I defined previously in the Pins tool.

GPIO Init Pins

GPIO Init Pins

Delay

To slow down the LED blinky, add a delay function to the code:

static void delay(void) {
  for(int i=0;i<100000;i++) {
    __asm("nop");
  }
}


Delay

Delay

Blinky Code

Finally, add some blinky code to the application. The code below will turn on and off each led with a delay in between:

for(;;) { /* blinky, blinky, blinky! */
  /* red */
  GPIO_PortClear(BOARD_INITPINS_LEDR_GPIO, BOARD_INITPINS_LEDR_PORT, 1<<BOARD_INITPINS_LEDR_PIN); /* turn on */
  delay();
  GPIO_PortSet(BOARD_INITPINS_LEDR_GPIO, BOARD_INITPINS_LEDR_PORT, 1<<BOARD_INITPINS_LEDR_PIN);  /* turn off */

  /* green */
  GPIO_PortClear(BOARD_INITPINS_LEDG_GPIO, BOARD_INITPINS_LEDG_PORT, 1<<BOARD_INITPINS_LEDG_PIN); /* turn on */
  delay();
  GPIO_PortSet(BOARD_INITPINS_LEDG_GPIO, BOARD_INITPINS_LEDG_PORT, 1<<BOARD_INITPINS_LEDG_PIN);  /* turn off */

  /* blue */
  GPIO_PortClear(BOARD_INITPINS_LEDB_GPIO, BOARD_INITPINS_LEDB_PORT, 1<<BOARD_INITPINS_LEDB_PIN); /* turn on */
  delay();
  GPIO_PortSet(BOARD_INITPINS_LEDB_GPIO, BOARD_INITPINS_LEDB_PORT, 1<<BOARD_INITPINS_LEDB_PIN);  /* turn off */
} 


Blinky Code

Blinky Code

Build and Debug

Time to build and then debug it with the board connected:

Build and Debug

Build and Debug

With the board connected to the host, the IDE automatically recognized the board:

Probes discovered

Probes discovered

Press OK and the debugger is loading the code:

Debugging the Board

Debugging the Board

Run it, and enjoy the blinky-blinky-blinky

Binky on NXP LPC845-BRK Board

Binky on NXP LPC845-BRK Board

Summary

Although there is no dedicated SDK for the LPC845-BRK board yet, it is very simple and easy to create a blinky application for it. Using the NXP MCUXpresso SDK, IDE, and Configuration tools, it only needs a few lines in the application code to use the LEDs or any GPIO pins on the board.

List of articles about the LPC845-BRK board:

  • Unboxing the NXP LPC845-BRK Board
  • Tutorial: Using external Debug Probes with NXP LPC845-BRK Board
  • Tutorial: Transforming the NXP LPC845-BRK into a CMSIS-DAP Debug Probe
  • Tutorial: Blinky with the NXP LPC845-BRK Board

Happy Transforming!

Helpful Links

  • LPC845-BRK Board web page
  • User Guide for LPC845-BRK Board
  • NXP LPC845 
  • MCUXpresso SDK
  • MCUXpresso IDE
  • MCUXpresso IDE 10.3.0: New NXP MCUXpresso IDE V10.3.0 Release
  • List of community projects
Software development kit LEd Integrated development environment

Published at DZone with permission of Erich Styger, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • How To Visualize Temporal.io Workflows
  • Introduction to ESP32 for Beginners Using the Xedge32 Lua IDE
  • The Definitive Guide to Developing Portable Tizen Apps
  • Publishing Flutter Packages to JFrog Artifactory

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!