Download Print this page
NXP Semiconductors LPC1114 Getting Started With

NXP Semiconductors LPC1114 Getting Started With

Cortex-m0 arm microcontrollers

Advertisement

Quick Links

Getting Started with NXP's LPC11XX Cortex-M0 ARM
Microcontrollers
Introduction
Hardware
Software
Code Example 0: Toggle a GPIO Pin
Code Example 1: Read a GPIO Pin
Code Example 2: Setting Up the Oscillator
Code Example 3: Transmitting Data Using the UART
Code Example 4: Receiving Data Using the UART
Code Example 5: Using the Analog to Digital Converter (ADC)
Code Example 6: Transmitting with Synchronous Serial Port (SSP/SPI)
Code Example 7: Setting Up the 16bit Timer for PWM
Code Example 8: Transmitting with I2C
Author's Note:
Introduction
Many engineers use 8 bit microcontrollers because of their low cost and ease of use. 32 bit microcontrollers generally offer higher performance
than 8 bit parts, but many believe their cost is significantly higher than bit uCs and that they are more difficult to use than 8 bit parts. While 32 bit
parts are generally a little more complicated than 8 bit parts, the cost of 8 and 32 bit parts aren't that far apart in many cases. Additionally, the 32
bit parts offer significantly higher performance. In other words, give 32 bit parts a chance!
NXP has introduced a very low cost (i.e. often less than $1 in production volumes) line of 32 bit microcontrollers, the LPC111X family. There are
several other companies also offering some type of ARM Cortex M0 microcontroller. NXP was one of the earliest, but Freescale (Kinetis L), ST
Micro (STM32 F0), and Nuvoton (M051,M058,Mini51,NUC100,NUC122) also have Cortex M0 offerings. This document will give a brief
introduction on how to get up and running using NXP's
The assumption inherent in this document is that most engineers follow a fairly similar method of learning when presented with a new
microcontroller family. They start by getting a development kit and trying to toggle a pin, transmit/receive with a serial port, read an ADC pin
etc. This document will show some very simple examples of how to enable and operate these peripherals. This will not be exhaustive of every
operating mode and every peripheral but, it is hoped that it will cover the basics in sufficient detail to allow an engineer to get up and running
quickly. Also included are some tips regarding custom design of PCBs using these parts (see example schematic and BOM below in the
"Hardware" section.
This document is primarily targeted at those who are familiar with 8 bit microcontrollers, but are interested in learning to use a 32 bit part. It is
hoped that this document can make getting started with a 32 bit part as painless as possible. It is realized that this code is very simplistic, and if
one were going to write production code, there would certainly be other features, such as error checking, that would be needed. This code is
provided purely to provide a simplistic "working" example.
LPC1114
. The code will work on several other members of the LPC11xx family as well.

Advertisement

loading
Need help?

Need help?

Do you have a question about the LPC1114 and is the answer not in the manual?

Questions and answers

Summary of Contents for NXP Semiconductors LPC1114

  • Page 1 Micro (STM32 F0), and Nuvoton (M051,M058,Mini51,NUC100,NUC122) also have Cortex M0 offerings. This document will give a brief introduction on how to get up and running using NXP's LPC1114 . The code will work on several other members of the LPC11xx family as well.
  • Page 2 OM11049,598 plugs in on top of this baseboard and allows you to use the peripherals of the LPC1114 in an easily measurable/observable way. Since this page was first built NXP purchased Embedded Artists and has obsoleted the EA-XPR-002 .
  • Page 3 Ref Des Part Number Digi-Key Part Number Other Options LPC1114FBD48/302,1 (NXP) 568-5150-ND 534237-6 (TE Connectivity) A26420-ND S5444-ND, A35047-ND ABM7-12.000MHZ-D-2-Y-T (Abracon) 535-9836-1-ND 39pF GRM1885C1H390JA01D (Murata) 490-1417-1-ND EMK107B7105KA-T (Taiyo Yuden) 587-1241-1-ND Figure 2: Here here are some examples of basic circuits that can be used to get the LC1114 up and running on a custom board.
  • Page 4 mating connector for the three connectors given/shown above is 961108-5604-AR from 3M Figure 3: 5535676-7 (TE Connectivity), 534237-6 (TE Connectivity), PPTC081LGBN-RC (Sullins), and 961108-5604-AR (3M) respectively...
  • Page 5 Figure 4 Above (figure 3) is a pictorial example of how the OM11049,598 can be used as an inexpensive programmer/debugger. The OM11049,598 board can be carefully split in two using a “Dremel” tool, at least that’s how separation was accomplished in this case. Wear safety glasses! Alternatively, I was told by an NXP applications engineer that some customers have found that an old style paper cutter (see Figure 4)
  • Page 6 works very well too. If you don't like the idea of cutting the board, the OM11049,598 can be used without physically splitting the PCB in two. To prepare for use without sawing it in half, use an “exacto” knife to cut the traces between the two rows of vias that compose J4. Then solder a vertical connector into the vias on the programmer/debugger side.
  • Page 7 0 ; Important Note: The LPC1114 toggles pins rather slowly. If you set the oscillator to a frequency of 48MHz and comment out the two "for" loops you’ll find that this program will only toggle a pin at around 1MHz. It’s something to be aware of if you are planning to toggle pins in a timing critical application.
  • Page 8 //unsigned int i = 0; while(1){ //infinite loop if(LPC_GPIO1->DATA & (1<<4)) //check state of pin 40, PIO1_4 (sec 12.3.1) LPC_GPIO0->DATA |= (1<<7); //set pin high (sec 12.3.1) else LPC_GPIO0->DATA &= ~(1<<7); //set pin low (sec 12.3.1) return 0 ; In order to change the state of pin 40 on the OM11049,598 board a switch such as 450-1467-ND...
  • Page 9 to the MAINCLKUEN register (sec. 3.5.12), necessary for MAINCLKSEL to update LPC_SYSCON->MAINCLKUEN |= 1; //write a one to the MAINCLKUEN register (sec. 3.5.12) for(;;){ //infinite loop //your application code here return 0 ; The critical bit of code to keep in mind is this line: LPC_SYSCON->SYSPLLCTRL = 0x42;...
  • Page 10 #include "LPC11xx.h" int main(void) { //SET UP UART (sec. 13.2 in datasheet "BASIC CONFIGURATION") LPC_IOCON->PIO1_7 |= 0x01; //configure UART TXD pin (sec. 7.4.41) LPC_SYSCON->SYSAHBCLKCTRL |= (1<<12); //enable clock to UART (sec. 3.5.14) LPC_SYSCON->UARTCLKDIV |= 0x9B; //0x9B will give approx. 19.2K baud signal (sec. 3.5.16) LPC_UART->FCR |= 0x01;...
  • Page 11 Figure 6: Example scope shot of 19.2k baud transmission of hex value 0x55 using UART code given above. Code Example 4: Receiving Data Using the UART The program below demonstrates how data can be received through the serial port. Note that this code will only work if the TX pin (PIO1_7) and RX pin (PIO1_7) are shorted together.
  • Page 12 LPC_SYSCON->UARTCLKDIV |= 0x4e; //set clk divider to 4e (sec 3.5.16) LPC_UART->FCR |= 0x01; //enable FIFO (sec 13.5.6) LPC_UART->LCR |= 0x03; //set for 8 bit data width, 1 stop bit, no parity (sec 13.5.7) LPC_UART->TER |= 0x80; //enable transmission (sec 13.5.16) unsigned int i = 0;...
  • Page 13 LPC_UART->LCR |= 0x03; //set for 8 bit data width (sec. 13.5.7) LPC_UART->TER |= 0x80; //transmit enable (sec. 13.5.16) //SET UP THE ADC LPC_SYSCON->PDRUNCFG &= ~(0x1<<4); //power the ADC (sec. 3.5.35) LPC_SYSCON->SYSAHBCLKCTRL |= (1<<13); //enable clock for ADC (sec. 3.5.14) LPC_IOCON->R_PIO0_11 &= 0xFFFFFF78;...
  • Page 14 LPC_IOCON->PIO2_0 = (LPC_IOCON->PIO2_0 & ~(0x3)) | 0x2; //set PIO2_0 up as SSEL function (sec. 7.4.2) LPC_IOCON->PIO2_1 = (LPC_IOCON->PIO2_1 & ~(0x3)) | 0x2; //set PIO2_1 up as SCK function (sec. 7.4.9) LPC_SYSCON->SYSAHBCLKCTRL |= (1<<18); //enable clock to SPI1 block (sec. 3.5.14) LPC_SYSCON->SSP1CLKDIV |= 0x2F;...
  • Page 15 Figure 7: This oscilloscope screenshot show the SCLK signal (in yellow) and the MOSI signal (in blue). Code Example 7: Setting Up the 16bit Timer for PWM The following is a code snippet showing how to set up 16 bit timer 0 for PWM operation on PIO0_8 (pin 27 of the 48 pin LQFP package). In this case, the value for the period of the PWM signal is loaded into LPC_TMR16B0->MR1.
  • Page 16 LPC_TMR16B0->CCR //set to timer mode (sec 18.7.11) LPC_TMR16B0->PWMC 0x1; //set channel zero to PWM mode (sec 18.7.12) LPC_TMR16B0->MR1 0x32; //set value for period (sec 18.7.7) LPC_TMR16B0->MR0 0xC; //set value for duty cycle (sec 18.7.7) LPC_TMR16B0->TCR 0x3; //enable and reset counter (sec 18.7.2) LPC_TMR16B0->TCR &= ~...
  • Page 17 transmit mode (sec 15.8.1 and 15.7.1) LPC_I2C->SCLH = 0xFFF; //set clk dividers (sec 15.7.5) set arbitrarily long LPC_I2C->SCLL = 0xFFF; //set clk dividers (sec 15.7.5) set arbitrarily long unsigned int i = 0; unsigned int status = 0; while(1){ //infinite loop //I2C TRANSMIT LPC_I2C->CONSET |= (1<<5);...
  • Page 18 To get in touch with us call 1.800.344.4539. Additionally, all the authors of the eewiki can also be contacted by email. Just send an email to eewiki @digikey.com and mention the author in the subject line. Want a production part quote right now? Send me the information below ( example Project Name Project Description...

This manual is also suitable for:

Lpc11 series