Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Sensor Series
      • 3D Printing
      • AI
      • ARDUINO Compatible Coding
      • Audio Electronics
      • Battery Management
      • Beginners Electronics Series
      • Brainwave
      • Digital electronics (DE)
      • Electric Vehicles
      • EMI/EMC/RFI
      • EVs
      • Hardware Filters
      • IoT tutorials
      • LoRa/LoRaWAN
      • Power Tutorials
      • Protocol
      • Python
      • RPI Python Programming
      • Sensors
      • USB
      • Thermal management
      • Verilog
      • 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
  • Guest Post Guidelines
  • Advertise
  • Subscribe

Getting started with the ARM Cortex M3 (LPC1768)- (Part 1/21)

By Prabakaran P.M March 22, 2024

This is the Article to introduce the programming of ARM Cortex-M3 LPC1768 Microcontroller. First step in this journey is to get yourself introduced to the programming Environment. For programming LPC1768 plenty of free software are available online. For ARM based Microcontrollers it is suggested to go with Keil µVision4. For the beginner, Demo version of Keil is more than enough to start with. Let’s start with the brief introduction to the LPC1768 ARM cortex M3 based Microcontroller.


The LPC 1768 is ARM Cortex- M3 based Microcontrollers for embedded application features in low power consumption and a high level of integration. The ARM Cortex M3 is designed in a such way to enhance debug features and a higher level of system integration. It clocks at a CPU frequency of 100 MHz, and incorporates a 3-stage pipeline and uses a Harvard architecture with separate local instruction and data buses for third bus peripherals. The ARM Cortex- M3 CPU have an internal pre-fetch unit to support speculative branching. The peripheral components include 512KB of flash memory, 64kb of data memory, Ethernet MAC, USB OTG, 4 UART’s, 8-channel general purpose DMA controller, 2 SSP Controllers, 10-bit DAC, Quadrature encoder interface, SPI interface, 3 I2C bus interface, 2 input plus 2 outputs I2S bus interface, 4 general purpose timers, ultra-low power Real-Time Clock (RTC) with separate battery supply, and up to 70 general purpose I/O pins, 6-output general purpose PWM. The LPC1768/66/65/64 are pin-compatible with the 100-pin LPC236x ARM7-based Microcontroller series.

Setting up of Programming and debugging Environment:

First step in this process is to install Keil MDK (Microcontroller Development Kit).In the following series of tutorial we are going to use Keil µVision4 integrated with CooCox Debugger. You can download the Keil IDE from the below link.

Download

Step by Step installation guide is explained in this video.

In the following tutorials we will be using CoLinkEx ARM-JTAG Programmer which is USB programmer.

This Debugger is an open source you can also make one for you. It is very easy to use we have to do two things before starting.

  1. Install Drivers for the Debugger.

  2. Install Plugin for the Keil IDE.

Install the Driver of CoLinkEx:

You can download the driver from http://www.coocox.org/wiki/coocox/CoLinkEx/CoLinkEx-Support#Software.

Install the driver and then plug in the debugger to the computer USB and check whether it is working properly by seeing the Device manager of the Computer.

Installing Driver of CoLinkEx for Setting up Programming and debugging Environment in ARM

Fig. 1: Installing Driver of CoLinkEx for Setting up Programming and debugging Environment in ARM

Install the plugin and integrate with Keil MDK:

You can download the driver from http://www.coocox.org/book/coocox/stop-maintanance-product/MDKPlugin/MDKPlugin

Scroll down to the bottom and download the MDKPlugin.

Open the Setup file and install the Plugin in the Directory where Keil is installed.

Installing plugin and integrate with Keil MDK in ARM Cortex M3

Fig. 2: Installing Plugin and integrate with Keil MDK in ARM Cortex M3

Register Configuration (lpc17xx.h):

As LPC1768 is 32-bit architecture which is memory mapped to the location 0x2009 C000 to 0x2009 FFFF. Special Function registers of LPC1768 are defined in lpc17xx.h which can be included in the beginning of the project. Ports (PORT0 – PORT4) are available in LPC1768. Even though every PORT will not have 32 physical pins. A structure is defined in the System file LPC_GPIOn(n= 0,1,2,3) contains all the registers for required for GPIO operation. Refer lpc17xx.h file for more info on the registers.

PINSEL: GPIO Pins Select Register:

PINSEL register is to be configured before using the PIN since almost all the pins has a max of four functions. Below table explains the function for a particular pin using two bits of the PINSEL register.

