Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key 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
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
    • Design Guides
      • WiFi & the IOT Design Guide
      • Microcontrollers Design Guide
      • State of the Art Inductors Design Guide
  • Women in Engineering

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

By Tularam M Bansod

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: Recent Articles

 

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.

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!


Featured Tutorials

  • PS2 Keyboard To Store Text In SD Card Using Arduino Circuit Setup On Breadboard
    How To Use PS2 Keyboard To Store Text In SD Card Using Arduino- (Part 42/49)
  • Wireless Path Tracking System Using Mouse, XBee And Arduino Circuit Setup On Breadboard
    How To Make A Wireless Path Tracking System Using Mouse, XBee And Arduino- (Part 43/49)
  • How to Make a Wireless Keyboard Using Xbee with Arduino- (Part 44/49)
  • Making Phone Call From GSM Module Using Arduino Circuit Setup On Breadboard
    How to Make Phonecall From GSM Module Using Arduino- (Part 45/49)
  • How to Make a Call using Keyboard, GSM Module and Arduino
    How To Make A Call Using Keyboard, GSM Module And Arduino- (Part 46/49)
  • Receiving SMS Using GSM Module With Arduino Prototype
    How to Receive SMS Using GSM Module with Arduino- (Part 47/49)

Stay Up To Date

Newsletter Signup

Sign up and receive our weekly newsletter for latest Tech articles, Electronics Projects, Tutorial series and other insightful tech content.

EE Training Center Classrooms

EE Classrooms

Recent Articles

  • Renesas delivers intelligent sensor solutions for IoT applications
  • Microchip Technology releases AVR-IoT Cellular Mini Development Board
  • Qualcomm acquires Cellwize to accelerate 5G adoption and spur infrastructure innovation
  • MediaTek’s chipset offers high-performance option for 5G smartphones
  • Nexperia’s new level translators support legacy and future mobile SIM cards

Most Popular

5G 555 timer circuit 8051 ai Arduino atmega16 automotive avr bluetooth dc motor display Electronic Part Electronic Parts Fujitsu ic infineontechnologies integratedcircuit Intel IoT ir lcd led maximintegratedproducts microchip microchiptechnology Microchip Technology microcontroller microcontrollers mosfet motor powermanagement Raspberry Pi remote renesaselectronics renesaselectronicscorporation Research samsung semiconductor sensor software STMicroelectronics switch Technology vishayintertechnology wireless

RSS EDABOARD.com Discussions

  • ADS Cascode Power Amplifier Loadpull Problem
  • lna+mixer noise figure problem
  • Thermal pad
  • DC DC converter output voltage rise time
  • building lm2596 dc dc using Arduino uno

RSS Electro-Tech-Online.com Discussions

  • Where is the fuse ?
  • 500+V power supply from 9V battery using ZVS
  • Control Bare LCD With ATmega328p
  • undefined reference header file in proteus
  • Engine compression high voltage ignition voltage?
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • About Us
  • Contact Us
  • Advertise

Copyright © 2022 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 | Advertising | About Us

Search Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key 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
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
    • Design Guides
      • WiFi & the IOT Design Guide
      • Microcontrollers Design Guide
      • State of the Art Inductors Design Guide
  • Women in Engineering