Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe

How to Interface LED to LPC1768 Microcontroller (ARM Cortex)?

By Tularam M Bansod April 21, 2008

Introduction

ARM cortex is new microcontroller. It is designed by ARM limited. ARM company had given license to 200 vendors for production. The share of LPC2148 is almost reducing in the market. ARM also aggressively promoting ARM cortex. We have to understand features and way of programming. What are new features of ARM cortex like LPC1768. LPC1768 is manufactured by NXP and it is based on ARM cortex M3 core. It is good for high level of integration and low power consumption embedded system.

Handheld devices are becoming more popular. That devices are smart mobile phone, Kindle, Smart Tab. Low power consumption is required in these devices.

Technical features:

1) Three stage pipe line architecture

2) Higher frequency working. 100 MHz to 120 Mhz is normal working.

3) Harvard architecture which is providing separate buses for local instruction, peripheral and data.

4) There is internal instruction prefetching unit which helps for predicting jumps in the program.

5) It is 100 pin SMD form IC.

6) There is 512 KB flash memory and 64 KB is data memory.

7) Two channels of CAN (Control Area Network) is available.

8) Ethernet MAC is supported which can used as hardwired Web server kind of development.

9) Four UARTs are supported.

10) There are 70 General purpose IO pins and 8 channels of 12 bit ADC.

Pin diagram of LPC1768:

 

 

Fig 1: Pin diagram of LPC1768 Microcontroller. (100 pin SMD Physical IC)

[header=ARM Cortex]

ARM cortex Programming:

Whenever we are doing programming of ARM cortex, we have to understand about registers, SFRs which are supported for peripherals.

The processor has the following 32-bit registers:

• 13 general-purpose registers, r0-r12

• stack point alias of banked registers, SP_process and SP_main

• link register, r14

• program counter, r15

• one program status register, xPSR.

Figure 1 shows the processor register set. These are general purpose registers. There are various other registers which we can use for programming. For example FIODIR register to select Output or Input direction of signal. Let you want to blink LED on P1.29 port line of ARM cortex. Then value of FIODIR=0x20000000; This value look like bigger but that’s due to 32 bit of Port 1 of ARM cortex.

  • r0

    r1

    r2

    r3

    r4

    r5

    r6

    r7

    r8

    r9

    r10

    r11

    r12

    r13

    r14

    r15

    CPSR

 

Fig 1 Registers of ARM cortex microcontroller.

Similarly we have to understand FIOSET register. This is Fast version register to SET single bit Port line. When I want to make LED ON, I can assign FIOSET=0x00000200;

Similarly we can assign FIOCLR=0x00000200; to make LED OFF also we can set bit equal to “1” that is interesting part in ARM programming.

Steps for Programming:

1) You create project in your working directory, give LED_toggle.uvproj name to it and then compiler will ask you TARGET name, select NXP and LPC1768 microcontroller.

2) Then compiler will ask “whether you want Startup file?” click on “Yes” button so that Startup_LPC17xx.s file will help compiler to maintain Memory Mapping for Lpc1768 microcontroller.

3) Open new file to type source code. Type following code in IDE.

#include “lpc17xx.h”

 

 

int main (void)

{

int j;

 

SystemInit();

 

LPC_GPIO2->FIODIR =0x00000200; // P2.9 = Outputs

LPC_GPIO2->FIOCLR = 0x00000200; // Turn-OFF LED

 

//Loop LED Test

while(1)

{

LPC_GPIO2->FIOSET=0x20000000 ; // Turn-ON LED

for(j = 1000000; j > 0; j–);

LPC_GPIO2->FIOCLR = 0x20000000; // Turn-OFF LED

for(j = 1000000; j > 0; j–);

}

}

 

 

4) You have to take care to add “System_LPC17xx.c” file for SystemInit() function. This SystemInit() function is long technical function for Initializing Microcontroller. PLL logic is used to set frequency in this function.

5)Fig 2 shows Keil screen of LED_toggle project.

 

 

Fig 2: LED_toggle project screen

6)Once you type source code, now

You can set options for creating HEX file in “Options for Target” in Project Menu. Fig 3 shows Debug to test code in compiler. In debugging mode, you can see Register values of LPC1768 Microcontroller.

 

Fig 3: Debug mode of Keil compiler version 4.

 

7) Now in debug mode you can select “Fast GPIO -> Port 2” to check output in Simulator. If you are getting some error to run code in simulator then might be you forgot to select Simulator options and your keil compiler is in “Hardware Debug Mode”.

Fig 4 shows output of LED toggling at Port 2 and line 9. If you are not getting blink then reduce delay value in FOR LOOP so that you can see blink output.

Fig 4 Out put of LED toggling program at P2.9 port line of LPC1768.

I do believe this program seem very simple but many times due to Library file this become very tough to run. We assume you have library file of LPC1768 Iniitlaization function with you.


Filed Under: Articles

 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

EE TECH TOOLBOX

“ee
Tech Toolbox: 5G Technology
This Tech Toolbox covers the basics of 5G technology plus a story about how engineers designed and built a prototype DSL router mostly from old cellphone parts. Download this first 5G/wired/wireless communications Tech Toolbox to learn more!

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions

  • How to improve the reliability of RS485 communication?
  • The Analog Gods Hate Me
  • Battery Deep Discharge – IC Workarounds?
  • Safe Current and Power Density Limits in PCB Copper(in A/m² and W/m³) simulation
  • Why so few Phase shift full bridge controllers?

RSS Electro-Tech-Online.com Discussions

  • Simple LED Analog Clock Idea
  • The Analog Gods Hate Me
  • Wideband matching an electrically short bowtie antenna; 50 ohm, 434 MHz
  • PIC KIT 3 not able to program dsPIC
  • Parts required for a personal project

Featured – LoRa/LoRaWan Series

  • What is the LoRaWAN network and how does it work?
  • Understanding LoRa architecture: nodes, gateways, and servers
  • Revolutionizing RF: LoRa applications and advantages
  • How to build a LoRa gateway using Raspberry Pi
  • How LoRa enables long-range communication
  • How communication works between two LoRa end-node devices

Recent Articles

  • Tria modules integrate edge AI processing with multi-core processors
  • pSemi introduces RF switch with 52 dBm PMAX,PEAK and 90-dBm IIP3 linearity
  • XP Power launches 1.3 kW power supply with 58.9 W/cm³ density
  • How to enable Wi-Fi provisioning in ESP32-based IoT products
  • Amphenol RF introduces FAKRA to SMA adapters with 4 GHz operating frequency

EE ENGINEERING TRAINING DAYS

engineering

Submit a Guest Post

submit a guest post
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy

Search Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe