This document explains how to create a new project using MCUXpresso IDE for a LPCXpresso1549 board.
There is important to mention that there is no SDK for LPC15xx device family so we are using LPCOpen libraries.
MCUXpresso IDE is based on the Eclipse IDE and includes the industry standard ARM GNU toolchain. It brings developers an easy-to-use and unlimited code size development environment for NXP MCUs based on Cortex-M cores (LPC and Kinetis). MCUXpresso IDE debug connections support Freedom, Tower®, LPCXpresso and your custom development boards with industry- leading open-source and commercial debug probes including LPC-Link2, P&E and SEGGER.
The fully featured debugger supports both SWD and JTAG debugging, and features direct download to on-chip flash.
When MCUXpresso IDE is installed, it will contain pre-installed part support for most LPC based MCUs. Example code for these pre-installed parts is provided by sophisticated LPCOpen packages (and Code Bundles). Each of these contains code libraries to support the MCU features, LPCXpresso boards (and some other popular ones), plus a large number of code examples and drivers.
In addition, MCUXpresso IDE’s part support can be extended using freely available MCUXpresso SDK2.x packages. These can be installed via a simple ‘drag and drop’ and automatically extend the IDE with new part knowledge and examples.
SDKs for MCUXpresso IDE can be generated and downloaded as required using the SDK Builder on the MCUXpresso Config Tools website at:
For this document, we are using the LPCXpresso1549 board (for this MCU an LPCOpen project exists), however the process is the same for any LPCXpresso board.
It is necessary to download the LPCOpen bundle for your target MCU/board and import it into your Workspace, LPCOpen is available in the next link:
NOTE: When the board is selected, you can see highlighted in the above figure that the matching MCU (part) is selected automatically. If no matching board is available, the required MCU can be selected from the list of Pre-Installed MCUs.
This New Project wizard supports 2 types of projects:
In this case, we will show the steps in creating a LPCOpen- Cproject. This option creates a simple C project, with the main() routine consisting of an infinite while(1) loop that increments a counter. In additions, code will also be included to initialize the board and enable a LED.
It is necessary import the LPCOpen Chip Library for the device used and optionally the LPCOpen Board Library Project, the below window allows to import the libraries if you have not already done so. Follow the below steps:
a. Click on “Import…”, a new window will appear, select the archive file to import. In this case, the projects imported are contained within archives .zip. For this example, the LPCXpresso1549 board is selected. Click “Open”. Then click “Next”
b. Select only the LPCOpen Chip Library and LPCOpen Board Library Project. Click “Finish”
NOTE: The use of LPCOpen instead of CMSIS-CORE library projects is recommended in most cases for new projects.
“character-by-character” versions of these functions (which do not require additional heap space). This can be useful, for example, if you are retargeting printf() to write out over a UART – since in this case it is pointless creating a temporary buffer to store the whole string, only to print it out over the UART one character at a time.
For this example we will maintain as default.
Writing my first project
The LPCOpen Chip Library (in this case lpc_chip_15xx) contains the drivers for some LPC peripherals. For these examples, we will use the GPIO Driver.
The LPCOpen Board Library Project (in this case lpc_board_nxp_lpcxpresso_1549) contains files with software API functions that provide some simple abstracted functions used across multiple LPCOpen board examples.
The board_api.h contains common board definitions that are shared across boards and devices. All of these functions do not need to be implemented for a specific board, but if they are implemented, they should use this API standard.
After create a new project using MCUXpresso and LPCOpen, it is created a simple C project where it is initialized the board and set the LED to the state of "On" using the Board_LED_Set function.
In this example, we will toggle the a LED using a push bottom. In LPCXpresso1549 board le LEDs are connected to PIO1.1, PIO0.3 and PIO0.25 pins. And the SW1 to PIO0.17 pin.
The function Chip_GPIO_SetPinDIRInput configures a pin as input.
The function Chip_GPIO_GetPinState gets a GPIO pin state via the GPIO byte register.
The function Board_LED_Set set the LED to the state of "On" or “Off”..
Complete code (Set the LED using a push bottom).
/*
===============================================================================
Name : LPCXpresso_new_example.c
Author : $(author)
Version :
Copyright : $(copyright)
Description : main definition
===============================================================================
*/
#if defined (__USE_LPCOPEN)
#if defined(NO_BOARD_LIB)
#include "chip.h"
#else
#include "board.h"
#endif
#endif
#include <cr_section_macros.h>
int main(void) {
bool State_Input;
#if defined (__USE_LPCOPEN)
// Read clock settings and update SystemCoreClock variable
SystemCoreClockUpdate();
#if !defined(NO_BOARD_LIB)
// Set up and initialize all required blocks and
// functions related to the board hardware
Board_Init();
Chip_GPIO_SetPinDIRInput(LPC_GPIO, 0, 17); //Set GPIO direction for a single GPIO pin to an input
#endif
#endif
while(1) {
State_Input= Chip_GPIO_GetPinState (LPC_GPIO, 0, 17); //Get a GPIO pin state via the GPIO byte register
if (State_Input==0){
Board_LED_Set(0, true); // Set the LED to the state of "On"
}
else {
Board_LED_Set(0, false); // Set the LED to the state of "Off"
}
}
return 0 ;
}
翻译成了中文,感兴趣的朋友可以看一看。如有错漏,敬请指正。
Great tutorial to create a new LPC project. I have lost more than a week with errors while building my poject. The errors were "undefined reference to Chip_SWM_MovablePinAssign" or "undefined reference to Chip_UART_SetBaud", etc. I have understood that the binary variable "NO_BOARD_LIB" was true. Firstly, I thought tha the link to the library of LPCOpen was wrong and I tried to make the link to the library manually without success. When I had lost hope to find a solution, I searched for tutorial to create a new LPC project. Thanks to your tutorial, I understand that I haven't added the LPCOpen Board library as you mentionned in step 6.
Thanks again !
Soufien