Programming the LPC1114FN28 - Created 19 Dec 2012, last modified: 14 May 2013
http://vilaca.eu/lpc1114/
http://vilaca.eu/lpc1114/vilaca.eu.lpc1114_102_led_blink.zip
#include <LPC11xx.h> /* LPC11xx Peripheral Registers */
#include "system_LPC11xx.h"
#define LED (1<<9) /* LED D1 connect to PIO1_9 */
int main(void)
{
LPC_SYSCON ->SYSAHBCLKCTRL |= (1 << 8); // Enable Clock for TMR1
LPC_IOCON ->PIO1_9 |= (1 << 0); // PIN1_9 = CT16B1_MAT0
LPC_TMR16B1 ->MR0 = 2000; // 50% Duty Cycle
LPC_TMR16B1 ->PR = 12000;
LPC_TMR16B1 ->MR3 = 4000; // Cycle Length
LPC_TMR16B1 ->MCR |= (1 << 10); // TC Reset on MR3 Match
LPC_TMR16B1 ->PWMC |= (1 << 0); // PWM Mode
LPC_TMR16B1 ->TCR |= (1 << 0); // GO
while (1);
// unreachable
return 0;
}
Programming the LPC1114FN28 - Created 19 Dec 2012, last modified: 14 May 2013
http://vilaca.eu/lpc1114/
The LPC1114FN28 is a breadboard friendly MCU that most hobbyists will like and a great chip to get started in ARM embedded development.
It is sold in a DIP package and has a Bootloader installed, so programing it is very easy, requiring virtually zero supporting components.
Unlike most 32 bit MCUs this one can be easily placed in a breadboard, PCB or Perfboard without having to use any special tools or equipment.
Overall features: 32 bits, 50MHz, ARM Cortex M0 family, DIP package, Built-in serial Bootloader, 1.8-3.6v, up to 50 MHz, 8KB SRAM, SPI, I2C, USART, 10 bit ADC, 16 & 32 bit timers, ISP, Internal Oscillator and many more.
Plugging it in for programming
You don't need a fancy development kit to test your code: a simple breadboard and a USB to TTL adapter will be enough as only 5 pins are necessary for this task
Pins 21 and 22 should be connected to your power source, usually a voltage regulator, possibly a LM117, or your USB to TTL adapter 3.3V pin.
Pins 16 and 17 should be connected to your UART pins TX and RX respectively; RX on the MCU should be connected to TX on the UART and TX to RX.
Pin 24 should be connected to GND. When the MCU boots, this pin is tested and, if it is connected to GND, the program in flash memory will run. Connecting it to GND [Vdd?] makes the chip run the boot-loader, allowing a program to be written to the MCU internal Flash memory.
Example program
Download and unzip the file vilaca.eu.lpc1114_102_led_blink.
This file is an example program that can be uploaded to the LPC1114 using the previous circuit.
It is a very simple program that uses PWM to blink a led on pin 18 every second. The led stays ON for exactly 1/2 second.
Once you upload it to the LPC1114 you can switch to the circuit bellow to run the program.
You can also download the full Keil project for this example.
http://vilaca.eu/lpc1114/vilaca.eu.lpc1114_102_led_blink.zip
Uploading the program with Flash magic
Flash magic is a free and easy to use tool that can upload program files to a large variety of microcontrollers.
Make sure you select the correct COM port where the USB to TTL UART is connected in your computer. In the screenshot above COM 5 is selected.
Flash Magic can only handle files in the .hex format and can be downloaded from: http://www.flashmagictool.com/
If you're using Linux there's a very good article on how to program this MCU using open tools at http://www.meatandnetworking.com.
Simple circuit for blinking led
The following is a simple circuit to make a led blink.
Since the MCU already has an internal oscillator very few parts are needed
Pins 18 is connected to a generic Led and resistor. I used a 330 Ω resistor for this setup.
Pins 22 and 23 should be connected to your power source.
This setup is enough to run a program blinking the LED and you can adapt it to your needs.
In this example pin 18 was selected because it is one of the timer output pins. In the sample program we set timer to do PWM with a cycle length of around 1HZ, that is one blink per second.
LPC1114 Pin reference
PIN GPIO AD Timers SPI I2C UART Other
1 PIO0_8 CT16B0_MAT0 MISO0
2 PIO0_9 CT16B0_MAT1 MOSI0
3 PIO0_10 CT16B0_MAT2 SCK0 SWCLK
4 PIO0_11 AD0 CT32B0_MAT3
5 PIO0_5 SDA
6 PIO0_6
7 VDDA
8 VSSA
9 PIO1_0 AD1 CT32B1_CAP0
10 PIO1_1 AD2 CT32B1_MAT0
11 PIO1_2 AD3 CT32B1_MAT1
12 PIO1_3 AD4 CT32B1_MAT2 SWDIO
13 PIO1_4 AD5 CT32B1_MAT3 WAKEUP
14 PIO1_5 CT32B0_CAP0 RTS
15 PIO1_6 CT32B0_MAT0 RXD
16 PIO1_7 CT32B0_MAT1 TXD
17 PIO1_8 CT16B1_CAP0
18 PIO1_9 CT16B1_MAT0
19 XTALOUT
20 XTALIN
21 VDD
22 VSS
23 PIO0_0 RESET
24 PIO0_1 CT32B0_MAT2 CLKOUT
25 PIO0_2 CT16B0_CAP0 SSEL0
26 PIO0_3
27 PIO0_4 SCL
28 PIO0_7 CTS
LPC1114 Pinout Diagram
Useful downloads
If you haven't already, you can go to the NXP website and download a free version of the Keil environment and start coding: http://www.keil.com/dd/chip/6526.htm
To upload your finished program to the MCU you can use:
http://www.flashmagictool.com/
External links
NXP product page for LPC1114FN28/102
http://www.nxp.com/products/microcontrollers/cortex_m0/lpc1100_x_l/LPC1114FN28.html
IPS (Polytechnic Institute of Setúbal, Portugal) is a public institution of higher education, which employs approximately 650 personnel and has app. 6 500 students.
.END
No comments:
Post a Comment