How to use the GPIO pins on the LPC55S69 powered Okdo E1

Over the last couple of years, I’ve utilized a few different Arduino, Raspberry Pi, and other Linux based hobbyist development boards, like the BeagleBone Black, for many of my projects. I, however, never used other microcontroller boards that weren’t Arduino compatible. Recently, I started experimenting with the Okdo E1, a development board that’s powered by the LPC55S69, a very capable NXP microcontroller.

So I found myself in the situation of being a complete beginner again, and while there was some material out there that discusses the absolute basics, most of it was still quite technical and was clearly aimed at professionals. Therefore, I decided to write a gentler (and more top-level) introduction that explains how you can get started with using the LPC55S69 GPIO pins.

Creating a new project in MCUXpresso

Make sure to download and install the MCUXpresso IDE if you haven’t done that already. Before you proceed any further, make sure that you read through the official getting started guide and that you can execute the hello world project.

Then, create a new C/C++ project in MCUXpresso:

The MCUXpresso IDE's main menu bar is shown in the image. The mouse cursor hovers over the Project entry that can be found in the File menu under the new entry.
Figure 1: Use the IDE’s main menu bar to open the ‘New Project’ Wizzard. Then select ‘C/C++ Project’

Make sure to select the correct entry in the pop-up window:

The image highlights that it's important to select the New C/C++ Project entry in the pop-up window instead of the C/C++ Project entry.
Figure 1a

On the next page, make sure to select the lpcxpresso55s69 SDK and click the ‘next’ button:

This image shows the available SDKs that one can choose from. In my installation, I only have the 55s69 SDK installed. It is selected, and the next button is highlighted.
Figure 2: Select the SDK for the lpcxpresso55s69 development board (even if you’re using the Okdo E1)

Enter a name for your project on the next page, check whether the gpio driver is imported (which it should be by default), and click ‘finish’ once you’re done:

This image explains how to enter a name for the project. The project name textbox is highlighted and marked with a one. The next button is marked with a two.
Figure 3: Give your project a name and click ‘Finish’ once you’re done

After a short while, the new project should open up automatically, and you should see something similar to this:

This image contains a screenshot of the IDE's main window in its default setup.
Figure 4: The newly created project should open up automatically

Configuring the system clock

Next, you’ll have to configure the system clock (as demonstrated in the getting started guide). Because the process is explained in great detail in the aforementioned guide, I’ll only show you the end result of that step:

This image portrays the clocks tool of the IDE. The functional groups dropdown is highlighted, and the BOARD_BootClockFROHF96M functional group is selected. The green flag next to the dropdown selection is marked with a green tick mark.
Figure 4: Select the BOARD_BootClockFROHF96M functional group, make sure that the green flag next to it is checked, and don’t forget to click the ‘Update Code’ button!

Using the pins tool to configure the GPIO pins

Once you’ve configured the project and the clock, make sure to upload the code to the microcontroller and see whether everything goes as planned. Once the upload’s done, you should see that ‘Hello World’ got printed to the serial monitor of the IDE.

Now, stop the debugging process, and open up the ‘Pins’ tool in MCUXpresso:

This image shows the IDE's main window with the pins menu item highlighted.
Figure 5: Open the Pins tool from the IDE’s main menu bar

The tool should bring up the following perspective within the IDE:

This image is an overview of the pins tool. On the left-hand side, there is a list of available pins. The center area displays the MCU. The bottom half of the image contains a list of already routed pins.
Figure 6: The pins tool

Next, you should think about what GPIO pin you’d like to use:

An overview of the physical pins present on the okdo e1
Figure 7: The pinout of the Okdo E1

In this tutorial, I’ll be using PIO0_15 (Pin #4 on the left-hand side of the PCB). In the pins tool, use the search bar in the left panel to find that pin. Once you found it, click the gray box next to the pin’s number:

This image illustrates how a user can search for a pin in the pins tool. Then, the grey checkbox next to the search result is highlighted with an arrow.
Figure 8

When you click that small gray box, a pop-up window will appear where you can select the function(s) that this pin should have. In this case, choose GPIO:

Once the user clicked the grey checkbox and selected a function for the pin, said checkbox turns green. Furthermore, the image also shows that the pin name is now also highlighted in green.
Figure 9: Select the GPIO function for pin 22. Once you’ve done that, the small gray box will turn green, and the pin appears in the ‘Routed Pins’ tab in the bottom half of the IDE.

Once you’re done, click the ‘Update Code’ button and switch back to the Code-Editor perspective.

Writing values to and reading values from the GPIO pins

Once you routed the GPIO pins that you’d like to control, get back to the main code file and add the following lines for every GPIO pin you want to use to output values:

gpio_pin_config_t PIO0_15_config =
{
   kGPIO_DigitalOutput, // Mode
   0 // Initial State
};

int main(void)
{
    BOARD_InitPins();

    /* Other initialization calls */

    GPIO_PinInit(GPIO, 0, 15, &PIO0_15_config);

    /* Rest of the main method */
}

Above the main, I added a small configuration for the GPIO pin in question. It states that the pin will be used as an output and that its initial state will be LOW. In the main method itself, the pin is initialized. These steps are only necessary if you want to output something. GPIO pins that you’ll use as input pins don’t have to be initialized this way.

To read a pin’s state use the following function:

// Read the current state of pin PIO0_15
bool value = GPIO_PinRead(GPIO, 0, 15);

To set a pin HIGH or LOW, use the following function:

GPIO_PinWrite(GPIO, 0, 15, 1U); // Set pin HIGH
GPIO_PinWrite(GPIO, 0, 15, 0U); // Set pin LOW

Note that output pins must be initialised as described above before you can use them!

You can take a look at the official API page for further details and examples.

Summary

Maybe it’s just me, but being a maker and coming from a Raspberry Pi and Arduino background with little to no experience in embedded systems, I found it quite confusing to get started with the LPC5500. I couldn’t find a tutorial that talked about these simple beginner’s topics. That’s why I decided to quickly put one together. Once you get the hang of it, the process is pretty straight-forward and easy to remember.

Sources

MCUXpresso API – mcuxpresso.nxp.com
Okdo E1 getting started guide – okdo.com
Getting started with the LPC5500 series – allaboutcircuits.com
First experience with Okdo E1 board – mcuoneclipse.com

Image sources

[Title image] Original image courtesy of allaboutcircuits.com
[Figure 7] Okdo E1 pinout diagram – okdo.com

Table of content

How to use the GPIO pins of the LPC55S69 (You are here)
How to use interrupts on the LPC55S69

One thought on “How to use the GPIO pins on the LPC55S69 powered Okdo E1

Leave your two cents, comment here!

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.