Simple GPIO Data of LPC 2148

You might also like

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 11

Name of Subject Advanced Processor

Subject code 304189

Year 2020-21

Class TE E&Tc

Semester VI

Examination In-Sem(Paper)-30 Marks


Scheme End-Sem(Paper)-70 Marks

Unit no III
Real World Interfacing with ARM7
Name of Unit
BasedSepMicrocontroller-1
1, 2021 1
Course Objectives

To understand need and application of ARM


CO1
Microprocessors in embedded system.
To study the architecture of ARM series
CO2
microprocessor

To understand architecture and features of typical


CO3
ARM7& DSP Processors.

To learn interfacing of real world input and output


CO4
devices

CO5 To learn embedded communication systems.

Sep 1, 2021 2
Course Outcomes

Describe the ARM microprocessor architectures and


CO1
its features.

CO2 Design embedded system with available resources.

Interface the advanced peripherals to ARM based


CO3
microcontroller

Use of DSP Processors and resources for signal


CO4
processing applications

Sep 1, 2021 3
Objectives
 LED Interfacing with LPC2148
 LCD Interfacing with LPC2148
 GLCD
 GLCD Interfacing with LPC2148

Sep 1, 2021 4
Registers used for GPIO Programming:
 Usually most of the pins of an ARM microcontroller is
multi-functional, every pin can be made to perform one of
the assigned function by setting particular bits of PINSEL
register.

Register Pins

PINSEL0 P0.0 to P0.15

PINSEL1 P0.16 to P0.31

PINSEL2 P1(P1.16 to P1.31)

IOxDIR
 This register is used to control the direction (input or
output) of a pin, once is it configured as a GPIO pin
(General Purpose Input Output) by using PINSELx
register.

Sep 1, 2021 5
Registers Required to set Input/Output
• IOxDIR
Value Direction

0 Input
1 Output

IOxSET

IOxSET is GPIO output set register. This register is


commonly used in conjunction with IOxCLR register
described below. Writing ones to this register sets (output
high) corresponding port pins, while writing zeros has no
effect.

IOxCLR
IOxCLR is GPIO output clear register. As mentioned above,
this register is used in conjunction with IOxSET. Writing
Sep 1, 2021 6
Input/Output Configuration:
1. E.g.Setting PIN 2 of port 0 i.e. p0.2 as output can be
done in various ways:
Case1: IODIR0=(1<<2);//(binary-direct assign:
other pins set to 0)
Case2:IODIR0|=0x00000004;//or
0x4(hexadecimal –OR and assign: other pins not
effected)
Case3:IODIR0|=(1<<2);//(binary-OR and assign:
others pins not effected
2.E.g.Consider that we want to configure pin 19 of port 0
i.e. p0.19 as output and want to drive it high.
Sol: IODIR0|=(1<<19);//config. P0.19 as output
IOSET0|(1<<19);Make output high for p0.19

Sep 1, 2021 7
Simple program

1)E.g.Making output configured pin 15 High of Port 0 i.e.


p0.15 and then Low.

Sol:IODIR0|=(1<<15);//p0.15 is output pin

IOSET0|=(1<<15);//output for p0.15 becomes High

IOCLR0 |=(1<<15);//output for P0.15 becomes Low

2)Configuring P0.13 and P0.19 as output and setting High:

Sol:IODIR0 |=(1<<13) |(1<<19)

IOSET0 |=(1<<13) |(1<<19)

3)Configuring 1st 16 Pins of port 0(P0.0 to P0.15) as output


and setting High: IODIR0 |=0x0000FFFF

IOSET0 |=0x0000FFFF;//configure P0.0 to P0.15 as Output


September 1, 2021 8
Embedded C Program for Following Step:
1) Configuring p0.7 as input and monitoring it for a
external event like connecting it low or gnd.p0.30 is
configured as output and connected to LED.
2) If Input for p0.7 is a ‘low’(gnd) then output for p0.30 is
made High which will activate the LED activate the LED
and make it glow(Since the other end of led is
connected to low i.e. gnd)
3) Consider one end of tactile switch connected to p0.7
and other to ground
4) When the switch is pressed a ‘low’ will be applied to
p0.7
Sol:#include<lpc214x.h>
int main()
{ IODIR0 &=~((1<<7));Explicitly making p0.7 as output as
input –even through by default its already Input
IODIR0 |=(1<<30);//Configuring P0.30 as output
While(1)
Sep 1, 2021 9
{
If(!IOPIN0 & (1<<7))//evaluate to True for ‘LOW’ on p0.7
{
IOSET0 |=(1<<30);//drive P0.30 High
}}
Return 0;
}

Sep 1, 2021 10
Thank
you

Sep 1, 2021 11

You might also like