Professional Documents
Culture Documents
final embedded systems design and arm processor manual
final embedded systems design and arm processor manual
FACULTY IN-CHARGE
Mrs. Usha Rani M A (Assistant Professor )
Dept. of ETE.
2023 – 24
Sl.no Experiments no
1 ALP to calculate 10+9+8+7+………+1
2 ALP to store data in RAM
3 ALP to find squares of first 5 natural numbers and
Assembly
store data in RAM
4 ALP to find 2’s compliment of a number and language
store data in RAM
5 ALP to solve the given polynomial function
Sl.no Experiments no
6 To display ‘hello world’ by UART protocol
7 To interface of 8 LEDs with LPC1768
8 To interface relay with LPC1768
9 To read on chip DAC values ,generate triangular, Embedded
& square waves
10 To interface a 4*4 keyboard & display key
C-language
pressed
I.INTRODUCTION
Steps to be followed for keli uvision 4:-
Step 1:- create a new uvision file and give a suitable name and save
it with the file extension as .uvproj.
Step 5:- after typing the program save as .asm for assembly level
programs and .c for the embedded c programs.
Step 6:- add a .asm /.c files which was created to the target1 by right
clicking >add files to exiting file> add .c /.asm file to it.
Step 9:- after adding all the files. Build a target and after getting 0
errors, debug it.
After debugging we will get registers, call stack+locals , command
window etc…,
I.INTRODUCTION
The LPC-1768 operate at CPU frequencies of up to 100 MHz. The LPC1768 operates at
CPU frequencies of up to 120 MHz. The ARM Cortex-M3 CPU incorporates a 3-stage
pipeline and uses a Harvard architecture with separate local instruction and data buses
as well as a third bus for peripherals. The ARM Cortex-M3CPU also includes an internal
prefetch unit that supports speculative branching.
accelerator enables high-speed 120 MHz operation with zero wait states.
In-System Programming (ISP) and In-Application Programming (IAP) via on-chip
boot loader software.
Serial interfaces:
➢ Ethernet MAC with RMII interface and dedicated DMA controller. USB 2.0 full-speed
device/Host/OTG controller with dedicated DMA controller and on-chip PHY for
device, Host, and OTG functions.
➢ Four UARTs with fractional baud rate generation, internal FIFO, and DMA support.
➢ One UART has modem control I/O and RS-485/EIA-485 support, and one UART has
IrDA support.
➢ CAN 2.0B controller with two channels.
➢ SPI controller with synchronous, serial, full duplex communication and programmable
data length.
➢ Two SSP controllers with FIFO and multi-protocol capabilities. The SSP interfaces can
be
used with the GPDMA controller.
➢ Three enhanced I2C bus interfaces, one with an open-drain output supporting full I2C
specification and Fast mode plus with data rates of 1 Mbit/s, two with standard port
pins. Enhancements include multiple address recognition and monitor mode.
➢ I2S (Inter-IC Sound) interface for digital audio input or output, with fractional rate
control. The I2S-bus interface can be used with the GPDMA. The I2S-bus
interface Supports 3-wire and 4-wire data transmit and receive as well as master clock
input/output.
Other peripherals:
➢ 70 (100 pin package) General Purpose I/O (GPIO) pins with configurable pull-up/down
resistors. All GPIOs support a new, configurable open-drain operating mode. The GPIO
block is accessed through the AHB multilayer bus for fast access and located in memory
such
➢ that it supports Cortex-M3 bit banding and use by the General Purpose DMA Controller.
➢ 12-bit Analog-to-Digital Converter (ADC) with input multiplexing among eight pins,
conversion rates up to 200 kHz, and multiple result registers. The 12-bit ADC can be
used with the GPDMA controller.
➢ 10-bit Digital-to-Analog Converter (DAC) with dedicated conversion timer and DMA
support.
➢ Four general purpose timers/counters, with a total of eight capture inputs and ten
compare outputs. Each timer block has an external count input. Specific timer events
can be selected to generate DMA requests.
➢ One motor control PWM with support for three-phase motor control
➢ Quadrature encoder interface that can monitor one external quadrature encoder.
➢ One standard PWM/timer block with external count input.
➢ RTC with a separate power domain and dedicated RTC oscillator. The RTC block
includes 20 bytes of battery-powered backup registers.
➢ WatchDog Timer (WDT). The WDT can be clocked from the internal RC
oscillator, the RTC oscillator, or the APB clock.
➢ ARM Cortex-M3 system tick timer, including an external clock input option.
➢ Repetitive interrupt timer provides programmable and repeating timed interrupts.
➢ Each peripheral has its own clock divider for further power savings.
➢ Standard JTAG test/debug interface for compatibility with existing tools. Serial Wire
Debug and Serial Wire Trace Port options.
➢ Emulation trace module enables non-intrusive, high-speed real-time tracing of
instruction execution.
➢ Integrated PMU (Power Management Unit) automatically adjusts internal regulators to
minimize power consumption during Sleep, Deep sleep, Power-down, and Deep power-
down modes.
➢ Four reduced power modes: Sleep, Deep-sleep, Power-down, and Deep power-down.
➢ Single 3.3 V power supply (2.4 V to 3.6 V).
➢ Four external interrupt inputs configurable as edge/level sensitive. All pins on Port
0 and Port 2 can be used as edge sensitive interrupt sources.
➢ Non-maskable Interrupt (NMI) input.
➢ Clock output function that can reflect the main oscillator clock, IRC clock, RTC
clock,
CPU clock, and the USB clock.
➢ The Wake-up Interrupt Controller (WIC) allows the CPU to automatically wake up
from any priority interrupt that can occur while the clocks are stopped in deep sleep,
Power-down,
➢ and Deep power-down modes.
➢ Processor wake-up from Power-down mode via any interrupt able to operate during
Power down mode (includes external interrupts, RTC interrupt, USB activity, Ethernet
wake-up interrupt, CAN bus activity, Port 0/2 pin interrupt, and NMI).
➢ Brownout detect with separate threshold for interrupt and forced reset.
➢ Power-On Reset (POR).
➢ Crystal oscillator with an operating range of 1 MHz to 25 MHz.
➢4 MHz internal RC oscillator trimmed to 1 % accuracy that can optionally be used as
a system clock.
➢ PLL allows CPU operation up to the maximum CPU rate without the need for a high
frequency crystal. May be run from the main oscillator, the internal RC oscillator, or the
RTC oscillator.
➢ USB PLL for added flexibility.
➢ Code Read Protection (CRP) with different security levels.
➢ Unique device serial number for identification purposes.
➢ Available as LQFP100 (14 mm x 14 mm x 1.4 mm), TFBGA1001 (9 mm x 9 mm x
0.7 mm), and WLCSP100 (5.074 x 5.074 x 0.6 mm) package.
ASSEMBLY
PROGRAMS
PROGRAM 1A
PRESERVE8
THUMB
AREA RESET, DATA, READONLY
EXPORT __Vectors
__Vectors
DCD 0x20001000
DCD Reset_Handler
ALIGN
AREA MYCODE, CODE, READONLY
ENTRY
EXPORT Reset_Handler
Reset_Handler
MOV R1, #0x0A
MOV R2, #0X00
LOOP1 ADD R2, R1
SUBS R1, #0X01
BNE LOOP1
HERE B HERE
END
Expected Output:
Before Execution: After Execution:
PRESERVE8
THUMB
AREA RESET,DATA,READONLY
EXPORT __Vectors
__Vectors
DCD 0x20001000
DCD Reset_Handler
ALIGN
AREA MYCODE,CODE,READONLY
ENTRY
EXPORT Reset_Handler
Reset_Handler
MOV R1,#0X10000000
MOV R0,#0X501
STR R0,[R1]
ADD R1,R1,#4
MOV R0,R0,LSL#1
STR R0,[R1]
ADD R1,R1,#4
MOV R0,R0,LSL#1
STR R0,[R1]
ADD R1,R1,#4
MOV R0,R0,LSL#1
STR R0,[R1]
here B here
END
Expected Output:
before execution :-
After execution :-
Program 3:- write an assembly language program to find squares of first 5 natural
numbers and store data in RAM
PRESERVE8
THUMB
AREA RESET,DATA,READONLY
EXPORT __Vectors
__Vectors
DCD 0x20001000
DCD Reset_Handler
ALIGN
AREA MYCODE,CODE,READONLY
ENTRY
EXPORT Reset_Handler
Reset_Handler
MOV R0,#0X00
MOV R1,#0X05
MOV R2,#0X01
MOV R3,#0X10000000
before execution :-
After execution :-
Program 4:-write an assembly language program to find 2’s compliment of a
given number and store data in RAM
PRESERVE8
THUMB
AREA RESET,DATA,READONLY
EXPORT __Vectors
__Vectors
DCD 0x20001000
DCD Reset_Handler
ALIGN
AREA MYCODE,CODE,READONLY
ENTRY
EXPORT Reset_Handler
Reset_Handler
MOV R0,#0X10000000
MOV R1,#0X055
EOR R1,#0XFFFFFFFF
ADD R1,R1,#1
STR R1,[R0],1
here B here
END
Expected Output:
before execution :-
After execution :-
Program 5:-write an assembly language program to solve the given polynomial
function
PRESERVE8
THUMB
AREA RESET,DATA,READONLY
EXPORT __Vectors
Vectors
DCD 0x20001000
DCD Reset_Handler
ALIGN
AREA MYCODE,CODE,READONLY
ENTRY
EXPORT Reset_Handler
Reset_Handler
MOV R0,#7
MUL R1,R0,R0
MOV R4,#5
MUL R1,R1,R4
MOV R5,#6
MUL R2,R0,R5
SUB R3,R1,R2
ADD R3,R3,#8
here B here
END
Expected Output:
before execution :-
After execution :-
Embedded
C-language
1.Write a C-Program to display “Hello world” by using UART Serial
Communication Protocol
Steps for Configuring UART0:
Step1: Configure the GPIO pin for UART0 function using PINSEL register. Step2:
Configure the FCR for enabling the FIXO and Reset both the Rx/Tx FIFO.
Step3: Configure LCR for 8-data bits, 1 Stop bit, Disable Parity and Enable DLAB.
Step4: Get the PCLK from PCLKSELx register 7-6 bits.
Step5: Calculate the DLM,DLL values for required baudrate from PCLK.
Step6: Update the DLM,DLL with the calculated values.
Step7: 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.
Register Description
#include "LPC17xx.h"
#define FOSC 12000000 /* oscillator frequency */
#define FCCLK (FOSC * 8) /* master clock frequency <= 100Mhz */
#define FCCO (FCCLK * 3) /* PLL frequency (275Mhz to 550Mhz)
*/
#define FPCLK (FCCLK / 4) /* peripheral clock frequency */
#define UART0_BPS 9600 /* Serial communication baud rate 9600
*/
void UART0_Init (void)
{
unsigned int usFdiv;
LPC_PINCON->PINSEL0 |= (1 << 4); /* Pin P0.2 used as TXD0
(Com0) */
LPC_PINCON->PINSEL0 |= (1 << 6); /* Pin P0.3 used as RXD0
(Com0) */
LPC_UART0->LCR = 0x83; /* allows you to set the baud rate */
usFdiv = (FPCLK / 16) / UART0_BPS; /* set the baud rate*/
LPC_UART0->DLM = usFdiv / 256;
LPC_UART0->DLL = usFdiv % 256;
LPC_UART0->LCR = 0x03; /* Lock the baud rate*/
LPC_UART0->FCR = 0x06;
}
int UART0_SendByte (int ucData)
{
while (!(LPC_UART0->LSR & 0x20));
return (LPC_UART0->THR = ucData);
}
void UART0_SendString (unsigned char *s)
{
while (*s != 0)
UART0_SendByte(*s++);
}
int main(void)
{
UART0_Init();
UART0_SendString("HELLO WORLD !!!");
UART0_SendByte(0x0D); UART0_SendByte(0x0A); //CR LF
}
Result :-
2. Write a C-Program to interface 8 LEDs with LPC1768 to BLINK in
given Pattern
#include <lpc17xx.h>
void delay()
{
int i,j;
for(i=0;i<0x4000;i++)
for(j=0;j<0x400;j++);
}
int main (void)
{
LPC_GPIO0->FIODIR = 0x0000FF0; /* P2.xx defined as Outputs */
LPC_GPIO0->FIOCLR = 0x0000FF0; /* turn off all the LEDs */
while(1)
{
LPC_GPIO0->FIOSET = 0x0000FF0;
delay();
LPC_GPIO0->FIOCLR = 0x0000FF0;
delay();
}
}
Expected output:-
#include <lpc17xx.h>
void delay()
{
int i,j;
for(i=0;i<0x2000;i++)
for(j=0;j<0x200;j++);
}
int main (void)
{
LPC_PINCON->PINSEL7 = 0X02000000;
LPC_GPIO0->FIODIR = 0X02000000;
LPC_GPIO0->FIOCLR =0X02000000;
while(1)
{
LPC_GPIO0->FIOSET =0X02000000;
delay();
LPC_GPIO0->FIOCLR = 0X02000000;
delay();
}
}
Expected output:-
Relay on/closed state:-
As this board comes with one DAC output for generation different wave forms. AOUT
(P0.26) is connected to TEST point TP1. The generated waveforms can be viewed through
TP1 (DAC) and TP2 (GND) by connecting CRO.
Program:-
#include <LPC17xx.H>
#define voltage 1024
#define freq 120000
int main (void)
{
uint32_t m;
LPC_PINCON->PINSEL1 |= (1<<21);
while(1)
{
LPC_DAC->DACR = (voltage/2 << 6);
for(m = freq; m > 1; m--);
LPC_DAC->DACR = (voltage << 6);
for(m = freq; m > 1; m--);
}
}
Expected output:-
Triangular wave
Program :-
#include <LPC17xx.H>
#define voltage 1024
int main (void)
{
uint32_t i = 0;
LPC_PINCON->PINSEL1 |= (1<<21);
while(1)
{
for(i = 0; i < voltage; i++)
LPC_DAC->DACR = (i << 6);
for(i = voltage; i > 0; i--)
LPC_DAC->DACR = (i << 6);
}
}
Expected output:-
Demo program:-
HEX KEY PAD Pin configurations:
The hex keypad is a peripheral that is organized in rows and Columns. Hex key Pad 16
Keys arranged in a 4 by 4 grid, labeled with the hexadecimal digits 0 to F. Internally, the
structure of the hex keypad is very simple. Wires run in vertical columns (we call them
C0 to C3) and in horizontal rows (called R0 to R3). These 8 wires are available externally,
and will be connected to the lower 8 bits of the port. Each key on the keypad is essentially
a switch that connects a row wire to a column wire. When a key is pressed, it makes an
electrical connection between the row and column. Table shows connections for HEX
KEY Pad matrix.
Program:-
#include <LPC17xx.H>
#include <stdio.h>
#include "lcd.h"
void delay(unsigned int count)
{
unsigned int j=0,k=0;
for(j=0;j<count;j++)
{
for(k=0;k<12000;k++);
}
}
void LCD_DATA(unsigned char val)
{
LPC_GPIO2->FIOPIN= val;
LPC_GPIO0->FIOSET=(1<<28);
LPC_GPIO0->FIOSET=(1<<27);
delay(100);
LPC_GPIO0->FIOCLR=(1<<27);
delay(100);
}
void col_write( unsigned char data )
{
unsigned int temp=0;
temp=(data << 14) & 0X0003C000;
LPC_GPIO1->FIOCLR = 0X0003C000;
LPC_GPIO1->FIOSET = temp;
}
int main()
{
unsigned char array[100]={"PRESSED KEY IS"};
unsigned char i,j,key,key1;
unsigned char rval[ ] = {0x7,0xB,0xD,0xE,0x0};
unsigned char keyPadMatrix[ ] = { 'C','8','4','0',
'D','9','5','1',
‘E','A','6','2',
'F','B','7','3‘ };
LPC_GPIO0->FIODIR =0X18000000;
LPC_GPIO2->FIODIR=0x000000FF;
LPC_GPIO1->FIODIR=0X0003C000;
LPC_GPIO1->FIODIR&=~0X003C0000;
init_lcd();
for(j=0; j<14; j++)
{
key1=array[j];
LCD_DATA(key1);
delay(100);
}
while(1)
{
key = 0;
for( i = 0; i < 4; i++ )
{
col_write(rval[i]);
if (!(LPC_GPIO1->FIOPIN & (1<<18)))
break;
key++;
if (!(LPC_GPIO1->FIOPIN & (1<<19)))
break;
key++;
if (!(LPC_GPIO1->FIOPIN & (1<<20)))
break;
key++;
if (!(LPC_GPIO1->FIOPIN & (1<<21)))
break;
key++;
}
lcd_command_write(0xC8);
if (!(key == 0x10))
LCD_DATA(keyPadMatrix[key]);
delay(10);
}
}
NOTE: Along with the above program add lcd.c and lcd.h Supporting files and then build
the program.
Output:-
16*2 LCD display
Pressed key is :-7
The key passed on 4*4 keypad matrix was displayed on 16*2 alphanumeric display.
a. LPC-1768 Board:
b. 16 X 2 LCD Display:
An LCD display is specifically manufactured to be used with microcontrollers,
which means that it cannot be activated by standard IC circuits. It is used for
displaying different messages on a miniature liquid crystal display. It displays all
the letters of alphabet, Greek letters, punctuation marks, mathematical symbols
etc. In addition, it is possible to display symbols made up by the user. Other useful
features include automatic message shift (left and right), cursor appearance, LED
backlight etc.
There are pins along one side of a small printed board. These are used for
connecting to the microcontroller. There are in total of 14 pins marked with
numbers (16 if it has backlight). Their function is described in the table below:
Relay:-