Features of 32-Bit Arm Cortex-M3 Lpc1768 Microcontroller: Embedded Controller Lab Manual (15ECL68)
Features of 32-Bit Arm Cortex-M3 Lpc1768 Microcontroller: Embedded Controller Lab Manual (15ECL68)
LPC1768 is an ARM Cortex-M3 based MCU by Phillips/NXP and has plenty of General Purpose
Input Output pins to play with. The Name of Registers, Data structures that I have used in this guide
are defined in LPC17xx.h header file. LPC17xx.h header is based on CMSIS(Cortex
Microcontroller System Interface Standard) developed by ARM.
Most of the function oriented pins on LPC176x Microcontrollers are grouped into Ports. LPC1768
has 5 ports viz. Port 0 to 4. The associated registers for each port are grouped into a structure with
the following naming convention : LPC_GPIOx , where x is the port number.
Register Configuration
As all the LPC1768 SFRs(Special Function Registers) are defined in lpc17xx.h, this has to be
included at the beginning of our project/code.
LPC1768 has its GPIOs divided into five ports PORT0 - PORT4, although many of them are not
physically 32bit wide. Refer the data sheet for more info. The Below registers will be used for
Configuring and using the GPIOs registers for sending and receiving the Digital signals.
A structure 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.
Values Direction
0 Input
1 Output
Values FIOCLR
0 No Effect
1 Sets Low on Pin
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 pins are not configured as an input to ADC).
Registers on LPC1768 are present on Peripheral AHB bus(Advanced High performance Bus) for
fast read/write timing. So, these are basically Fast I/O or Enhanced I/O and hence the naming
convention in datasheet uses a prefix of “FIO” instead of something like “GIO” for all the registers
related to GPIO. Let’s go through these as given below.
1) FIODIR : This is the GPIO direction control register. Setting a bit to 0 in this register will
configure the corresponding pin to be used as an Input while setting it to 1 will configure it as
Output.
2) FIOMASK : This gives masking mechanism for any pin i.e. it is used for Pin access control.
Setting a bit to 0 means that the corresponding pin will be affected by changes to other registers like
FIOPIN, FIOSET, FIOCLR. Writing a 1 means that the corresponding pin won’t be affected by
other registers.
3) FIOPIN : This register can be used to Read or Write values directly to the pins. Regardless
of the direction set for the particular pins it gives the current start of the GPIO pin when read.
4) FIOSET : It is used to drive an ‘output’ configured pin to Logic 1 i.e HIGH. Writing Zero
does NOT have any effect and hence it cannot be used to drive a pin to Logic 0 i.e LOW. For
driving pins LOW FIOCLR is used which is explained below.
5) FIOCLR : It is used to drive an ‘output’ configured pin to Logic 0 i.e LOW. Writing Zero
does NOT have any effect and hence it cannot be used to drive a pin to Logic 1.
Experiment No.1
DISPLAY “Hello World” MESSAGE USING INTERNAL UART
Date:
Pin Configuration:
UART module
UART module and registers. LPC1768 has 4-UARTs numbering 0-3, similarly the pins are also
named as RXD0-RXD3 and TXD0-TXD3.As the LPC1768 pins are multiplexed for multiple
functionalities, first they have to be configured as UART pins.
Below table shows the multiplexed UARTs pins.
UART Registers
The below table shows the registers associated with LPC1768 UART.
Register Description
LCR Controls the UART frame formatting(Number of Data Bits, Stop bits)
DLL Least Significant Byte of the UART baud rate generator value.
DLM Most Significant Byte of the UART baud rate generator value.
FCR
Bit 0 – FIFO:
This bit is used to enable/disable the FIFO for the data received/transmitted.
0--FIFO is Disabled.
1--FIFO is Enabled for both Rx and Tx.
Bit 1 – RX_FIFO:
This is used to clear the 16-byte Rx FIFO.
0--No impact.
1--CLears the 16-byte Rx FIFO and the resets the FIFO pointer.
Bit 2 – Tx_FIFO:
This is used to clear the 16-byte Tx FIFO.
0--No impact.
1--Clears the 16-byte Tx FIFO and the resets the FIFO pointer.
Bit 3 – DMA_MODE:
This is used for Enabling/Disabling DMA mode.
0--Disables the DMA.
1--Enables DMA only when the FIFO(bit-0) bit is SET.
LCR
Reserved DLAB Break COntrol Parity Select Parity Enable Stop Bit Select Word Length Select
LSR
31:8 7 6 5 4 3 2 1 0
TER
31:8 7 6-0
Baudrate Calculation
LPC1768 generates the baud rate depending on the values of DLM,DLL.
Baudrate = PCLK/ (16 * ( 256 * DLM + DLL) * (1+ DivAddVal/MulVal))
UART_PCLK PCLK
0 SystemFreq/4
1 SystemFreq
2 SystemFreq/2
3 SystemFreq/8
DivAddVal/MulVal == 0
1. Step1: Configure the GPIO pin for UART0 function using PINSEL register.
2. Step2: Configure the FCR for enabling the FIXO and Reste both the Rx/Tx FIFO.
3. Step3: Configure LCR for 8-data bits, 1 Stop bit, Disable Parity and Enable DLAB.
4. Step4: Get the PCLK from PCLKSELx register 7-6 bits.
5. Step5: Calculate the DLM,DLL vaues for required baudrate from PCLK.
6. Step6: Updtae the DLM,DLL with the calculated values.
7. Step6: Finally clear DLAB to disable the access to DLM,DLL.
After this the UART will be ready to Transmit/Receive Data at the specified baudrate.
Output:
Connect the LPC1768 microcontroller kit and dump the program using FLASHMAGIC
software. Now in FLASHMAGIC software goto TOOLS TERMINALOK. Now press
RESET in LPC1768 kit.
Experiment No.2
Interface and Control of a DC Motor
Date:
Aim: to write a embedded C program to control the speed of DC motor and change the direction of the
motor using ARM Cortex-M3 LPC1768 microcontroller.
Embedded C code:
#include <lpc17xx.h>
void delay(unsigned int d)
{
unsigned int i,j; for(i=0;i<d;i++) for(j=0;j<500;j++);
}
int main(void)
{
int dc;
LPC_PINCON->PINSEL4 = 0x41;
LPC_PWM1->MR0 = 4000;
LPC_PWM1->MCR = 2;
LPC_PWM1->PCR = (1<<9)|(1<<12);
//or =0x1200
LPC_PWM1->TCR = 2;
LPC_PWM1->TCR = 9;
while(1)
{
for(dc=0; dc<4000; dc++)
{
LPC_PWM1->MR1 = dc;
LPC_PWM1->MR4 = 0;
LPC_PWM1->LER = 0x31;
delay(5);
}
for(dc=0; dc<4000; dc++)
{
LPC_PWM1->MR4 =dc;
LPC_PWM1->MR1 = 0;
LPC_PWM1->LER = 0x31;
delay(5);
}
}
}
Pin Configuration:
Experiment No.3
Interface and Controlling direction of a Stepper Motor
Date:
Aim: to write a embedded C program to Interface stepper motor and program to rotate it in clockwise
and anti-clockwise directions using ARM Cortex-M3 LPC1768 microcontroller..
Embedded C code:
#include <lpc17xx.h>
void delay(unsigned int t)
while(1)
{
for(i=0;i<50;i++)
for (j=0;j<=3;j++)
{
LPC_GPIO2->FIOPIN = a[j];
delay(1);
}
for(i=0;i<50;i++)
for (j=3;j>=0;j--)
{
LPC_GPIO2->FIOPIN = a[j];
delay(1);
}
}
}
Pin Configuration:
Experiment No.4A
Interface a DAC and Generate Square Waveform
Date:
Aim: to write a Embedded C program to configure an internal DAC to produce triangular waveform on
CRO using ARM Cortex-M3 LPC1768 microcontroller.
Embedded C code:
#include <lpc17xx.h>
void delay(unsigned int d)
{
unsigned int i,j; for(i=0;i<d;i++) for(j=0;j<100;j++);
}
int main(void)
{
LPC_PINCON->PINSEL1 = (1<<21);
while(1)
{
LPC_DAC->DACR = 1023<<6;
delay(1);
LPC_DAC->DACR = 0<<6;
delay(1);
}
}
Pin Configuration:
Circuit Diagram
LPC1768
FRC-5
P0.26
CRO
AOUT
Experiment No.4B
Interface a DAC and Generate Triangular Waveform
Date:
Aim: to write a Embedded C program to configure an internal DAC to produce square waveform on CRO
using ARM Cortex-M3 LPC1768 microcontroller.
Embedded C code:
#include <lpc17xx.h>
int main(void)
{
unsigned int j=0;
LPC_PINCON->PINSEL1 = (1<<21);
while(1)
{
for (j=0;j<1023;j++)
LPC_DAC->DACR = j<<6;
for (j=1023;j>0;j--)
LPC_DAC->DACR = j<<6;
}
}
Pin Configuration:
Experiment No. 5A
Program to Configure LCD Display
Date:
Aim: to write a Embedded C program to display digital output on LCD for a given analog input using
internal ADC of ARM Cortex-M3 LPC1768 microcontroller.
Embedded C code:
#include<lpc17xx.h>
void delay(unsigned int d);
void lcdcmd(unsigned int cmd);
void lcddata(unsigned int value);
void lcdstr(unsigned char addr,char *msg);
void convert(unsigned int adc);
int main()
{
unsigned int adc=0,t=1;
LPC_GPIO1->FIODIR=0x03FF8000;
lcdcmd(0x38);
lcdcmd(0x0C);
lcdcmd(0x01);
lcdcmd(0x06);
lcdstr(0x80,"ADC TEST");
lcdstr(0xc0,"ADC Value=");
LPC_SC->PCONP|=(1<<12);
LPC_ADC->ADCR=(1<<21)|(10<<8);
LPC_PINCON->PINSEL1=(1<<18);
while(1)
{
LPC_ADC->ADCR|=4;
delay(10);
LPC_ADC->ADCR|=(1<<24);
while(LPC_ADC->ADDR2&(t<<31)==0);
adc=((LPC_ADC->ADDR2>>4)&0XFFF);
adc=(adc*(3.901/4096)*10);
convert(adc);
}
}
void convert(unsigned int adc)
{ lcdcmd(0xCB);
lcddata((adc/10)|0x30);
lcddata('.');
lcddata((adc%10)|0x30);
lcddata('V');
}
void delay(unsigned int d)
{
unsigned int i,j;
for(i=0;i<d;i++)
for(j=0;j<1200;j++);
}
void lcdcmd(unsigned int cmd)
{
cmd=cmd<<18;
LPC_GPIO1->FIOPIN=(1<<17)|(cmd);
delay(5);
LPC_GPIO1->FIOPIN=(0<<17)|(cmd);
}
void lcdstr(unsigned char addr,char *msg)
{
lcdcmd(addr);
while(*msg!=0)
lcddata(*msg++);
}
void lcddata(unsigned int value)
{
value=value<<18;
LPC_GPIO1->FIOPIN=(1<<15)|(1<<17)|value;
delay(5);
LPC_GPIO1->FIOPIN=(1<<15)|(0<<17)|value;
}
Pin Configuration:
Output:
Connect ADC module to FRC-5
Connect LCD module to FRC-2
Experiment No. 5B
Interface a Keyboard and Display Key on an LCD
Date:
Aim: to write a Embedded C program to Interface a 4x4 keyboard and to display the key code on LCD
using ARM Cortex-M3 LPC1768 microcontroller.
Embedded C code:
#include <lpc17xx.h>
void delay(unsigned int d);
void lcdstr(unsigned char addr,char *msg);
void lcddata(unsigned int value);
void lcdcmd(unsigned int cmd); char scan(int key);
int main()
{
LPC_GPIO1->FIODIR = 0x03FF8000;
lcdcmd(0x38); lcdcmd(0x0C);
lcdcmd(0x01);
lcdcmd(0x06);
lcdstr(0x80,"4x4 Key Pad Test");
lcdstr(0xC0,"Key Pressed= ");
LPC_GPIO0->FIODIR = 0xFC3;
while(1)
{
LPC_GPIO0->FIOCLR = 0x3C0;
LPC_GPIO0->FIOSET = 0x380;
delay(50);
if(scan(0x038))lcdstr(0xCD,"0");
if(scan(0x034))lcdstr(0xCD,"4");
if(scan(0x02C))lcdstr(0xCD,"8");
if(scan(0x01C))lcdstr(0xCD,"C");
LPC_GPIO0->FIOCLR = 0x3C0;
LPC_GPIO0->FIOSET = 0x340;
if(scan(0x038))lcdstr(0xCD,"1");
if(scan(0x034))lcdstr(0xCD,"5");
if(scan(0x02C))lcdstr(0xCD,"9");
if(scan(0x01C))lcdstr(0xCD,"D");
LPC_GPIO0->FIOCLR = 0x3C0;
LPC_GPIO0->FIOSET = 0x2C0;
if(scan(0x038))lcdstr(0xCD,"2");
if(scan(0x034))lcdstr(0xCD,"6");
if(scan(0x02C))lcdstr(0xCD,"A");
if(scan(0x01C))lcdstr(0xCD,"E");
LPC_GPIO0->FIOCLR = 0x3C0;
LPC_GPIO0->FIOSET = 0x1C0;
if(scan(0x038))lcdstr(0xCD,"3");
if(scan(0x034))lcdstr(0xCD,"7");
if(scan(0x02C))lcdstr(0xCD,"B");
if(scan(0x01C))lcdstr(0xCD,"F");
}
}
void delay(unsigned int d)
{
unsigned int i,j;
for(i=0;i<d;i++)
for(j=1;j<1200;j++);
}
void lcddata(unsigned int VALUE)
{
VALUE = VALUE<<18;
LPC_GPIO1->FIOPIN = (1<<15)|(1<<17)|VALUE;
delay(5);
LPC_GPIO1->FIOPIN = (1<<15)|(0<<17)|VALUE;;
}
void lcdcmd(unsigned int cmd)
{
cmd = cmd<<18;
LPC_GPIO1->FIOPIN = ((1<<17)|cmd);
delay(5);
LPC_GPIO1->FIOPIN = ((0<<17)|cmd);
}
void lcdstr(unsigned char addr,char *msg)
{
lcdcmd(addr); while(*msg!=0) lcddata(*msg++);
}
char scan(int key)
{
while((LPC_GPIO0->FIOPIN & 0x03C)==key)
{
delay(50);
if((LPC_GPIO0->FIOPIN & 0x03C)== 0x03C)return(1);
}
return(0) ;}
Pin Configuration:
Experiment No.6
Generation of PWM
Date:
Aim: to write a Embedded C program to configure an internal PWM module to generate PWM wave and
to vary its duty cycle on CRO using ARM Cortex-M3 LPC1768 microcontroller.
Embedded C code:
#include <lpc17xx.h>
void delay(unsigned int d)
{
unsigned int i,j; for(i=0;i<d;i++) for(j=0;j<500;j++);
}
int main(void)
{
int dc;
LPC_PINCON->PINSEL4 = 1;
LPC_PWM1->MR0 = 10000;
LPC_PWM1->MCR = 2;
LPC_PWM1->PCR = (1<<9); //or 0x200
LPC_PWM1->TCR = 2;
LPC_PWM1->TCR = 9;
while(1)
{
for(dc=0; dc<10000; dc++)
{
LPC_PWM1->MR1 = dc;
LPC_PWM1->LER =3;
delay(5);
}
for(dc=10000; dc>0; dc--)
{
LPC_PWM1->MR1 =dc;
LPC_PWM1->LER =3;
delay(5);
}
}
}
Pin Configuration:
Output: Connect PWM module to FRC-1 and waveform will be displayed on CRO.
Experiment No.7
Demonstration of external interrupt to toggle LED
Date:
Aim: to write a Embedded C program to demonstrate the use of an external interrupt to toggle an LED
On/Off using ARM Cortex-M3 LPC1768 microcontroller.
Embedded C code:
#include <lpc17xx.h>
void EINT0_IRQHandler(void)
{
LPC_SC->EXTINT = 1; LPC_GPIO0->FIOPIN ^= 0x20;
}
int main()
{
LPC_PINCON->PINSEL4 = (1<<20); //or 0x00100000;
LPC_SC->EXTINT = 1;
LPC_SC->EXTMODE = 1;
LPC_SC->EXTPOLAR = 0;
LPC_GPIO0->FIODIR = 0x20;
NVIC_EnableIRQ(EINT0_IRQn);
while(1);
}
EINTx Pins
LPC1768 has four external interrupts EINT0-EINT3. As LPC1768 pins are multi functional, these four
interrupts are available on multiple pins.
Pin Configuration:
Experiment No.8
To Display Hex Digits on Seven Segment Interface
Date:
Aim: to write a Embedded C program on an 7-Seven segment LED interface to display the hex digits 0 to
F with an appropriate delay using ARM Cortex-M3 LPC1768 microcontroller.
Embedded C code:
#include<lpc17xx.h>
void display(unsigned char value);
void delay(unsigned int d);
unsigned char
data[16]={0xc0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8, 0x80,0x90,0x88,0x83,0xC6,0xA1,0x86,0x8E};
int main()
{
unsigned char i,j; LPC_GPIO2->FIODIR=7; while(1)
{
for(i=0; i<16; i++)
{
for(j=0;j<6;j++) display(data[i]); delay(50);
}
}
}
void display(unsigned char value)
{
unsigned char m;
for(m=0; m<8;m++)
{
if(value&0x80)
LPC_GPIO2->FIOSET=2;
else
LPC_GPIO2->FIOCLR=2;
LPC_GPIO2->FIOSET=1;
LPC_GPIO2->FIOCLR=1;
value<<=1;
}
LPC_GPIO2->FIOSET=4;
LPC_GPIO2->FIOCLR=4;
}
void delay(unsigned int d)
{
unsigned int i,j;
for(i=0;i<d;i++)
for(j=0;j<10000;j++);
}
7-segment Display
The 7-segment display, also written as “seven segment display”, consists of seven LEDs
(hence its name) arranged in a rectangular fashion as shown. Each of the seven LEDs is called a
segment because when illuminated the segment forms part of a numerical digit (both Decimal and Hex)
to be displayed. An additional 8th LED is sometimes used within the same package thus allowing the
indication of a decimal point, (DP) when two or more 7-segment displays are connected together to
display numbers greater than ten.
Each one of the seven LEDs in the display is given a positional segment with one of its connection pins
being brought straight out of the rectangular plastic package. These individually LED pins are labelled
from a through to g representing each individual LED. The other LED pins are connected together and
wired to form a common pin
So by forward biasing the appropriate pins of the LED segments in a particular order, some segments
will be light and others will be dark allowing the desired character pattern of the number to be
generated on the display. This then allows us to display each of the ten decimal digits 0 through to 9 on
the same 7-segment display.
The displays common pin is generally used to identify which type of 7-segment display it is. As each
LED has two connecting pins, one called the “Anode” and the other called the
“Cathode”, there are therefore two types of LED 7-segment display called: Common Cathode
(CC) and Common Anode (CA)
The difference between the two displays, as their name suggests, is that the common cathode has all the
cathodes of the 7-segments connected directly together and the common anode has all the anodes of the
7-segments connected together and is illuminated as follows.
The Common Cathode (CC) – In the common cathode display, all the cathode connections of the
LED segments are joined together to logic “0” or ground. The individual
segments are illuminated by application of a “HIGH”, or logic “1” signal via a
current limiting resistor to forward bias the individual Anode terminals (a-h).
Common Cathode 7-segment Display
The Common Anode (CA) – In the common anode display, all the anode connections of the LED
segments are joined together to logic “1”. The individual segments are
illuminated by applying a ground, logic “0” or “LOW” signal via a suitable
current limiting resistor to the Cathode of the particular segment (a-g).
Common Anode 7-segment Display
In general, common anode displays are more popular as many logic circuits can sink more current than
they can source. Also note that a common cathode display is not a direct replacement in a circuit for a
common anode display and vice versa, as it is the same as connecting the LEDs in reverse, and hence
light emission will not take place.
Depending upon the decimal digit to be displayed, the particular set of LEDs is forward biased. For
instance, to display the numerical digit 0, we will need to light up six of the LED segments
corresponding to a, b, c, d, e and f. Thus the various digits from 0 through 9 can be displayed using a
Then for a 7-segment display, we can produce a truth table giving the individual segments that need to
be illuminated in order to produce the required decimal digit from 0 through F as shown below.
Digit h g f e d c b a
0 1 1 0 0 0 0 0 0
1 1 1 1 1 1 0 0 1
2 1 0 1 0 0 1 0 0
3 1 0 1 1 0 0 0 0
4 1 0 0 1 1 0 0 1
5 1 0 0 1 0 0 1 0
6 1 0 0 0 0 0 1 0
7 1 1 1 1 1 0 0 0
8 1 0 0 0 0 0 0 0
9 1 0 0 1 0 0 0 0
A 1 0 0 0 1 0 0 0
B 1 0 0 0 0 0 1 1
C 1 1 0 0 0 1 1 0
D 1 0 1 0 0 0 0 1
E 1 0 0 0 0 1 1 0
F 1 0 0 0 1 1 1 0
Pin Configuration:
Experiment No.9
Interface of Simple Switch
Date:
Aim: to write a Embedded C programto . Interface a simple Switch to display its status
through Relay, Buzzer and LED using ARM Cortex-M3 LPC1768 microcontroller.
Embedded C code:
#include <lpc17xx.h>
int main()
{
LPC_GPIO2->FIODIR = 0x30;
LPC_GPIO2->FIOPIN = 0x10;
while(1)
{
while((LPC_GPIO2->FIOPIN & 4)!=4)
LPC_GPIO2->FIOPIN= 0x20;
LPC_GPIO2->FIOPIN= 0x10;
}
}
Output: Connect RELAY module to FRC-1.
Pin Configuration:
Experiment No.10
Interface Temperature Sensor
Date:
Aim: to write a Embedded C program to interface temperature sensor and SPI ADC IC to
measure the ambient temperature LED using ARM Cortex-M3 LPC1768 microcontroller.
Embedded C code:
#include <lpc17xx.h>
void delay(unsigned int d);
void lcdstr(unsigned char addr,char *msg);
void lcddata(unsigned int value);
void lcdcmd(unsigned int cmd);
void convert(unsigned int adc);
unsigned int temperature(void);
unsigned int adc=0,temp=0;
int main()
{
LPC_GPIO1->FIODIR = 0x03FF8000;
lcdcmd(0x38);
lcdcmd(0x0C);
lcdcmd(0x01);
lcdcmd(0x06);
lcdstr(0x80," AMBIENT ROOM ");
lcdstr(0xC0," TEMPe: ");
LPC_GPIO0->FIODIR = 0xFC;
LPC_GPIO0->FIOPIN = 0x00;
while(1)
{
adc=temperature();
adc = (1000*(adc*(5.0/4096)))-100;
convert(adc);
}
}
unsigned int temperature()
{
unsigned char cnt=0; LPC_GPIO0->FIOSET |= 0xC0; LPC_GPIO0->FIOCLR |=
0x40; for(cnt=0;cnt<15;cnt++)
{
LPC_GPIO0->FIOCLR |= 0x80;
temp = LPC_GPIO0->FIOPIN;
if(temp & 0x100) adc=adc|1;
else adc=adc & 0xFFE; if(cnt<14) adc<<=1;
LPC_GPIO0->FIOSET |= 0x80;
}
LPC_GPIO0->FIOSET |= 0x40;
LPC_GPIO0->FIOCLR |= 0x80;
adc=adc & 0xFFF;
return(adc);
}
void delay(unsigned int d)
{
unsigned int i,j;
for(i=0;i<d;i++)
for(j=1;j<1200;j++);
}
void lcddata(unsigned int value)
{
value = value<<18;
LPC_GPIO1->FIOPIN = ((1<<15)|(1<<17)|value);
delay(5);
LPC_GPIO1->FIOPIN = ((1<<15)|(0<<17)|value);
}
void lcdcmd(unsigned int cmd)
{
cmd = cmd<<18;
LPC_GPIO1->FIOPIN = ((1<<17)|cmd);
delay(5);
LPC_GPIO1->FIOPIN = ((0<<17)|cmd);
}
void lcdstr(unsigned char addr,char *msg)
{
lcdcmd(addr);
while(*msg!=0)
lcddata(*msg++);
}
void convert(unsigned int adc)
{
lcdcmd(0xC8);
lcddata((adc/100)|48);
lcddata(((adc/10)%10)|48);
lcddata('.');
lcddata((adc % 10)|48);
lcddata(223);
lcddata('C');
}
Output: Connect PWM/Temperature Sensor module to FRC-4, LCD to FRC-2
Pin Configuration:
First open the icon keil µvision4 on Windows desktop and the following steps are give
below.
The menu bar provides you with menus for editor operations, project
maintenance, development tool option settings, program debugging, external
tool control, window selection and manipulation, and on-line help.
The toolbar buttons allow you to rapidly execute µVision4 commands. A Status
Bar provides editor and debugger information.
The various toolbars and the status bar can be enabled or disabled from the
View Menu commands.
Creating a Project
This will explains the steps required to setup a simple application and to generate
HEX output.
STEP 2: Go to the “Project” menu and click on “New Micro vision Project”
STEP 3: Here we can see a small window as “Create New Project” and here we can
select our destination to wherever we want.
STEP 4: Open one drive and create a “New Folder” and to give any name related to
the Project.
STEP 5: Again we can see a small window as “Select Device for Target ‘Target 1’”,
here select NXP founded by Philips.
STEP 7: If we want to add Startup file we can click “Yes” or else click on “No”.
STEP 9: These are the main three windows in the keil IDE. One is Project Workspace,
second is Editor Window and third is Output Window.
STEP 10: In editor window we can start to write our program and after editing we
have to save.
STEP 11: Save the file, if the program is in “C” save as “filename.C” or else if it is in
ASM save as “filename.ASM”.
STEP 12: Next add this source file to Group1, for that go to “Project Workspace” drag
the “Target 1” in that right click on “Source Group1” and click on “Add Files to
Group “Source Group1””.
STEP 13: Here one small window will open as “Add Files to Group “Source Group1”,
default the Files of type will be in C source Files (*.C). If our program is in C we need
to select C source Files (*.C) or select ASM Source file (*.s,*.src,*.a*).
STEP 14: Then go to “Project” click on “Build Target” or F7. There we can see errors
and warning in Output Window.
Keil Simulation
For access internal memory type i:0x_memory location example: i:0x30 and
For external and program memory x:0x_memory location, c:0x_memory
location respectively.
From Register window we can edit and access the values also.
STEP 16: Follow the STEP up to 16 and go to “Project” and click on “Option for
Group ‘Source Group1’”. There we can see one window as “Option for Target
‘Target1’”. In that window, within the Device menu we need to select LPC1768 and
click ok.
STEP 17: Next within the Target menu we need to set clock frequency as 25.0 MHz
STEP 18: Then go to Output click on create HEX file and click ok.
STEP 19: Then go to “Project” click on “Rebuild all target files”. There we can see
errors and warning in Output Window.
STEP 20: For programming with communication port first we need to select the
following:
STEP 22: Under the Advanced options go to Hardware configuration click on the
Assert DTR and RTS while COM port open and click ok.
STEP 23: Next browse the file and select the path.
STEP 24: After selecting ISP mode and reset at the kit and click on start.
STEP 25: After the above steps we can see the finished indication.