Value

Function

Enumeration

00

Primary (default) function, typically GPIO port

PINSEL_FUNC_0

01

First alternate function

PINSEL_FUNC_1

10

Second alternate function

PINSEL_FUNC_2

11

Third alternate function

PINSEL_FUNC_3

Fig. 3: Bit Values of PINSEL Register to select GPIO in ARM Cortex M3

FIODIR:Fast GPIO Direction Control Register.
This register individually controls the direction of each port pin.

Values

Direction

0

Input

1

Output

Fig. 4: Bit Values of FIODIR Register to Control Direction in ARM Cortex M3

FIOSET:Fast Port Output Set Register.
This register controls the state of the output pins. Writing 1s produces highs at the corresponding port pins. Writing 0s has no effect. Reading this register returns the current contents of the port output register not the physical port value.

Values

FIOSET

0

No Effect

1

Sets High on Pin

Fig. 5: Bit Values of FIOSET Register to Control state of Pin in ARM Cortex M3

FIOCLR:Fast Port Output Clear Register.
This register controls the state of the output pins. Writing 1s produces lows at the corresponding port pins. Writing 0s has no effect.

Values

FIOCLR

0

No Effect

1

Sets Low on Pin

Fig. 6: Bit Values of FIOCLR Register to Control Output Pins in ARM Cortex M3

FIOPIN:Fast Port Pin Value Register.
This register is used for both reading and writing data from/to the PORT.
Output: Writing to this register places corresponding values in all bits of the particular PORT pins.
Input: The current state of digital port pins can be read from this register, regardless of pin direction or alternate function selection (as long as the pins are not configured as an input to ADC).
Note:It is recommended to configure the PORT direction and pin function before using it.

Create a project using Keil uvision4 for LPC1768 Microcontroller:

In this section, we will start creating a project in Keil MDK we have already installed Keil µVision and Co-MDK Plug-in + CoLinkEx Drivers required for the CoLinkEx programming adapter. Let’s get started to create a new µVision project to running LED by adding a simple delay between each LED connected to PORT 2 of LPC1768.

Here I am using third party board which consists of four on-board LEDs connected to PORT 2.

The first thing you have to do is download these files and put together in a folder.

code.rar

Open “Keil µVision4” default workplace and then go to “Project” –> “New µVision Project” and then browse to the folder you created and give it name as blink and hit on “save”.

Image showing Keil µVision4 default workplace to create project for LPC1768 Microcontroller

Fig. 7: Image Showing Keil µVision4 Default Workplace to Create Project for LPC1768 Microcontroller

Saving Project Name as Blink in Keil µVision4 for LPC1768 Microcontroller

Fig. 8: Saving Project Name as Blink in Keil µVision4 for LPC1768 Microcontroller

Popup window will show there we have to select “LPC1768” from NXP and then hit on “ok”

Selecting LPC1768 from device target window in Keil µVision4

Fig. 9: Selecting LPC1768 from Device Target Window in Keil µVision4

Now it ask you to copy “Startup_LPC1768xx.s” and hit on “Yes”

Image showing message on µVision4 window for copying LPC1768 to project Folder

Fig. 10: Image Showing message on µVision4 Window for Copying LPC1768 to Project Folder

Now right click on “Target 1” in the project pane and click on “Add Existing files to the project”

Selecting Exsisting File Blink from Source Group Window in KEIL to program LPC1768

Fig. 11: Image Showing Source Group Window to Add Files in KEIL uVision Software to program LPC1768

Image Showing Window to Select the Debugger Options to configure programming adapter CoLinkEx.

Fig. 12: Selecting Existing File Blink from Source Group Window in KEIL to program LPC1768

At this point we need to configure programming adapter CoLinkEx. So click on “Options for Target” on the menu bar and then go to “Debug” –> select “CooCox Debugger” from drop down menu.

Fig. 13: Image Showing Window to Select the Debugger Options to Configure Programming Adapter CoLinkEx.

then hit on Setting –> choose SYSRESETREQ from drop down menu –> hit on “Ok”

Selecting SYSRESETREQ from Debugger Options

Fig. 14: Selecting SYSRESETREQ from Debugger Options

Now go to “Utilities” –> uncheck “Use Debug Driver” and then choose “CooCox Debugger” from drop down menu.

Here again we have to go to “Setting” –> click on “Add” –> and choose “LPC17xx IAP 512kB Flash” from list and hit on “ok”

