ARM Lab Manual1 PDF
ARM Lab Manual1 PDF
ARM Lab Manual1 PDF
Prepared by
To foster professional level competence in all areas of Electronics and Communication Engineering
and to benchmark the Department as a centre in the Country, for nurturing Women Engineers in the
Country.
M5: To sensitize the Students regarding Social, Moral and Professional ethics.
M7: To provide special skills training to the Students to make them eligible for Placement.
PEO1: To inculcate students to excel in professional career and/or higher education by acquiring
knowledge in the field of Electronics and Communication.
PEO2: To make the students capable of managing their profession based on existing as well as
new emerging technologies in the area of Electronics and Communication Engineering.
PEO3: To Produce Technically competent graduates with ability to analyze, design, develop,
optimize and implement Electronics and Communication systems.
Program Outcomes
PSO1. Graduates will have the ability to mould the technology in the areas of Analog and
Digital Scenario.
PART-A: Conduct the following Study experiments to learn ALP using ARM Cortex M3 Registers
PART-B: Conduct the following experiments on an ARM CORTEX M3 evaluation board using
4. Determine Digital output for a given Analog input using Internal ADC of ARM controller.
7. Using the Internal PWM module of ARM controller generate PWM and vary its duty cycle.
9. Display the Hex digits 0 to F on a 7-segment LED interface, with an appropriate delay in between.
10. Interface a simple Switch and display its status through Relay, Buzzer and LED.
11. Measure Ambient temperature using a sensor and SPI ADC IC.
Dos & don’ts
1.1 Introduction
The ARM Cortex-M3 is a general purpose 32-bit microprocessor, which offers high performance
and very low power consumption. The Cortex-M3 offers many new features, including a Thumb-
2 instruction set, low interrupt latency, hardware divide, interruptible/continuable multiple load
and store instructions, automatic state save and restore for interrupts, tightly integrated interrupt
controller with Wake-up Interrupt Controller and multiple core buses capable of simultaneous
accesses. Pipeline techniques are employed so that all parts of the processing and memory
systems can operate continuously. Typically, while one instruction is being executed, its
successor is being decoded, and a third instruction is being fetched from memory.
The processor has a Harvard architecture, which means that it has a separate instruction bus and
data bus. This allows instructions and data accesses to take place at the same time, and as a result
of this, the performance of the processor increases because data accesses do not affect the
instruction pipeline. This feature results in multiple bus interfaces on Cortex-M3, each with
optimized usage and the ability to be used simultaneously. However, the instruction and data
buses share the same memory space (a unified memory system). In other words, you cannot get 8
GB of memory space just because you have separate bus interfaces.
It is worthwhile highlighting that the Cortex-M3 processor is not the first ARM processor to be
used to create generic micro controllers. The venerable ARM7 processor has been very
successful in this market, The Cortex-M3 processor builds on the success of the ARM7
processor to deliver devices that are significantly easier to program and debug and yet deliver a
higher processing capability.
Nowadays, ARM partners ship in excess of 2 billion ARM processors each year. Unlike many
semiconductor companies, ARM does not manufacture processors or sell the chips directly.
Instead, ARM licenses the processor designs to business partners, including a majority of the
world‟s leading semiconductor companies. Based on the ARM low-cost and power-efficient
processor designs, these partners create their processors, micro controllers, and system-onchip
solutions. This business model is commonly called intellectual property (IP) licensing.
The ARMv5E architecture was introduced with the ARM9E processor families, including the
ARM926E-S and ARM946E-S processors. This architecture added “Enhanced” Digital Signal
Processing (DSP) instructions for multimedia applications. With the arrival of the ARM11
processor family, the architecture was extended to the ARMv6. New features in this architecture
included memory system features and Single Instruction–Multiple Data (SIMD) instructions.
Processors based on the ARMv6 architecture include the ARM1136J (F)-S, the ARM1156T2
(F)-S, and the ARM1176JZ (F)-S. Over the past several years, ARM extended its product
portfolio by diversifying its CPU development, which resulted in the architecture version 7 or v7.
processor is based on one profile of the v7 architecture, called ARM v7-M, an architecture
specification for micro controller products.
allowing higher efficiency by reducing the number of states switching between ARM state and
Thumb state. Focused on small memory system devices such as micro controllers and reducing
the size of the processor, the Cortex-M3 supports only the Thumb-2 (and traditional Thumb)
instruction set.
Instead of using ARM instructions for some operations, as in traditional ARM processors, it uses
the Thumb-2 instruction set for all operations. As a result, the Cortex-M3 processor is not
backward compatible with traditional ARM processors. Nevertheless, the Cortex-M3 processor
can execute almost all the 16-bit Thumb instructions, including all 16-bit Thumb instructions
supported on ARM7 family processors, making application porting easy. With support for both
16-bit and 32-bit instructions in the Thumb-2 instruction set, there is no need to switch the
processor between Thumb state (16-bit instructions) and ARM state (32-bit instructions). For
example, in ARM7 or ARM9 family processors, you might need to switch to ARM state if you
want to carry out complex calculations or a large number of conditional operations and good
performance is needed, whereas in the Cortex-M3 processor, you can mix 32-bit instructions
with 16-bit instructions without switching state, getting high code density and high performance
with no extra complexity.
The Thumb-2 instruction set is a very important feature of the ARMv7 architecture. Compared
with the instructions supported on ARM7 family processors (ARMv4T architecture), the Cortex-
M3 processor instruction set has a large number of new features. For the first time, hardware
divide instruction is available on an ARM processor, and a number of multiply instructions are
also available on the Cortex-M3 processor to improve data-crunching performance. The Cortex-
M3 processor also supports unaligned data accesses, a feature previously available only in high
end processors.
Low power consumption: enabling longer battery life, especially critical in portable
products including wireless networking applications.
Enhanced determinism: guaranteeing that critical tasks and interrupts are serviced as
quickly as possible and in a known number of cycles.
Improved code density: ensuring that code fits in even the smallest memory footprints.
Ease of use: providing easier programming and debugging for the growing number of 8-
bit and 16-bit users migrating to 32 bits.
Lower cost solutions: reducing 32-bit-based system costs close to those of legacy 8-bit
and 16-bit devices and enabling low-end, 32-bit micro controllers to be priced at less than
US$1 for the first time.
Wide choice of development tools: from low-cost or free compilers to full-featured
development suites from many development tool vendors.
Cost savings can be achieved by improving the amount of code reuse across all systems. Because
Cortex-M3 processor-based micro controllers can be easily programmed using the C language
and are based on a well-established architecture, application code can be ported and reused
easily, and reducing development time and testing costs.
Data communications: The processor‟s low power and high efficiency, coupled with
instructions in Thumb-2 for bit-field manipulation, make the Cortex-M3 ideal for many
communications applications, such as Bluetooth and ZigBee.
Industrial control: In industrial control applications, simplicity, fast response, and reliability are
key factors. Again, the Cortex-M3 processors interrupt feature, low interrupt latency, and
enhanced fault-handling features make it a strong candidate in this area.
Consumer products: In many consumer products, a high-performance microprocessor (or
several of them) is used. The Cortex-M3 processor, being a small processor, is highly efficient
and low in power and supports an MPU enabling complex software to execute while providing
robust memory protection.
1.7 The Cortex-M3 Processor versus Cortex-M3-Based Micro
Controllers
The Cortex-M3 processor is the central processing unit (CPU) of a micro controller chip. In
addition, a number of other components are required for the whole Cortex-M3 processor-based
micro controller. After chip manufacturers license the Cortex-M3 processor, they can put the
Cortex-M3 processor in their silicon designs, adding memory, peripherals, input/output (I/O),
and other features. Cortex-M3 processor-based chips from different manufacturers will have
different memory sizes, types, peripherals, and features.
The LPC1768FBD100 is an ARM Cortex-M3 based micro controller for embedded applications
requiring a high level of integration and low power dissipation. The ARM Cortex-M3 is a next
generation core that offers system enhancements such as modernized debug features and a higher
level of support block integration. LPC1768 operate up to 100 MHz CPU frequency.
The peripheral complement of the LPC1768 includes up to 512 kilo bytes of flash memory, up to
64KB of data memory, Ethernet MAC, a USB interface that can be configured as either Host,
Device, or OTG, 8 channel general purpose DMA controller, 4 UARTs, 2 CAN channels, 2 SSP
controllers, SPI interface, 3 I2C interfaces, 2-input plus 2-output I2S interface, 8 channel 12-bit
ADC, 10-bit DAC, motor control PWM, Quadrature Encoder interface, 4 general purpose timers,
6-output general purpose PWM, ultra-low power RTC with separate battery supply, and up to 70
general purpose I/O pins.
The LPC1768 use a multi layer AHB(Advanced High Performance Bus) matrix to connect the
ARM Cortex-M3 buses and other bus masters to peripherals in a flexible manner that optimizes
performance by allowing peripherals that are on different slaves ports of the matrix to be
accessed simultaneously by different bus masters.
On-chip flash memory system
The LPC1768 contains up to 512 KB of on-chip flash memory. A flash memory accelerator
maximizes performance for use with the two fast AHB Lite buses. This memory may be used for
both code and data storage. Programming of the flash memory may be accomplished in several
ways. It may be programmed In System via the serial port. The application program may also
erase and/or program the flash while the application is running, allowing a great degree of
flexibility for data storage field firmware upgrades, etc.
On-chip Static RAM
The LPC1768 contains up to 64 KB of on-chip static RAM memory. Up to 32 KB of SRAM,
accessible by the CPU and all three DMA controllers are on a higher-speed bus. Devices
containing more than 32 KB SRAM have two additional 16 KB SRAM blocks, each situated on
separate slave ports on the AHB multilayer matrix. This architecture allows the possibility for
CPU and DMA accesses to be separated in such a way that there are few or no delays for the bus
masters.
Interrupt sources
Each peripheral device has one interrupt line connected to the NVIC but may have several
interrupt flags. Individual interrupt flags may also represent more than one interrupt source. Any
pin on Port 0 and Port 2 (total of 42 pins) regardless of the selected function, can be programmed
to generate an interrupt on a rising edge, a falling edge, or both.
General purpose DMA controller
The GPDMA (General Purpose Direct Memory Access) is an AMBA AHB (Advanced Micro
controller Bus Architecture Advance high performance bus) compliant peripheral allowing
selected peripherals to have DMA support. The GPDMA enables peripheral-to-memory,
memory-to-peripheral, peripheral-to-peripheral, and memory-to-memory transactions. The
source and destination areas can each be either a memory region or a peripheral, and can be
accessed through the AHB master. The GPDMA controller allows data transfers between the
USB and Ethernet controllers and the various onchip SRAM areas. The supported APB
peripherals are SSP0/1, all UARTs, the I2S-bus interface, the ADC, and the DAC. Two match
signals for each timer can be used to trigger DMA transfers.
Function Configuration block
The selected pins of the micro controller to have more than one function. Configuration registers
control the multiplexers to allow connection between the pin and the on-chip peripherals.
Peripherals should be connected to the appropriate pins prior to being activated and prior to any
related interrupt(s) being enabled. Activity of any enabled peripheral function that is not mapped
to a related pin should be considered undefined. Most pins can also be configured as open-drain
outputs or to have a pullup, pull-down, or no resistor enabled.
Fast general purpose parallel I/O
Device pins that are not connected to a specific peripheral function are controlled by the GPIO
registers. Pins may be dynamically configured as inputs or outputs. Separate registers allow
setting or clearing any number of outputs simultaneously. The value of the output register may
be read back as well as the current state of the port pins.
USB interface
The Universal Serial Bus (USB) is a 4-wire bus that supports communication between a host and
one or more (up to 127) peripherals. The host controller allocates the USB bandwidth to attached
devices through a token-based protocol. The bus supports hot plugging and dynamic
configuration of the devices. All transactions are initiated by the host controller.
The USB interface includes a device, Host, and OTG controller with on-chip PHY for device and
Host functions. The OTG switching protocol is supported through the use of an external
controller.
USB device controller enables 12 Mbit/s data exchange with a USB Host controller. It consists
of a register interface, serial interface engine, endpoint buffer memory, and a DMA controller.
The serial interface engine decodes the USB data stream and writes data to the appropriate
endpoint buffer. The status of a completed USB transfer or error condition is indicated via status
registers. An interrupt is also generated if enabled. When enabled, the DMA controller transfers
data between the endpoint buffer and the on-chip SRAM.
12-bit ADC
The LPC1768 contain a single 12-bit successive approximation ADC with eight channels and
DMA support.
10-bit DAC
The DAC allows to generate a variable analog output. The maximum output value of the DAC is
VREFP.
UART's
The LPC1768 contain four UART's. In addition to standard transmit and receive data lines,
UART1 also provides a full modem control handshake interface and support for RS-485/9-bit
mode allowing both software address detection and automatic address detection using 9-bit
mode. The UART's include a fractional baud rate generator. Standard baud rates such as 115200
Baud can be achieved with any crystal frequency above 2 MHz
SPI serial I/O controller
The LPC1768 contain one SPI controller. SPI is a full duplex serial interface designed to handle
multiple masters and slaves connected to a given bus. Only a single master and a single slave can
communicate on the interface during a given data transfer. During a data transfer the master
always sends 8 bits to 16 bits of data to the slave, and the slave always sends 8 bits to 16 bits of
data to the master.
SSP serial I/O controller
The LPC1768 contain two SSP controllers. The SSP controller is capable of operation on a SPI,
4-wire SSI, or Micro wire bus. It can interact with multiple masters and slaves on the bus. Only a
single master and a single slave can communicate on the bus during a given data transfer. The
SSP supports full duplex transfers, with frames of 4 bits to 16 bits of data flowing from the
master to the slave and from the slave to the master. In practice, often only one of these data
flows carries meaningful data.
I2C-bus serial I/O controllers
The LPC1768 each contain three I2C-bus controllers. The I2C-bus is bidirectional for inter-IC
control using only two wires: a Serial Clock line (SCL) and a Serial DAta line (SDA). Each
device is recognized by a unique address and can operate as either a receiver-only device or a
transmitter with the capability to both receive and send information (such as memory).
Transmitters and/or receivers can operate in either master or slave mode, depending on whether
the chip has to initiate a data transfer or is only addressed. The I2C is a multi-master bus and can
be controlled by more than one bus master connected to it.
General purpose 32-bit timers/external event counters
The LPC1768 include four 32-bit timer/counters. The timer/counter is designed to count cycles
of the system derived clock or an externally-supplied clock. It can optionally generate interrupts,
generate timed DMA requests, or perform other actions at specified timer values, based on four
match registers. Each timer/counter also includes two capture inputs to trap the timer value when
an input signal transitions, optionally generating an interrupt.
Pulse width modulator
The PWM is based on the standard Timer block and inherits all of its features, although only the
PWM function is pinned out on the LPC1768. The Timer is designed to count cycles of the
system derived clock and optionally switch pins, generate interrupts or perform other actions
when specified timer values occur, based on seven match registers. The PWM function is in
addition to these features, and is based on match register events.
Watchdog timer
The purpose of the watchdog is to reset the micro controller within a reasonable amount of time
if it enters an erroneous state. When enabled, the watchdog will generate a system reset if the
user program fails to „feed‟ (or reload) the watchdog within a predetermined amount of time.
RTC and backup registers
The RTC is a set of counters for measuring time when system power is on, and optionally when
it is off. The RTC on the LPC1768 is designed to have extremely low power consumption, i.e.
less than 1 uA. The RTC will typically run from the main chip power supply, conserving battery
power while the rest of the device is powered up. When operating from a battery, the RTC will
continue working down to 2.1 V. Battery power can be provided from a standard 3 V Lithium
button cell. An ultra-low power 32 kHz oscillator will provide a 1 Hz clock to the time counting
portion of the RTC, moving most of the power consumption out of the time counting function.
Clocking and Power Control
Crystal oscillators
The LPC1768 include three independent oscillators. These are the main oscillator, the IRC
oscillator, and the RTC oscillator. Each oscillator can be used for more than one purpose as
required in a particular application. Any of the three clock sources can be chosen by software to
drive the main PLL and ultimately the CPU. Following reset, the LPC1768 will operate from the
Internal RC oscillator until switched by software. This allows systems to operate without any
external crystal and the boot loader code to operate at a known frequency.
Power control
The LPC1768 support a variety of power control features. There are four special modes of
processor power reduction: Sleep mode, Deep-sleep mode, Power-down mode, and Deep power-
down mode. The CPU clock rate may also be controlled as needed by changing clock sources,
reconfiguring PLL values, and/or altering the CPU clock divider value. This allows a trade-off of
power versus processing speed based on application requirements. In addition, Peripheral Power
Control allows shutting down the clocks to individual on-chip peripherals, allowing fine tuning
of power consumption by eliminating all dynamic power use in any peripherals that are not
required for the application. Each of the peripherals has its own clock divider which provides
even better power control.
Integrated PMU (Power Management Unit) automatically adjust internal regulators to minimize
power consumption during Sleep, Deep sleep, Power-down, and Deep power- down modes. The
LPC1768 also implement a separate power domain to allow turning off power to the bulk of the
device while maintaining operation of the RTC and a small set of registers for storing data during
any of the power-down modes.
System Control
Reset
Reset has four sources on the LPC1768: the RESET pin, the Watchdog reset, power-on reset
(POR), and the Brown-Out Detection (BOD) circuit. The RESET pin is a Schmitt trigger input
pin. Assertion of chip Reset by any source, once the operating voltage attains a usable level,
causes the RSTOUT pin to go LOW. Once reset is de-asserted, or, in case of a BOD- triggered
reset, once the voltage rises above the BOD threshold, the RSTOUT pin goes HIGH. In other
words RSTOUT is high when the controller is in its active state.
Emulation and debugging
Debug and trace functions are integrated into the ARM Cortex-M3. Serial wire debug and trace
functions are supported in addition to a standard JTAG debug and parallel trace functions. The
ARM Cortex-M3 is configured to support up to eight breakpoints and four watch points.
Note: For further details on Controller blocks refer the User manual of LPC176x/5x – UM10360
available at www.nxp.com
- SPI controller with synchronous, serial, full duplex communication and programmable data
length. SPI is included as a legacy peripheral and can be used instead of SSP0.
- Three enhanced I2C-bus interfaces, one with an open-drain output supporting the full I2C
specification and Fast mode plus with data rates of 1Mbit/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 interface can be used with the GPDMA. The I2S interface supports 3-wire data transmit and
receive or 4-wire combined transmit and receive connections, as well as master clock output.
Other peripherals:
- 70 General Purpose I/O (GPIO) pins with configurable pull-up/down resistors, open drain
mode, and repeater mode. All GPIOs are located on an AHB bus for fast access, and support
Cortex-M3 bit-banding. GPIOs can be accessed by the General Purpose DMA Controller. Any
pin of ports 0 and 2 can be used to generate an interrupt.
- 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.
- Real-Time Clock (RTC) with a separate power domain. The RTC is clocked by a dedicated
RTC oscillator. The RTC block includes 20 bytes of battery-powered backup registers, allowing
system status to be stored when the rest of the chip is powered off. Battery power can be
supplied from a standard 3 V Lithium button cell. The RTC will continue working when the
battery voltage drops to as low as 2.1 V. An RTC interrupt can wake up the CPU from any
reduced power mode.
- Watchdog Timer (WDT). The WDT can be clocked from the internal RC oscillator, the RTC
oscillator, or the APB clock.
PART-A
Conduct the following Study experiments to learn ALP using ARM Cortex M3 Registers using
an Evaluation board and the required software tool.
#include <LPC17xx.h>
SystemInit();
MULTIPLY(); //Function Call
result = globvar;
LCD_DISP(globvar);
while(1);
#include <LPC17xx.h>
extern void sumten(void); //Name of assembly routine
extern unsigned long int globvar; //global variable to access at asm code
SystemInit();
sumten(); //calling asm code
result = globvar;
LCD_DISP(globvar);
while(1);
PART-B
#include<LPC17xx.h>
int main(void)
{
SystemInit();
SystemCoreClockUpdate();
UART0_Init();
while(1)
{
ptr = arr;
while ( *ptr != '\0'){
LPC_UART0->THR = *ptr++;
while(tx0_flag == 0x00);
tx0_flag = 0x00;
for (i=0; i<200; i++);
}
for (i=0; i<500; i++)
delay(625); //delay
}
}
void UART0_Init(void)
{
LPC_SC->PCONP |= 0x00000008; //UART0 peripheral enable
LPC_PINCON->PINSEL0 |= 0x00000050;
LPC_UART0->LCR = 0x00000083; //enable divisor latch, parity disable,
1 stop bit, 8bit word length
LPC_UART0->DLM = 0X00;
LPC_UART0->DLL = 0x13; //select baud rate 9600 bps
LPC_UART0->LCR = 0X00000003;
LPC_UART0->FCR = 0x07;
LPC_UART0->IER = 0X03; //select Transmit and receive
interrupt
void UART0_IRQHandler(void)
{
unsigned long Int_Stat;
Int_Stat = LPC_UART0->IIR; //reading the data from
interrupt identification register
Int_Stat = Int_Stat & 0x06; //masking other than txmit int & rcve
data indicator
{
for(r=0;r<r1;r++);
}
#include <lpc17xx.h>
void pwm_init(void);
void PWM1_IRQHandler(void);
int main(void)
{
SystemInit();
SystemCoreClockUpdate();
pwm_init();
while(1)
{
for(i=0;i<=1000;i++); // delay
}//end of while
}//end of main
void pwm_init(void)
{
LPC_SC->PCONP |= (1<<6); //PWM1 is
powered
NVIC_EnableIRQ(PWM1_IRQn);
return;
}
void PWM1_IRQHandler(void)
{
LPC_PWM1->IR = 0xff; //clear the interrupts
if(flag == 0x00)
{
LPC_PWM1->MR5 += 100;
LPC_PWM1->LER = 0x000000FF;
LPC_PWM1->MR5 -= 100;
LPC_PWM1->LER = 0x000000fF;
LPC_PWM1->LER = 0X000000fF;
}
for(i=0;i<8000;i++);
}
}
#include <LPC17xx.H>
void Clock_Wise(void);
void AClock_Wise(void);
unsigned long i;
int main(void)
{
SystemInit();
LPC_PINCON->PINSEL1 &= 0xFFCFFFFF; //P0.26 GPIO, P0.26 controls dir
LPC_PINCON->PINSEL3 &= 0xFFFFCFFF; //P1.24 GPIO
LPC_GPIO0->FIODIR |= 0x04000000; //P0.26 output
LPC_GPIO1->FIODIR |= 0x01000000; //P1.24 output
while(1)
{
Clock_Wise();
for(i=0;i<200000;i++);
AClock_Wise();
for(i=0;i<200000;i++);
} //end while(1)
} //end main
void Clock_Wise(void)
{
LPC_GPIO1->FIOCLR = 0x01000000; //P0.23 Kept low to off DCM
for(i=0;i<10000;i++); //delay to componsate
inertia
LPC_GPIO0->FIOSET = 0x04000000; //coil is on
LPC_GPIO1->FIOSET = 0x01000000; //motor in on
return;
} //end void
Clock_Wise(void)
void AClock_Wise(void)
{
LPC_GPIO1->FIOCLR = 0x01000000; //P0.23 Kept low to off DCM
for(i=0;i<10000;i++); //delay to componsate inertia
LPC_GPIO0->FIOCLR = 0x04000000; //coil is off
LPC_GPIO1->FIOSET = 0x01000000; //Motor is on
return;
} //end void
AClock_Wise(void)
#include <LPC17xx.H>
void clock_wise(void);
void anti_clock_wise(void);
unsigned long int var1,var2;
unsigned int i=0,j=0,k=0;
int main(void)
{
SystemInit();
SystemCoreClockUpdate();
while(1)
{
for(j=0;j<50;j++) //50 times in Clock wise Rotation
clock_wise();
void clock_wise(void)
{
var1 = 0x00000001; //For Clockwise
for(i=0;i<=3;i++) //for A B C D Stepping
{
LPC_GPIO2->FIOCLR = 0X0000000F;
LPC_GPIO2->FIOSET = var1;
var1 = var1<<1; //For Clockwise
for(k=0;k<15000;k++); //for step speed variation
}
}
void anti_clock_wise(void)
{
var1 = 0x0000008; //For Anticlockwise
for(i=0;i<=3;i++) //for A B C D Stepping
{
LPC_GPIO2->FIOCLR = 0X0000000F;
LPC_GPIO2->FIOSET = var1;
var1 = var1>>1; //For Anticlockwise
for(k=0;k<15000;k++); //for step speed variation
}
4) Determine Digital output for a given Analog input using Internal ADC of ARM
controller.
#include <lpc17xx.h>
#include "AN_LCD.h"
//lcd initialization
void lcd_init()
{
/* Ports initialized as GPIO */
LPC_PINCON->PINSEL4 &= 0xFFF000FF; //P2.4 to P2.9
clear_ports();
delay_lcd(3200);
temp2 = (0x30<<2);
wr_cn();
delay_lcd(30000);
temp2 = (0x30<<2);
wr_cn();
delay_lcd(30000);
temp2 = (0x30<<2);
wr_cn();
delay_lcd(30000);
temp2 = (0x20<<2);
wr_cn();
delay_lcd(30000);
temp1 = 0x28;
lcd_com();
delay_lcd(30000);
temp1 = 0x0c;
lcd_com();
delay_lcd(800);
temp1 = 0x06;
lcd_com();
delay_lcd(800);
temp1 = 0x01;
lcd_com();
delay_lcd(10000);
temp1 = 0x80;
lcd_com();
delay_lcd(800);
return;
}
void lcd_com(void)
{
temp2 = temp1 & 0xf0;//move data (26-8+1) times : 26 - HN place, 4 - Bits
temp2 = temp2 << 2;//data lines from 23 to 26
wr_cn();
temp2 = temp1 & 0x0f; //26-4+1
temp2 = temp2 << 6;
wr_cn();
delay_lcd(1000);
return;
}
void clr_disp(void)
{
temp1 = 0x01;
lcd_com();
delay_lcd(10000);
return;
}
void clear_ports(void)
{
/* Clearing the lines at power on */
LPC_GPIO2->FIOCLR = DT_CTRL; //Clearing data lines
LPC_GPIO2->FIOCLR = RS_CTRL; //Clearing RS line
LPC_GPIO2->FIOCLR = EN_CTRL; //Clearing Enable line
return;
}
while(buf1[i]!='\0')
{
temp1 = buf1[i];
lcd_data();
i++;
if(i==16)
{
temp1 = 0xc0;
lcd_com();
}
}
return;
}
SINE WAVEFORM
#include <LPC17xx.H>
int count=0,sinevalue,value;
unsigned char sine_tab[49]=
{ 0x80,0x90,0xA1,0xB1,0xC0,0xCD,0xDA,0xE5,0xEE,0xF6,0xFB,0xFE,
0xFF,0xFE,0xFB,0xF6,0xEE,0xE5,0xDA,0xCD,0xC0,0xB1,0xA1,0x90,
0x80,0x70,0x5F,0x4F,0x40,0x33,0x26,0x1B,0x12,0x0A,0x05,0x02,
0x00,0x02,0x05,0x0A,0x12,0x1B,0x26,0x33,0x40,0x4F,0x5F,0x70,0x80};
int main(void)
{
LPC_PINCON->PINSEL0 &= 0xFF0000FF ;
// Configure P0.0 to P0.15 as GPIO
LPC_GPIO0->FIODIR |= 0x00000FF0 ;
count = 0;
while(1)
{
for(count=0;count<48;count++)
{
sinevalue = sine_tab[count];//+0X10 ;
value= 0x00000FF0 & (sinevalue << 4);
LPC_GPIO0->FIOPIN = value;
}
}
}
TRIANGULAR WAVEFORM
#include <LPC17xx.H>
int main ()
{
unsigned long int temp=0x00000000;
unsigned int i=0;
while(1)
{
//output 0 to FE
for(i=0;i!=0xFF;i++)
{
temp=i;
temp = temp << 4;
LPC_GPIO0->FIOPIN = temp;
}
// output FF to 1
for(i=0xFF; i!=0;i--)
{
temp=i;
temp = temp << 4;
LPC_GPIO0->FIOPIN = temp;
}
}//End of while(1)
}//End of main()
SQUARE WAVEFORM
#include <LPC17xx.H>
void delay(void);
int main ()
{
while(1)
{
LPC_GPIO0->FIOPIN = 0x00000FF0 ;
delay();
LPC_GPIO0->FIOCLR = 0x00000FF0 ;
delay();
}
}
void delay(void)
{
unsigned int i=0;
for(i=0;i<=9500;i++);
}
#include <lpc17xx.h>
#include "AN_LCD.h"
//lcd initialization
void lcd_init()
{
/* Ports initialized as GPIO */
LPC_PINCON->PINSEL4 &= 0xFFF000FF; //P2.4 to P2.9
clear_ports();
delay_lcd(3200);
temp2 = (0x30<<2);
wr_cn();
delay_lcd(30000);
temp2 = (0x30<<2);
wr_cn();
delay_lcd(30000);
temp2 = (0x30<<2);
wr_cn();
delay_lcd(30000);
temp2 = (0x20<<2);
wr_cn();
delay_lcd(30000);
temp1 = 0x28;
lcd_com();
delay_lcd(30000);
temp1 = 0x0c;
lcd_com();
delay_lcd(800);
temp1 = 0x06;
lcd_com();
delay_lcd(800);
temp1 = 0x01;
lcd_com();
delay_lcd(10000);
temp1 = 0x80;
lcd_com();
delay_lcd(800);
return;
}
void lcd_com(void)
{
temp2 = temp1 & 0xf0;//move data (26-8+1) times : 26 - HN place, 4 - Bits
temp2 = temp2 << 2;//data lines from 23 to 26
wr_cn();
temp2 = temp1 & 0x0f; //26-4+1
temp2 = temp2 << 6;
wr_cn();
delay_lcd(1000);
return;
}
clear_ports();
LPC_GPIO2->FIOPIN = temp2; // Assign the value to the data lines
LPC_GPIO2->FIOCLR = RS_CTRL; // clear bit RS
LPC_GPIO2->FIOSET = EN_CTRL; // EN=1
delay_lcd(25);
LPC_GPIO2->FIOCLR = EN_CTRL; // EN =0
return;
void clr_disp(void)
{
temp1 = 0x01;
lcd_com();
delay_lcd(10000);
return;
}
void clear_ports(void)
{
/* Clearing the lines at power on */
LPC_GPIO2->FIOCLR = DT_CTRL; //Clearing data lines
LPC_GPIO2->FIOCLR = RS_CTRL; //Clearing RS line
LPC_GPIO2->FIOCLR = EN_CTRL; //Clearing Enable line
return;
}
while(buf1[i]!='\0')
{
temp1 = buf1[i];
lcd_data();
i++;
if(i==16)
{
temp1 = 0xc0;
lcd_com();
}
}
return;
}
7) Using the Internal PWM module of ARM controller generate PWM and vary its
duty cycle.
#include <LPC17xx.H>
void pwm_init(void);
void PWM1_IRQHandler(void);
int main(void)
{
SystemInit();
SystemCoreClockUpdate();
pwm_init();
while(1)
{
for(i=0;i<=1000;i++); // delay
}//end of while
}//end of main
void pwm_init(void)
{
LPC_SC->PCONP |= (1<<6); //PWM1 is powered
LPC_PINCON->PINSEL7 |= 0x000C0000; //pwm1.2 is selected for the pin P3.25
NVIC_EnableIRQ(PWM1_IRQn);
return;
}
void PWM1_IRQHandler(void)
{
LPC_PWM1->IR = 0xff; //clear the interrupts
if(flag == 0x00)
{
LPC_PWM1->MR2 += 100;
LPC_PWM1->LER = 0x000000FF;
#include<LPC17xx.h>
void EINT3_IRQHandler(void);
int main(void)
{
unsigned char flag=0;
SystemInit();
SystemCoreClockUpdate();
//above
registers, bit0-EINT0, bit1-EINT1, bit2-EINT2,bit3-EINT3
NVIC_EnableIRQ(EINT3_IRQn); //core_cm3.h
while(1)
{
while(int3_flag == 0x00); //wait till interrupt
int3_flag = 0x00;
void EINT3_IRQHandler(void)
{
int3_flag = 0xff;
LPC_SC->EXTINT = 0x00000008; //cleares the interrupt
}
9) Display the Hex digits 0 to F on a 7-segment LED interface, with an appropriate delay
in between.
#include <LPC17xx.h>
unsigned int delay, count=0, Switchcount=0,j;
while(1)
{
LPC_GPIO0->FIOSET |= ALLDISP;
LPC_GPIO0->FIOCLR = 0x00000ff0; // clear the data lines to 7-
segment displays
LPC_GPIO0->FIOSET = Disp[Switchcount]; // get the 7-segment display
value from the array
for(j=0;j<3;j++)
for(delay=0;delay<30000;delay++); // 1s delay
Switchcount++;
if(Switchcount == 0x10) // 0 to F has been displayed ? go
back to 0
{
Switchcount = 0;
LPC_GPIO0->FIOCLR = 0x00180ff0;
}
}
}
10) Interface a simple Switch and display its status through Relay, Buzzer and LED.
#include <LPC17xx.H>
unsigned int count=0;
int main(void)
{
unsigned int i;
SystemInit();
SystemCoreClockUpdate();
}
else
{
LPC_GPIO0->FIOCLR = 0x03000000; //relay off
for(i=0;i<100000;i++);
}
}
} //end
int main(void)
11) Measure Ambient temperature using a sensor and SPI ADC IC.
#include <LPC17xx.h>
#include "SPI.h"
unsigned char spi_flag = 0, temp=0;
void SPI_Init(void)
{
// LPC_SC->PCONP |= (1<<8); //Enable the peripheral SPI
LPC_PINCON->PINSEL0 |= 0xC0000000; //P0.15 as SCK
LPC_PINCON->PINSEL1 |= 0x0000003C; //select MISO-P0.17,MOSI-P0.18
void SPI_IRQHandler(void)
{
spi_flag = 1;
temp = LPC_SPI->SPSR; // To clear SPIF bit we have to read status register.
temp = LPC_SPI->SPDR; // Then read the data register(optional)
LPC_SPI->SPINT = 0x01; // To clear the SPI interrupt
}
INSTITUTION VISION&MISSION
VISION
To become a recognized world class Women Educational Institution, by imparting
professional education to the students, creating technical opportunities through academic
excellence and technical achievements, with ethical values.
MISSION
M1. To support value based education with state of art infrastructure.
M2. To empower women with the additional skill for professional future carrier.
M3. To enrich students with research blends in order to fulfill the International challenges.
M4. To create multidisciplinary center of excellence.
M5. To achieve Accreditation standards towards intentional education recognition.
M6. To establish more Post Graduate & Research course.
M7. To increase Doctorates numbers towards the Research quality of academics.
Vision of the Institute
“To become a recognized world class women educational institution, by imparting professional
education to the students, creating technical opportunities through academic excellence and
technical achievements, with ethical values”
M2: To empower women with the additional skill for professional future career
M3: To enrich students with research blends in order to fulfill the International challenges