Hit on “Build” icon on main menu and once we build successfully without any error. Then simply hit on “Load”.

Now we can see that 4 LED connected to P2 is Running. In the next tutorial we would discuss about a program which includes some Input Function.

Code Description:

ARM programming requires good handling of Bit manipulation in C language. Here is the small note in the introduction of Bit manipulation to a newbie.

C has direct support for bitwise operations that can be used for bit manipulation. In the following examples, n is the index of the bit to be manipulated within the variable bit_fld, which is an unsigned char being used as a bit field. Bit indexing begins at 0, not 1. Bit 0 is the least significant bit.

Set a bit

bit_fld |= (1 << n)

Clear a bit

bit_fld &= ~(1 << n)

Toggle a bit

bit_fld ^= (1 << n)

Test a bit

bit_fld & (1 << n)

LPC_GPIO2->FIODIR = 0x000000FF; /* P2.xx defined as Outputs */

LPC_GPIO2->FIOCLR = 0x000000FF; /* turn off all the LEDs */

The above two lines is to SET the PORT 2 pins as output and clearing it. LPC_GPIO2 structure consists of FIODIR,FIOCLR and FIOSET members.

for(i = 0; i < 8; i++)

{

LPC_GPIO2->FIOSET = 1 << i;

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

}

The above for loop is used to set the bits of PORT 2 one by one using set a bit, which is mentioned above in the bit manipulation types.

You may also like:


  • What are the top 4G modems available in India?

  • What are different types of industrial robots?

  • How does LoRa modulation enable long-range communication?

  • What are the different types of EV charging connectors?

  • What is Wireless Electric Vehicle Charging System (WEVCS)?

  • What are the components of robotic arms and industrial robots?

Project Source Code

###
 
The codes are linked in Description ###

Project Components

  • LED
  • Resistor

Project Video


Filed Under: ARM, Electronic Projects

 

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.

Submit a Guest Post

submit a guest post

EE TECH TOOLBOX

“ee
Tech Toolbox: Power Efficiency
Discover proven strategies for power conversion, wide bandgap devices, and motor control — balancing performance, cost, and sustainability across industrial, automotive, and IoT systems.

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.

  • Help me understand comparators , AD8611 in particular
  • Methods for Calculating SNR and SFDR in a CUI for Use in Machine Learning
  • rechargeable battery and simple alkaline battery in one single product
  • Industrial Network Market Analysis and Introduction to Common Bus Protocols
  • Ensuring Reliable Backups in Azure

RSS Electro-Tech-Online.com Discussions

  • WTB: "The Theory Of Servicing AM, FM, And FM Receivers" by Clarence R. Green and Robert M. Bourque
  • Anyone In The US Ordered From AliExpress Recently?
  • Calculation of A Class amplifier
  • strange laptop problem
  • restarting this Christmas project

Featured Tutorials

Real Time Hardware Filter Design

  • Practical implementation of bandpass and band reject filters
    Practical implementation of bandpass and band reject filters
  • Practical application of hardware filters with real-life examples
    Practical application of hardware filters with real-life examples
  • A filter design example
    A filter design example
  • Types of filter responses
    Types of filter responses
  • What are the two types of hardware filters?
    What are the two types of hardware filters?
  • What are hardware filters and their types?
    What are hardware filters and their types?
More Tutorials >

Recent Articles

  • Stackpole introduces compact jumpers for high-current circuit routing
  • Ironwood Electronics launches near-device-footprint SMT elastomer socket for BGA264
  • Amphenol RF releases P67 FAKRA plugs for 6 GHz RF transmission
  • Microchip releases platform to deliver real-time specifications for AI assistants
  • GigaDevices introduces 32-bit MCUs with integrated DSP and FPU support

EE ENGINEERING TRAINING DAYS

engineering
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • 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
      • Sensor Series
      • 3D Printing
      • AI
      • ARDUINO Compatible Coding
      • Audio Electronics
      • Battery Management
      • Beginners Electronics Series
      • Brainwave
      • Digital electronics (DE)
      • Electric Vehicles
      • EMI/EMC/RFI
      • EVs
      • Hardware Filters
      • IoT tutorials
      • LoRa/LoRaWAN
      • Power Tutorials
      • Protocol
      • Python
      • RPI Python Programming
      • Sensors
      • USB
      • Thermal management
      • Verilog
      • 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
  • Guest Post Guidelines
  • Advertise
  • Subscribe