SlideShare a Scribd company logo
1 of 16
Dr.Y.NARASIMHA MURTHY Ph.D
                                                                    yayavaram@yahoo.com


                   ARM LPC 21XX INTEFACING EXAMPLES



1.INTERFACING LEDs TO ARM 7 CONTROLLER- (LPC2148 )
Light Emitting Diodes (LEDs) are popularly used display components used to indicate the ON
and OFF state of a system. These are also used to realize various counters like binary counters
experimentally. These LEDs can be easily interfaced with the Port pins of any Microcontroller
by using current limiting resistors of the order of 220 Ohms.

The diagram below shows the interfacing of LED array to the Port1 pins of LPC2148 ARM 7
microcontroller.




1
Dr.Y.NARASIMHA MURTHY Ph.D
                                                                      yayavaram@yahoo.com




PROGRAM -1

This program blinks the LEDs continuously with a small delay. The LEDs are connected to the
Port1 pins P1.24 to P1.31 and the these pins are configured as General Purpose output pins.

#include<lpc2148.H>                  //LPC2148 Header
 void delay()
{
for(int i=0x00;i<=0xff;i++)
for(int j=0x00;j<=0xFf;j++) ;      // Delay program
}
void main()
{
PINSEL2 = 0X00000000;              // Set P1.24 TO P1.31 as GPIO
IO1DIR = 0XFF000000;               //Port pins P1.24 to P 1.31 Configured as Output port.

while(1)                          //Infinite loop
{
IO1SET=0XFF000000;                   // Pins P1.24 to P1.31 goes to high state
delay();
IO1CLR=0XFF000000;                   // Pins P1.24 to P1.31 goes to low state
delay() ;
}
}

PROGRAM – 2

This program glows LEDs alternately by sending 55H and AAH through the port1 Pins.

# include <LPC214X.H>             //LPC2148 HEADER
void delay(void)                  // Delay Program
{
unsigned int i;
i=0xffffff;
 while(i--);
}
int main(void)
{
PINSEL2=0x0000;                        // Port 1 is I/O

IODIR1 = 0XFF <<24 ;            // Port Pins P1.24 to P1.31 as Output Pins


2
Dr.Y.NARASIMHA MURTHY Ph.D
                                                                           yayavaram@yahoo.com


while(1)                              // Infinite loop

{



IOSET1=0X55<<25               ;           // P1.25,P1.27,P1.29 & P1.31 LEDs will Glow

delay()                       ;          // Call delay function

IOCLR1= 0X55 <<25                 ;       // P1.25,P1.27,P1.29 &P1.31 LEDs will be off

IOSET1=0XAA<<24                   ;     //P1.24,P1.26,P1.28 &P1.30 LEDs are Glow

delay ()                      ; // Call delay function

IOCLR1=0XAA<<24               ; // P1.24,P1.26,P1.28 &P1.30 LEDs are off

}

}

2.INTERFACING A RELAY TO ARM 7 CONTROLLER- (LPC2148 )

Relays are devices which allow low power circuits to switch a relatively high Current/ Voltage
ON/OFF. A relay circuit is typically a smaller switch or device which drives (opens/closes) an
electric switch that is capable of carrying much larger current amounts.

Figure     below shows the interfacing of the Relay to ARM controller. When the input is
energized, the relay turns on and the '+' output is connected to +12v. When the relay is off, the '+'
output is connected to Ground. The '-' output is permanently wired to Ground.

The relay is interfaced to P0.30 Pin through an Opto-isolator. This opto-isolator protects the port
pin from damage due to any high currents .The opto-isolator consists of a pair of an LED and a
Photo transistor as shown in the diagram. The power transistor is used at the input. So, when the
input is high , the output of the transistor is LOW and the relay is in OFF state .Similarly when
we apply a low to the transistor ,the out put is high and the relay is ON.




3
Dr.Y.NARASIMHA MURTHY Ph.D
                                                                      yayavaram@yahoo.com




Interfacing Circuit.




PROGRAM

The following program configures the P0.30 pin as an out port. When a low signal is sent
through this pin to the relay the relay is switched ON and when a high signal is sent the relay is



4
Dr.Y.NARASIMHA MURTHY Ph.D
                                                                       yayavaram@yahoo.com


switched OFF.A constant delay is created between the two events and hence the relay switches
ON and OFF in regular intervals of time.



# include <LPC214X.H>                  //LPC2148 HEADER

# define relay 1<<30                  // ASSIGN P0.30 Pin to RELAY input PIN

void DELAY(void)                       // Delay function
 {
 unsigned int i;

i=0xffffff;

while(i--) ;
}

int main(void)                          // Main program
 {

IODIR0=1<<30           ;             // P0.30 Port Pin as Outport
while(1)                            //INFINITE LOOP
{
IOSET0=1<<30               ;        //SWITCH OFF RELAY
DELAY()                    ;        //CALL DELAY




IOCLR0=1<<30                   ;    // SWITCH ON RELAY

DELAY()                            ; // CALL DELAY

}                                  // REPEAT LOOP

}




5
Dr.Y.NARASIMHA MURTHY Ph.D
                                                                      yayavaram@yahoo.com


3. INTERFACING A STEPPER MOTOR TO ARM 7 CONTROLLER- (LPC2148 )

A stepper motor is a brushless, synchronous electric motor that converts digital pulses into
mechanical rotation in steps. Every revolution of the stepper motor is divided into a discrete
number of steps, and for each pulse it receives the motor rotates through one step.

Fig below shows the interface of the Stepper Motor to ARM 7 controller. The stepper motor is
connected to Microcontroller using a ULN2003 driver IC. The ULN driver IC is connected to
the Port1 pins P1.19 to P1.22 pins. So as the microcontroller gives pulses with a particular
frequency to ULN2003, the motor is rotated either in clockwise or anticlockwise.




PROGRAM

This program first configures the ARM Port1 as a GPIO and also as an out port. The sequence
code is sent to the driver IC using these port pins. A suitable delay is incorporated between each
step rotation. By applying the code in the reverse order, the stepper motor can be rotated in the
anticlockwise direction.

# include <LPC214X.H>                // LPC2148 HEADER

void delay_ms()                  ; // Delay function

void main()                      ; // Main program starts

{

PINSEL2 = 0X00000000;              // Set P1.19 TO P1.22 as GPIO

IO1DIR=0x000000F0 ;               // Set Port 1 as out port


6
Dr.Y.NARASIMHA MURTHY Ph.D
                                                                       yayavaram@yahoo.com


while(1)                          // Infinite Loop

{

IO1PIN = 0X00000090;                // Send the code1 for phase 1

delay_ms() ;                       // Call Delay

IO0PIN = 0X00000050 ;              // Send the code 2 for phase 2

delay_ms()                ;     // Call Delay

IO1PIN = 0X00000060 ;            // Send the code 3 for phase 3

delay_ms()                ;    // Call Delay


IO1PIN = 0X000000A0 ;           // Send the code 3 for phase 3

delay_ms()            ;         // Call Delay
}
}
void delay_ms()               // Delay function program
{
int i,j     ;

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

for (j=0;j<750;j++) ;

}

4. INTERFACING OF DAC-ARM LPC2148

A digital-to-analog converter is a device for converting a digital signal into to an analog signal
(current or voltage ). Digital-to-Analog Converters are the interface between the abstract digital
world and the analog real world. Simple switches, a network of resistors, current sources or
capacitors may be used to implement this conversion. A DAC inputs a binary number and
outputs an analog voltage or current signal.


The Microchip Technology Inc. MCP4921 is 2.7 – 5.5V, low-power, 12-Bit Digital-to-Analog
Converter (DAC) with SPI interface. The MCP4921 DACt provides high accuracy and low


7
Dr.Y.NARASIMHA MURTHY Ph.D
                                                                       yayavaram@yahoo.com


noise performance for industrial applications where calibration or compensation of signals is
required.
With an SPI connection there is always one master device (usually a microcontroller) which
controls the peripheral devices. Typically there are three lines common to all the devices,


Master In Slave Out (MISO) - The Slave line for sending data to the master,
Master Out Slave In (MOSI) - The Master line for sending data to the peripherals,
Serial Clock (SCK) -      The clock pulses which synchronize data transmission generated by the
master, and
Slave Select pin - the pin on each device that the master can use to enable and disable specific
devices.
When a device's Slave Select pin is low, it communicates with the master. When it's high, it
ignores the master. In SPI, the clock signal is controlled by the master device LPC2148 . All
data is clocked in and out using this pin. These lines need to be connected to the relevant pins on
the LPC21xx processor. Any unused GIO pin can be used for CS, instead pull this pin high.
Conversion speed is the time it takes for the DAC to provide an analog output when the digital
input word is changed.    The MCP4291 DAC - SPI connections with LPC21xx have four I/O
lines (P0.4 – P0.7) required. The analog output is generated by using these four lines.




8
Dr.Y.NARASIMHA MURTHY Ph.D
                                                                     yayavaram@yahoo.com



PROGRAM

#include <LPC2148.H>               // 2148 Header
#include "SPIsw.h"

unsigned long DACval, DACreg;
 int main (void)                  // Main program
{
  PINSEL0 = 0 ;                // Port 0 as GPIO
  PINSEL1 = 0x0000 ;           // Port 0 as Outport
  PINSEL2 & = 0x0000000C;
  SPI_ init (&IOPIN0,29/*CS*/, 5/*MISO*/, 6/*MOSI*/, 4/*SCK*/, 0/*CPOL*/, 0/*CPHA*/) ;
                                                                   // Set output voltage

    DAC val = 2047                ;     // Range [0..4095]
    DAC reg = DACval | 0x7000      ;
    SPI_enable ()                   ;  // Enable SPI port
    SPI_char ((DACreg >> 8) & 0x00FF);
    SPI_char (DACreg & 0x00FF)     ;
    SPI_disable ()                   ;  // Disable SPI port

    while (1)              ;           // Infinite Loop
}




5. INTERFACING ADC –LPC2148

LPC2148 controller has two on n-chip ADCs. In the present program the ADC0 with channel 3
is used and configured to convert the analog input signal into its equivalent digital output.The
configuring of on chip ADC is shown below.




9
Dr.Y.NARASIMHA MURTHY Ph.D
                                                                          yayavaram@yahoo.com




PROGRAM

#include "lpc214x.h"    // This example assumes that PCLK is 12Mhz!

int main(void)
{                        // Initialise ADC 0, Channel 3
adcInit0_3() ;          // Constantly read the results of ADC0.3
 int results = 0;
  while (1)
  {
    results = adcRead0_3();
  }
}                           // Initialise ADC Converter 0, Channel 3
void adcInit0_3(void)
{                            // Force pin 0.30 to function as AD0.3

PCB_PINSEL1 = (PCB_PINSEL1 & ~PCB_PINSEL1_P030_MASK) |

PCB_PINSEL1_P030_AD03;           // Enable power for ADC0

SCB_PCONP |= SCB_PCONP_PCAD0;                    // Initialise ADC converter

AD0_CR = AD_CR_CLKS10                            // 10-bit precision

10
Dr.Y.NARASIMHA MURTHY Ph.D
                                                                    yayavaram@yahoo.com


        | AD_CR_PDN                            // Exit power-down mode
        | ((3 - 1) << AD_CR_CLKDIVSHIFT)       // 4.0MHz Clock (12.0MHz / 3)
        | AD_CR_SEL3;                          // Use channel 3
    }

    int adcRead0_3(void)                   // Read the current value of ADC0.3


    AD0_CR &= ~(AD_CR_START_MASK | AD_CR_SELMASK);                   // Deselect all channels
                                                                    and stop all conversions

{

AD0_CR |= (AD_CR_START_NONE | AD_CR_SEL3);                                // Select channel 3

AD0_CR |= AD_CR_START_NOW; // Manually start conversions (rather than waiting on
                                                          an external input)


while (!(AD0_DR3 & AD_DR_DONE)) ;                   // Wait for the conversion to complete

    return ((AD0_DR3 & AD_DR_RESULTMASK) >> AD_DR_RESULTSHIFT);
                                                   // Return the processed results

}


6 . INTERFACING A SEVEN SEGMENT DISPLAY–LPC21XX


A seven segment display can be used to interface with LPC21XX microcontroller using the
GPIO lines. By using one seven segment display module along with LPC21XX ,a Hex counter
which counts 0 to F can be designed. By interfacing two Seven segment displays, a Hex counter
which counts 00 to FF can be designed. The LSB segment is interfaced to Port1 GPIO
lines(P1.16 to P1.22) and MSB module is interfaced to Port0 GPIO lines(Port0.16 to Port0.22) as
shown in the circuit diagram.




11
Dr.Y.NARASIMHA MURTHY Ph.D
                                                                    yayavaram@yahoo.com




PROGRAM

#include<lpc21xx.h>

unsigned char seg[16] ={0x40,0x79,0x24,0x30,0x19,0x12,0x02,0x78,0x00,0x10,0x08,

0x03,0x46,0x21,0x06,0x0e};

unsigned char seg_val,seg_val1;

unsigned char count,count1;

unsigned long int var,var1;

void main(void)

{    unsigned long int k;

     PINSEL0=0X00000000;          // Select Port 0 pins as GPIO lines


12
Dr.Y.NARASIMHA MURTHY Ph.D
                                                                        yayavaram@yahoo.com


     PINSEL1=0X00000000;             // Select Port 1 pins as GPIO lines

     IODIR0 = 0X00FF0000;          // Configure the required pins of Port 0 as output pins

     IODIR1 = 0X00FF0000;          // Configure the required pins of Port 1 as output pins

 for (count=0;count<=15;count++)              // COUNT FOR MSB

         {      IOCLR1 = var;

                seg_val = seg[count];

                var = seg_val;

                var = var<<16;

                IOSET1 = var;

             for(count1=0;count1<=15;count1++)                 // COUNT FOR LSB

                    {       IOCLR0=var1;

                            seg_val1=seg[count1];

                            var1=seg_val1;

                            var1=var1<<16;

                            IOSET0=var1;

                            for(k=0;k<50000;k++);

                            }                     // End for loop

                                 }                     // End for loop

                                        }                 // End main.




13
Dr.Y.NARASIMHA MURTHY Ph.D
                                                                     yayavaram@yahoo.com


7 . INTERFACING OF 2X16 LCD MODULE - LPC21XX
The ARM7 LPC21xx processor is interfaced to the 2x16 LCD mpdule in 4-bit mode .The
interfcae diagram is shown below.The four data pins are connected with 4 data bits (P0.19 –
P0.22 pins to bits D4-D7), address bit (RS-P0.16), read/write bit (R/W-P0.17) and control
signal (E-P0.18) to make LCD display complete.The pins D0,D1,D2,D3 are left free with out
any connections.

16X 2 LCD is a 16 pin module . In which pins 1 &16 are grounded, 2 &15 are given to V CC
and 3rd pin is given to potentiometer in order adjust the contrast of LCD. Pins 4, 5 & 6
corresponds to RS, R/W & EN respectively. Pins 7 to 14 are data lines from D0 to D7
respectively. Here the LCD is used in 4 bit mode i.e. upper 4 bits are used to transfer the data
with MSB first and LSB next. Port 0 pins i.e. from P0.16 to P0.22 are used for both data and
control signals. The interfacing diagram of 16X2 LCD is shown below.




PROGRAM

#include <LPC21xx.H>
long unsigned int data,temp1,temp2;
unsigned char *ptr,data_array[] = "SSBN DEGREE & PG COLLEGE, ATP";
void main()
{
       int i=0;

14
Dr.Y.NARASIMHA MURTHY Ph.D
                                                                       yayavaram@yahoo.com


       PINSEL0 = 0x00000000;          // Select Port 0 pins as GPIO lines
       IODIR0 = 0x00ff0000;          // Configure the required pins of Port 0 as output pins
       lcd_init();                   // LCD initialization
       delay(2500);                  // Delay
       ret_home();                   // Cursor to return home
       delay(2500);                  // Delay
       clr_disp();                   // Clear display
       delay(2500);                  // Delay
       ptr = &data_array[0];
       for(i=1;i<sizeof(data_array);i++)
       {
           if(i == 17)
                { temp1 = 0xc0;      // Goto 2nd line in the LCD
                   lcd_com();        // Byte to nibble conversion of LCD command
                   delay(800);
                }                    // End if
               data = *ptr;
               lcd_data();            // Byte to nibble conversion of LCD data
               ptr++;
       }                              // End for loop
}                                     // End main
void lcd_init(void)                   // Initialization of LCD
{
                temp2=0x30;            // Assign command to temp2
                temp2=temp2<<16;       // Shift the data by 16 bits left
                cmd_wrt();             // Command write subroutine
                delay(800);           // Delay
                temp2=0x30;            // Assign command to temp2
                temp2=temp2<<16;       // Shift the data by 16 bits left
                cmd_wrt();             // Command write subroutine
                delay(800);            // Delay
                temp2=0x30;            // Assign command to temp2
                temp2=temp2<<16;       // Shift the data by 16 bits left
                cmd_wrt();             // Command write subroutine
                delay(800);            // Delay
                temp2=0x30;            // Assign command to temp2
                temp2=temp2<<16;       // Shift the data by 16 bits left
                cmd_wrt();             // Command write subroutine
                delay(800);            // Delay
                temp2=0x20;            // Assign command to temp2
                temp2=temp2<<16;       // Shift the data by 16 bits left
                cmd_wrt();             // Command write subroutine
                delay(800);            // Delay
                temp1 = 0x28;          // Command for LCD to function in 4 bit mode
                lcd_com();
                delay(800);

15
Dr.Y.NARASIMHA MURTHY Ph.D
                                                                   yayavaram@yahoo.com


              temp1 = 0x0c;         // Command for display on, cursor off
              lcd_com();
              delay(800);
              temp1 = 0x06;         // Command for cursor increment
              lcd_com();
              delay(500);
              temp1 = 0x80;         // Command to force the cursor to beginning of 1st line
              lcd_com();
              delay(800);
 }
void delay(unsigned int j)        // Delay subroutine
{              unsigned int k;
               for(k=0;k<j;k++);
}
void clr_disp(void)                // To clear LCD display
{              temp1 = 0x01;
               lcd_com();
               delay(320);
}
void ret_home(void)                // To return home
{              temp1 = 0x02;
               lcd_com();
               delay(320);
}
void lcd_com(void)               // Byte to nibble conversion of LCD command
{              temp2= temp1 & 0x00f0;
               temp2=temp2<<16;
               cmd_wrt();
               temp2 = temp1 & 0x000f;
               temp2 = temp2 << 20;
               cmd_wrt();
}


                        -------------------xxxxxxx-------------
Acknowledgment: I thank all the people without whose contribution ,this class notes would
have not been possible ,especially Pantech Solutions website .




16

More Related Content

What's hot

Interfacing adc
Interfacing adcInterfacing adc
Interfacing adc
PRADEEP
 
Memory organization of 8051
Memory organization of 8051Memory organization of 8051
Memory organization of 8051
Muthu Manickam
 

What's hot (20)

ARM Processor
ARM ProcessorARM Processor
ARM Processor
 
Introduction to ARM LPC2148
Introduction to ARM LPC2148Introduction to ARM LPC2148
Introduction to ARM LPC2148
 
AVR ATmega32
AVR ATmega32AVR ATmega32
AVR ATmega32
 
ARM7-ARCHITECTURE
ARM7-ARCHITECTURE ARM7-ARCHITECTURE
ARM7-ARCHITECTURE
 
STM32 MCU Family
STM32 MCU FamilySTM32 MCU Family
STM32 MCU Family
 
Embedded C programming based on 8051 microcontroller
Embedded C programming based on 8051 microcontrollerEmbedded C programming based on 8051 microcontroller
Embedded C programming based on 8051 microcontroller
 
ARM Exception and interrupts
ARM Exception and interrupts ARM Exception and interrupts
ARM Exception and interrupts
 
Interrupts in pic
Interrupts in picInterrupts in pic
Interrupts in pic
 
Digital electronics logic families
Digital electronics logic familiesDigital electronics logic families
Digital electronics logic families
 
ATmega32-AVR microcontrollers-Part I
ATmega32-AVR microcontrollers-Part IATmega32-AVR microcontrollers-Part I
ATmega32-AVR microcontrollers-Part I
 
8051 MICROCONTROLLER ARCHITECTURE.pptx
 8051 MICROCONTROLLER ARCHITECTURE.pptx 8051 MICROCONTROLLER ARCHITECTURE.pptx
8051 MICROCONTROLLER ARCHITECTURE.pptx
 
TMS320C6X Architecture
TMS320C6X ArchitectureTMS320C6X Architecture
TMS320C6X Architecture
 
Study on 32-bit Cortex - M3 Powered MCU: STM32F101
Study on 32-bit Cortex - M3 Powered MCU: STM32F101Study on 32-bit Cortex - M3 Powered MCU: STM32F101
Study on 32-bit Cortex - M3 Powered MCU: STM32F101
 
Interfacing adc
Interfacing adcInterfacing adc
Interfacing adc
 
Memory organization of 8051
Memory organization of 8051Memory organization of 8051
Memory organization of 8051
 
Addressing modes of 8086
Addressing modes of 8086Addressing modes of 8086
Addressing modes of 8086
 
Pic 18 microcontroller
Pic 18 microcontrollerPic 18 microcontroller
Pic 18 microcontroller
 
Logic families
Logic  familiesLogic  families
Logic families
 
Msp 430 architecture module 1
Msp 430 architecture module 1Msp 430 architecture module 1
Msp 430 architecture module 1
 
Embedded System Basics
Embedded System BasicsEmbedded System Basics
Embedded System Basics
 

Viewers also liked

ARM 7 LPC 2148 lecture
ARM 7 LPC 2148 lectureARM 7 LPC 2148 lecture
ARM 7 LPC 2148 lecture
anishgoel
 
Programming The Arm Microprocessor For Embedded Systems
Programming The Arm Microprocessor For Embedded SystemsProgramming The Arm Microprocessor For Embedded Systems
Programming The Arm Microprocessor For Embedded Systems
joshparrish13
 
Implementation of-graphical-lcd-interface-using-arm7 tdmi-processor-based-mic...
Implementation of-graphical-lcd-interface-using-arm7 tdmi-processor-based-mic...Implementation of-graphical-lcd-interface-using-arm7 tdmi-processor-based-mic...
Implementation of-graphical-lcd-interface-using-arm7 tdmi-processor-based-mic...
Prakash Rajaiya
 
Assignment of pseudo code
Assignment of pseudo codeAssignment of pseudo code
Assignment of pseudo code
Burhan Chaudhry
 

Viewers also liked (20)

ARM lab programs
ARM  lab programs  ARM  lab programs
ARM lab programs
 
Unit III ARM Interface and ARM Programming
Unit III ARM Interface and ARM Programming Unit III ARM Interface and ARM Programming
Unit III ARM Interface and ARM Programming
 
ARM 7 LPC 2148 lecture
ARM 7 LPC 2148 lectureARM 7 LPC 2148 lecture
ARM 7 LPC 2148 lecture
 
Programming The Arm Microprocessor For Embedded Systems
Programming The Arm Microprocessor For Embedded SystemsProgramming The Arm Microprocessor For Embedded Systems
Programming The Arm Microprocessor For Embedded Systems
 
Ppt
PptPpt
Ppt
 
Timer counter in arm7(lpc2148)
Timer counter in arm7(lpc2148)Timer counter in arm7(lpc2148)
Timer counter in arm7(lpc2148)
 
Arm cortex ( lpc 2148 ) based motor speed control
Arm cortex ( lpc 2148 ) based motor speed control Arm cortex ( lpc 2148 ) based motor speed control
Arm cortex ( lpc 2148 ) based motor speed control
 
Sensors-Interfacing Techniques
Sensors-Interfacing TechniquesSensors-Interfacing Techniques
Sensors-Interfacing Techniques
 
ARM Processor Tutorial
ARM Processor Tutorial ARM Processor Tutorial
ARM Processor Tutorial
 
Rfid interface with lpc2148
Rfid interface with lpc2148 Rfid interface with lpc2148
Rfid interface with lpc2148
 
Arm architecture
Arm architectureArm architecture
Arm architecture
 
SPI Protocol in LPC2148
SPI  Protocol in LPC2148SPI  Protocol in LPC2148
SPI Protocol in LPC2148
 
Zigbee module interface with ARM 7
Zigbee module interface with ARM 7Zigbee module interface with ARM 7
Zigbee module interface with ARM 7
 
Embedded system for traffic light control
Embedded system for traffic light controlEmbedded system for traffic light control
Embedded system for traffic light control
 
Smart Prepaid Energy Meter using ARM7 & and GSM
Smart Prepaid Energy Meter using ARM7 & and GSMSmart Prepaid Energy Meter using ARM7 & and GSM
Smart Prepaid Energy Meter using ARM7 & and GSM
 
HAND GESTURE CONTROLLED WHEEL CHAIR
HAND GESTURE CONTROLLED WHEEL CHAIRHAND GESTURE CONTROLLED WHEEL CHAIR
HAND GESTURE CONTROLLED WHEEL CHAIR
 
Implementation of-graphical-lcd-interface-using-arm7 tdmi-processor-based-mic...
Implementation of-graphical-lcd-interface-using-arm7 tdmi-processor-based-mic...Implementation of-graphical-lcd-interface-using-arm7 tdmi-processor-based-mic...
Implementation of-graphical-lcd-interface-using-arm7 tdmi-processor-based-mic...
 
EMBEDDED PROJECTS BASED COMPONANTS
 EMBEDDED PROJECTS BASED COMPONANTS EMBEDDED PROJECTS BASED COMPONANTS
EMBEDDED PROJECTS BASED COMPONANTS
 
Unit ii arm7 thumb
Unit ii arm7 thumbUnit ii arm7 thumb
Unit ii arm7 thumb
 
Assignment of pseudo code
Assignment of pseudo codeAssignment of pseudo code
Assignment of pseudo code
 

Similar to Arm7 Interfacing examples

HOME AUTOMATION USING MOBILE PHONES GIRISH HARMUKH AND NEERAJ YADAV
HOME AUTOMATION USING MOBILE PHONES GIRISH HARMUKH AND NEERAJ YADAVHOME AUTOMATION USING MOBILE PHONES GIRISH HARMUKH AND NEERAJ YADAV
HOME AUTOMATION USING MOBILE PHONES GIRISH HARMUKH AND NEERAJ YADAV
GIRISH HARMUKH
 
digitalelectronicslogicfamilies-190628101225-converted.pptx
digitalelectronicslogicfamilies-190628101225-converted.pptxdigitalelectronicslogicfamilies-190628101225-converted.pptx
digitalelectronicslogicfamilies-190628101225-converted.pptx
BijaySharma51
 

Similar to Arm7 Interfacing examples (20)

8051 MMD Chapter 1.ppt
8051 MMD Chapter 1.ppt8051 MMD Chapter 1.ppt
8051 MMD Chapter 1.ppt
 
Ppt (1)
Ppt (1)Ppt (1)
Ppt (1)
 
Introduction to PIC.pptx
Introduction to PIC.pptxIntroduction to PIC.pptx
Introduction to PIC.pptx
 
Share 'speed control_of_dc_motor_using_microcontroller.pptx'[1][1]
Share 'speed control_of_dc_motor_using_microcontroller.pptx'[1][1]Share 'speed control_of_dc_motor_using_microcontroller.pptx'[1][1]
Share 'speed control_of_dc_motor_using_microcontroller.pptx'[1][1]
 
Industrial training presentation
Industrial training presentationIndustrial training presentation
Industrial training presentation
 
HOME AUTOMATION USING MOBILE PHONES GIRISH HARMUKH AND NEERAJ YADAV
HOME AUTOMATION USING MOBILE PHONES GIRISH HARMUKH AND NEERAJ YADAVHOME AUTOMATION USING MOBILE PHONES GIRISH HARMUKH AND NEERAJ YADAV
HOME AUTOMATION USING MOBILE PHONES GIRISH HARMUKH AND NEERAJ YADAV
 
digitalelectronicslogicfamilies-190628101225-converted.pptx
digitalelectronicslogicfamilies-190628101225-converted.pptxdigitalelectronicslogicfamilies-190628101225-converted.pptx
digitalelectronicslogicfamilies-190628101225-converted.pptx
 
Bluetooth based home appliances control
Bluetooth based home appliances controlBluetooth based home appliances control
Bluetooth based home appliances control
 
Arduino windows remote control
Arduino windows remote controlArduino windows remote control
Arduino windows remote control
 
TV Remote Operated Domestic Appliances Control
TV Remote Operated Domestic Appliances ControlTV Remote Operated Domestic Appliances Control
TV Remote Operated Domestic Appliances Control
 
Study of Data sheet of 56824 DSP processors
Study of Data sheet of 56824 DSP processorsStudy of Data sheet of 56824 DSP processors
Study of Data sheet of 56824 DSP processors
 
ELECTRONICS PROJECT REPORT OF HOME AUTOMATION CUM BUILDING SECUIRITY
ELECTRONICS PROJECT REPORT OF HOME AUTOMATION CUM BUILDING SECUIRITYELECTRONICS PROJECT REPORT OF HOME AUTOMATION CUM BUILDING SECUIRITY
ELECTRONICS PROJECT REPORT OF HOME AUTOMATION CUM BUILDING SECUIRITY
 
Remotely Secured Device Automation using Infrared
Remotely Secured Device Automation using InfraredRemotely Secured Device Automation using Infrared
Remotely Secured Device Automation using Infrared
 
Hardware View of Intel 8051
Hardware View of Intel 8051Hardware View of Intel 8051
Hardware View of Intel 8051
 
AUTOMATIC GRID ON SENSING BAD VOLTAGE OR FREQUENCY
AUTOMATIC GRID ON SENSING BAD VOLTAGE OR FREQUENCYAUTOMATIC GRID ON SENSING BAD VOLTAGE OR FREQUENCY
AUTOMATIC GRID ON SENSING BAD VOLTAGE OR FREQUENCY
 
File 1389427052
File 1389427052File 1389427052
File 1389427052
 
Speed checker on highway using 8051
Speed checker on highway using 8051Speed checker on highway using 8051
Speed checker on highway using 8051
 
Pin diagram 8085 microprocessor(For College Seminars)
Pin diagram 8085 microprocessor(For College Seminars)Pin diagram 8085 microprocessor(For College Seminars)
Pin diagram 8085 microprocessor(For College Seminars)
 
Vlsi es-lab-manual
Vlsi es-lab-manualVlsi es-lab-manual
Vlsi es-lab-manual
 
Live B tech Projects & Industrial Training @Technogroovy
Live B tech Projects & Industrial Training @Technogroovy Live B tech Projects & Industrial Training @Technogroovy
Live B tech Projects & Industrial Training @Technogroovy
 

More from Dr.YNM

More from Dr.YNM (20)

Introduction to DSP.ppt
Introduction to DSP.pptIntroduction to DSP.ppt
Introduction to DSP.ppt
 
Atmel.ppt
Atmel.pptAtmel.ppt
Atmel.ppt
 
PIC Microcontrollers.ppt
PIC Microcontrollers.pptPIC Microcontrollers.ppt
PIC Microcontrollers.ppt
 
Crystalstructure-.ppt
Crystalstructure-.pptCrystalstructure-.ppt
Crystalstructure-.ppt
 
Basics of OS & RTOS.ppt
Basics of OS & RTOS.pptBasics of OS & RTOS.ppt
Basics of OS & RTOS.ppt
 
Introducion to MSP430 Microcontroller.pptx
Introducion to MSP430 Microcontroller.pptxIntroducion to MSP430 Microcontroller.pptx
Introducion to MSP430 Microcontroller.pptx
 
Microcontroller-8051.ppt
Microcontroller-8051.pptMicrocontroller-8051.ppt
Microcontroller-8051.ppt
 
Introduction to ASICs.pptx
Introduction to ASICs.pptxIntroduction to ASICs.pptx
Introduction to ASICs.pptx
 
VHDL-PRESENTATION.ppt
VHDL-PRESENTATION.pptVHDL-PRESENTATION.ppt
VHDL-PRESENTATION.ppt
 
Basics of data communications.pptx
Basics of data communications.pptxBasics of data communications.pptx
Basics of data communications.pptx
 
CPLD & FPGA Architectures and applictionsplications.pptx
CPLD & FPGA Architectures and applictionsplications.pptxCPLD & FPGA Architectures and applictionsplications.pptx
CPLD & FPGA Architectures and applictionsplications.pptx
 
Transient response of RC , RL circuits with step input
Transient response of RC , RL circuits  with step inputTransient response of RC , RL circuits  with step input
Transient response of RC , RL circuits with step input
 
CISC & RISC ARCHITECTURES
CISC & RISC ARCHITECTURESCISC & RISC ARCHITECTURES
CISC & RISC ARCHITECTURES
 
Lect 4 ARM PROCESSOR ARCHITECTURE
Lect 4 ARM PROCESSOR ARCHITECTURELect 4 ARM PROCESSOR ARCHITECTURE
Lect 4 ARM PROCESSOR ARCHITECTURE
 
Lect 3 ARM PROCESSOR ARCHITECTURE
Lect 3  ARM PROCESSOR ARCHITECTURE Lect 3  ARM PROCESSOR ARCHITECTURE
Lect 3 ARM PROCESSOR ARCHITECTURE
 
Microprocessor Architecture 4
Microprocessor Architecture  4Microprocessor Architecture  4
Microprocessor Architecture 4
 
Lect 2 ARM processor architecture
Lect 2 ARM processor architectureLect 2 ARM processor architecture
Lect 2 ARM processor architecture
 
Microprocessor Architecture-III
Microprocessor Architecture-IIIMicroprocessor Architecture-III
Microprocessor Architecture-III
 
LECT 1: ARM PROCESSORS
LECT 1: ARM PROCESSORSLECT 1: ARM PROCESSORS
LECT 1: ARM PROCESSORS
 
Microprocessor architecture II
Microprocessor architecture   IIMicroprocessor architecture   II
Microprocessor architecture II
 

Recently uploaded

Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...
Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...
Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...
amitlee9823
 
The Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai Kuwait
The Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai KuwaitThe Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai Kuwait
The Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai Kuwait
daisycvs
 
Call Girls In Nangloi Rly Metro ꧂…….95996 … 13876 Enjoy ꧂Escort
Call Girls In Nangloi Rly Metro ꧂…….95996 … 13876 Enjoy ꧂EscortCall Girls In Nangloi Rly Metro ꧂…….95996 … 13876 Enjoy ꧂Escort
Call Girls In Nangloi Rly Metro ꧂…….95996 … 13876 Enjoy ꧂Escort
dlhescort
 
Russian Call Girls In Rajiv Chowk Gurgaon ❤️8448577510 ⊹Best Escorts Service ...
Russian Call Girls In Rajiv Chowk Gurgaon ❤️8448577510 ⊹Best Escorts Service ...Russian Call Girls In Rajiv Chowk Gurgaon ❤️8448577510 ⊹Best Escorts Service ...
Russian Call Girls In Rajiv Chowk Gurgaon ❤️8448577510 ⊹Best Escorts Service ...
lizamodels9
 
Call Girls In Noida 959961⊹3876 Independent Escort Service Noida
Call Girls In Noida 959961⊹3876 Independent Escort Service NoidaCall Girls In Noida 959961⊹3876 Independent Escort Service Noida
Call Girls In Noida 959961⊹3876 Independent Escort Service Noida
dlhescort
 
unwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabi
unwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabiunwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabi
unwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabi
Abortion pills in Kuwait Cytotec pills in Kuwait
 

Recently uploaded (20)

How to Get Started in Social Media for Art League City
How to Get Started in Social Media for Art League CityHow to Get Started in Social Media for Art League City
How to Get Started in Social Media for Art League City
 
Lundin Gold - Q1 2024 Conference Call Presentation (Revised)
Lundin Gold - Q1 2024 Conference Call Presentation (Revised)Lundin Gold - Q1 2024 Conference Call Presentation (Revised)
Lundin Gold - Q1 2024 Conference Call Presentation (Revised)
 
Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...
Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...
Call Girls Electronic City Just Call 👗 7737669865 👗 Top Class Call Girl Servi...
 
Value Proposition canvas- Customer needs and pains
Value Proposition canvas- Customer needs and painsValue Proposition canvas- Customer needs and pains
Value Proposition canvas- Customer needs and pains
 
The Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai Kuwait
The Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai KuwaitThe Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai Kuwait
The Abortion pills for sale in Qatar@Doha [+27737758557] []Deira Dubai Kuwait
 
Falcon Invoice Discounting: Unlock Your Business Potential
Falcon Invoice Discounting: Unlock Your Business PotentialFalcon Invoice Discounting: Unlock Your Business Potential
Falcon Invoice Discounting: Unlock Your Business Potential
 
Falcon Invoice Discounting platform in india
Falcon Invoice Discounting platform in indiaFalcon Invoice Discounting platform in india
Falcon Invoice Discounting platform in india
 
Call Girls In Nangloi Rly Metro ꧂…….95996 … 13876 Enjoy ꧂Escort
Call Girls In Nangloi Rly Metro ꧂…….95996 … 13876 Enjoy ꧂EscortCall Girls In Nangloi Rly Metro ꧂…….95996 … 13876 Enjoy ꧂Escort
Call Girls In Nangloi Rly Metro ꧂…….95996 … 13876 Enjoy ꧂Escort
 
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
 
Unveiling Falcon Invoice Discounting: Leading the Way as India's Premier Bill...
Unveiling Falcon Invoice Discounting: Leading the Way as India's Premier Bill...Unveiling Falcon Invoice Discounting: Leading the Way as India's Premier Bill...
Unveiling Falcon Invoice Discounting: Leading the Way as India's Premier Bill...
 
Russian Call Girls In Rajiv Chowk Gurgaon ❤️8448577510 ⊹Best Escorts Service ...
Russian Call Girls In Rajiv Chowk Gurgaon ❤️8448577510 ⊹Best Escorts Service ...Russian Call Girls In Rajiv Chowk Gurgaon ❤️8448577510 ⊹Best Escorts Service ...
Russian Call Girls In Rajiv Chowk Gurgaon ❤️8448577510 ⊹Best Escorts Service ...
 
Call Girls In Noida 959961⊹3876 Independent Escort Service Noida
Call Girls In Noida 959961⊹3876 Independent Escort Service NoidaCall Girls In Noida 959961⊹3876 Independent Escort Service Noida
Call Girls In Noida 959961⊹3876 Independent Escort Service Noida
 
Cracking the Cultural Competence Code.pptx
Cracking the Cultural Competence Code.pptxCracking the Cultural Competence Code.pptx
Cracking the Cultural Competence Code.pptx
 
Phases of Negotiation .pptx
 Phases of Negotiation .pptx Phases of Negotiation .pptx
Phases of Negotiation .pptx
 
unwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabi
unwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabiunwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabi
unwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabi
 
Organizational Transformation Lead with Culture
Organizational Transformation Lead with CultureOrganizational Transformation Lead with Culture
Organizational Transformation Lead with Culture
 
Malegaon Call Girls Service ☎ ️82500–77686 ☎️ Enjoy 24/7 Escort Service
Malegaon Call Girls Service ☎ ️82500–77686 ☎️ Enjoy 24/7 Escort ServiceMalegaon Call Girls Service ☎ ️82500–77686 ☎️ Enjoy 24/7 Escort Service
Malegaon Call Girls Service ☎ ️82500–77686 ☎️ Enjoy 24/7 Escort Service
 
Falcon's Invoice Discounting: Your Path to Prosperity
Falcon's Invoice Discounting: Your Path to ProsperityFalcon's Invoice Discounting: Your Path to Prosperity
Falcon's Invoice Discounting: Your Path to Prosperity
 
(Anamika) VIP Call Girls Napur Call Now 8617697112 Napur Escorts 24x7
(Anamika) VIP Call Girls Napur Call Now 8617697112 Napur Escorts 24x7(Anamika) VIP Call Girls Napur Call Now 8617697112 Napur Escorts 24x7
(Anamika) VIP Call Girls Napur Call Now 8617697112 Napur Escorts 24x7
 
Call Girls Zirakpur👧 Book Now📱7837612180 📞👉Call Girl Service In Zirakpur No A...
Call Girls Zirakpur👧 Book Now📱7837612180 📞👉Call Girl Service In Zirakpur No A...Call Girls Zirakpur👧 Book Now📱7837612180 📞👉Call Girl Service In Zirakpur No A...
Call Girls Zirakpur👧 Book Now📱7837612180 📞👉Call Girl Service In Zirakpur No A...
 

Arm7 Interfacing examples

  • 1. Dr.Y.NARASIMHA MURTHY Ph.D yayavaram@yahoo.com ARM LPC 21XX INTEFACING EXAMPLES 1.INTERFACING LEDs TO ARM 7 CONTROLLER- (LPC2148 ) Light Emitting Diodes (LEDs) are popularly used display components used to indicate the ON and OFF state of a system. These are also used to realize various counters like binary counters experimentally. These LEDs can be easily interfaced with the Port pins of any Microcontroller by using current limiting resistors of the order of 220 Ohms. The diagram below shows the interfacing of LED array to the Port1 pins of LPC2148 ARM 7 microcontroller. 1
  • 2. Dr.Y.NARASIMHA MURTHY Ph.D yayavaram@yahoo.com PROGRAM -1 This program blinks the LEDs continuously with a small delay. The LEDs are connected to the Port1 pins P1.24 to P1.31 and the these pins are configured as General Purpose output pins. #include<lpc2148.H> //LPC2148 Header void delay() { for(int i=0x00;i<=0xff;i++) for(int j=0x00;j<=0xFf;j++) ; // Delay program } void main() { PINSEL2 = 0X00000000; // Set P1.24 TO P1.31 as GPIO IO1DIR = 0XFF000000; //Port pins P1.24 to P 1.31 Configured as Output port. while(1) //Infinite loop { IO1SET=0XFF000000; // Pins P1.24 to P1.31 goes to high state delay(); IO1CLR=0XFF000000; // Pins P1.24 to P1.31 goes to low state delay() ; } } PROGRAM – 2 This program glows LEDs alternately by sending 55H and AAH through the port1 Pins. # include <LPC214X.H> //LPC2148 HEADER void delay(void) // Delay Program { unsigned int i; i=0xffffff; while(i--); } int main(void) { PINSEL2=0x0000; // Port 1 is I/O IODIR1 = 0XFF <<24 ; // Port Pins P1.24 to P1.31 as Output Pins 2
  • 3. Dr.Y.NARASIMHA MURTHY Ph.D yayavaram@yahoo.com while(1) // Infinite loop { IOSET1=0X55<<25 ; // P1.25,P1.27,P1.29 & P1.31 LEDs will Glow delay() ; // Call delay function IOCLR1= 0X55 <<25 ; // P1.25,P1.27,P1.29 &P1.31 LEDs will be off IOSET1=0XAA<<24 ; //P1.24,P1.26,P1.28 &P1.30 LEDs are Glow delay () ; // Call delay function IOCLR1=0XAA<<24 ; // P1.24,P1.26,P1.28 &P1.30 LEDs are off } } 2.INTERFACING A RELAY TO ARM 7 CONTROLLER- (LPC2148 ) Relays are devices which allow low power circuits to switch a relatively high Current/ Voltage ON/OFF. A relay circuit is typically a smaller switch or device which drives (opens/closes) an electric switch that is capable of carrying much larger current amounts. Figure below shows the interfacing of the Relay to ARM controller. When the input is energized, the relay turns on and the '+' output is connected to +12v. When the relay is off, the '+' output is connected to Ground. The '-' output is permanently wired to Ground. The relay is interfaced to P0.30 Pin through an Opto-isolator. This opto-isolator protects the port pin from damage due to any high currents .The opto-isolator consists of a pair of an LED and a Photo transistor as shown in the diagram. The power transistor is used at the input. So, when the input is high , the output of the transistor is LOW and the relay is in OFF state .Similarly when we apply a low to the transistor ,the out put is high and the relay is ON. 3
  • 4. Dr.Y.NARASIMHA MURTHY Ph.D yayavaram@yahoo.com Interfacing Circuit. PROGRAM The following program configures the P0.30 pin as an out port. When a low signal is sent through this pin to the relay the relay is switched ON and when a high signal is sent the relay is 4
  • 5. Dr.Y.NARASIMHA MURTHY Ph.D yayavaram@yahoo.com switched OFF.A constant delay is created between the two events and hence the relay switches ON and OFF in regular intervals of time. # include <LPC214X.H> //LPC2148 HEADER # define relay 1<<30 // ASSIGN P0.30 Pin to RELAY input PIN void DELAY(void) // Delay function { unsigned int i; i=0xffffff; while(i--) ; } int main(void) // Main program { IODIR0=1<<30 ; // P0.30 Port Pin as Outport while(1) //INFINITE LOOP { IOSET0=1<<30 ; //SWITCH OFF RELAY DELAY() ; //CALL DELAY IOCLR0=1<<30 ; // SWITCH ON RELAY DELAY() ; // CALL DELAY } // REPEAT LOOP } 5
  • 6. Dr.Y.NARASIMHA MURTHY Ph.D yayavaram@yahoo.com 3. INTERFACING A STEPPER MOTOR TO ARM 7 CONTROLLER- (LPC2148 ) A stepper motor is a brushless, synchronous electric motor that converts digital pulses into mechanical rotation in steps. Every revolution of the stepper motor is divided into a discrete number of steps, and for each pulse it receives the motor rotates through one step. Fig below shows the interface of the Stepper Motor to ARM 7 controller. The stepper motor is connected to Microcontroller using a ULN2003 driver IC. The ULN driver IC is connected to the Port1 pins P1.19 to P1.22 pins. So as the microcontroller gives pulses with a particular frequency to ULN2003, the motor is rotated either in clockwise or anticlockwise. PROGRAM This program first configures the ARM Port1 as a GPIO and also as an out port. The sequence code is sent to the driver IC using these port pins. A suitable delay is incorporated between each step rotation. By applying the code in the reverse order, the stepper motor can be rotated in the anticlockwise direction. # include <LPC214X.H> // LPC2148 HEADER void delay_ms() ; // Delay function void main() ; // Main program starts { PINSEL2 = 0X00000000; // Set P1.19 TO P1.22 as GPIO IO1DIR=0x000000F0 ; // Set Port 1 as out port 6
  • 7. Dr.Y.NARASIMHA MURTHY Ph.D yayavaram@yahoo.com while(1) // Infinite Loop { IO1PIN = 0X00000090; // Send the code1 for phase 1 delay_ms() ; // Call Delay IO0PIN = 0X00000050 ; // Send the code 2 for phase 2 delay_ms() ; // Call Delay IO1PIN = 0X00000060 ; // Send the code 3 for phase 3 delay_ms() ; // Call Delay IO1PIN = 0X000000A0 ; // Send the code 3 for phase 3 delay_ms() ; // Call Delay } } void delay_ms() // Delay function program { int i,j ; for(i=0;i<0x0a;i++) for (j=0;j<750;j++) ; } 4. INTERFACING OF DAC-ARM LPC2148 A digital-to-analog converter is a device for converting a digital signal into to an analog signal (current or voltage ). Digital-to-Analog Converters are the interface between the abstract digital world and the analog real world. Simple switches, a network of resistors, current sources or capacitors may be used to implement this conversion. A DAC inputs a binary number and outputs an analog voltage or current signal. The Microchip Technology Inc. MCP4921 is 2.7 – 5.5V, low-power, 12-Bit Digital-to-Analog Converter (DAC) with SPI interface. The MCP4921 DACt provides high accuracy and low 7
  • 8. Dr.Y.NARASIMHA MURTHY Ph.D yayavaram@yahoo.com noise performance for industrial applications where calibration or compensation of signals is required. With an SPI connection there is always one master device (usually a microcontroller) which controls the peripheral devices. Typically there are three lines common to all the devices, Master In Slave Out (MISO) - The Slave line for sending data to the master, Master Out Slave In (MOSI) - The Master line for sending data to the peripherals, Serial Clock (SCK) - The clock pulses which synchronize data transmission generated by the master, and Slave Select pin - the pin on each device that the master can use to enable and disable specific devices. When a device's Slave Select pin is low, it communicates with the master. When it's high, it ignores the master. In SPI, the clock signal is controlled by the master device LPC2148 . All data is clocked in and out using this pin. These lines need to be connected to the relevant pins on the LPC21xx processor. Any unused GIO pin can be used for CS, instead pull this pin high. Conversion speed is the time it takes for the DAC to provide an analog output when the digital input word is changed. The MCP4291 DAC - SPI connections with LPC21xx have four I/O lines (P0.4 – P0.7) required. The analog output is generated by using these four lines. 8
  • 9. Dr.Y.NARASIMHA MURTHY Ph.D yayavaram@yahoo.com PROGRAM #include <LPC2148.H> // 2148 Header #include "SPIsw.h" unsigned long DACval, DACreg; int main (void) // Main program { PINSEL0 = 0 ; // Port 0 as GPIO PINSEL1 = 0x0000 ; // Port 0 as Outport PINSEL2 & = 0x0000000C; SPI_ init (&IOPIN0,29/*CS*/, 5/*MISO*/, 6/*MOSI*/, 4/*SCK*/, 0/*CPOL*/, 0/*CPHA*/) ; // Set output voltage DAC val = 2047 ; // Range [0..4095] DAC reg = DACval | 0x7000 ; SPI_enable () ; // Enable SPI port SPI_char ((DACreg >> 8) & 0x00FF); SPI_char (DACreg & 0x00FF) ; SPI_disable () ; // Disable SPI port while (1) ; // Infinite Loop } 5. INTERFACING ADC –LPC2148 LPC2148 controller has two on n-chip ADCs. In the present program the ADC0 with channel 3 is used and configured to convert the analog input signal into its equivalent digital output.The configuring of on chip ADC is shown below. 9
  • 10. Dr.Y.NARASIMHA MURTHY Ph.D yayavaram@yahoo.com PROGRAM #include "lpc214x.h" // This example assumes that PCLK is 12Mhz! int main(void) { // Initialise ADC 0, Channel 3 adcInit0_3() ; // Constantly read the results of ADC0.3 int results = 0; while (1) { results = adcRead0_3(); } } // Initialise ADC Converter 0, Channel 3 void adcInit0_3(void) { // Force pin 0.30 to function as AD0.3 PCB_PINSEL1 = (PCB_PINSEL1 & ~PCB_PINSEL1_P030_MASK) | PCB_PINSEL1_P030_AD03; // Enable power for ADC0 SCB_PCONP |= SCB_PCONP_PCAD0; // Initialise ADC converter AD0_CR = AD_CR_CLKS10 // 10-bit precision 10
  • 11. Dr.Y.NARASIMHA MURTHY Ph.D yayavaram@yahoo.com | AD_CR_PDN // Exit power-down mode | ((3 - 1) << AD_CR_CLKDIVSHIFT) // 4.0MHz Clock (12.0MHz / 3) | AD_CR_SEL3; // Use channel 3 } int adcRead0_3(void) // Read the current value of ADC0.3 AD0_CR &= ~(AD_CR_START_MASK | AD_CR_SELMASK); // Deselect all channels and stop all conversions { AD0_CR |= (AD_CR_START_NONE | AD_CR_SEL3); // Select channel 3 AD0_CR |= AD_CR_START_NOW; // Manually start conversions (rather than waiting on an external input) while (!(AD0_DR3 & AD_DR_DONE)) ; // Wait for the conversion to complete return ((AD0_DR3 & AD_DR_RESULTMASK) >> AD_DR_RESULTSHIFT); // Return the processed results } 6 . INTERFACING A SEVEN SEGMENT DISPLAY–LPC21XX A seven segment display can be used to interface with LPC21XX microcontroller using the GPIO lines. By using one seven segment display module along with LPC21XX ,a Hex counter which counts 0 to F can be designed. By interfacing two Seven segment displays, a Hex counter which counts 00 to FF can be designed. The LSB segment is interfaced to Port1 GPIO lines(P1.16 to P1.22) and MSB module is interfaced to Port0 GPIO lines(Port0.16 to Port0.22) as shown in the circuit diagram. 11
  • 12. Dr.Y.NARASIMHA MURTHY Ph.D yayavaram@yahoo.com PROGRAM #include<lpc21xx.h> unsigned char seg[16] ={0x40,0x79,0x24,0x30,0x19,0x12,0x02,0x78,0x00,0x10,0x08, 0x03,0x46,0x21,0x06,0x0e}; unsigned char seg_val,seg_val1; unsigned char count,count1; unsigned long int var,var1; void main(void) { unsigned long int k; PINSEL0=0X00000000; // Select Port 0 pins as GPIO lines 12
  • 13. Dr.Y.NARASIMHA MURTHY Ph.D yayavaram@yahoo.com PINSEL1=0X00000000; // Select Port 1 pins as GPIO lines IODIR0 = 0X00FF0000; // Configure the required pins of Port 0 as output pins IODIR1 = 0X00FF0000; // Configure the required pins of Port 1 as output pins for (count=0;count<=15;count++) // COUNT FOR MSB { IOCLR1 = var; seg_val = seg[count]; var = seg_val; var = var<<16; IOSET1 = var; for(count1=0;count1<=15;count1++) // COUNT FOR LSB { IOCLR0=var1; seg_val1=seg[count1]; var1=seg_val1; var1=var1<<16; IOSET0=var1; for(k=0;k<50000;k++); } // End for loop } // End for loop } // End main. 13
  • 14. Dr.Y.NARASIMHA MURTHY Ph.D yayavaram@yahoo.com 7 . INTERFACING OF 2X16 LCD MODULE - LPC21XX The ARM7 LPC21xx processor is interfaced to the 2x16 LCD mpdule in 4-bit mode .The interfcae diagram is shown below.The four data pins are connected with 4 data bits (P0.19 – P0.22 pins to bits D4-D7), address bit (RS-P0.16), read/write bit (R/W-P0.17) and control signal (E-P0.18) to make LCD display complete.The pins D0,D1,D2,D3 are left free with out any connections. 16X 2 LCD is a 16 pin module . In which pins 1 &16 are grounded, 2 &15 are given to V CC and 3rd pin is given to potentiometer in order adjust the contrast of LCD. Pins 4, 5 & 6 corresponds to RS, R/W & EN respectively. Pins 7 to 14 are data lines from D0 to D7 respectively. Here the LCD is used in 4 bit mode i.e. upper 4 bits are used to transfer the data with MSB first and LSB next. Port 0 pins i.e. from P0.16 to P0.22 are used for both data and control signals. The interfacing diagram of 16X2 LCD is shown below. PROGRAM #include <LPC21xx.H> long unsigned int data,temp1,temp2; unsigned char *ptr,data_array[] = "SSBN DEGREE & PG COLLEGE, ATP"; void main() { int i=0; 14
  • 15. Dr.Y.NARASIMHA MURTHY Ph.D yayavaram@yahoo.com PINSEL0 = 0x00000000; // Select Port 0 pins as GPIO lines IODIR0 = 0x00ff0000; // Configure the required pins of Port 0 as output pins lcd_init(); // LCD initialization delay(2500); // Delay ret_home(); // Cursor to return home delay(2500); // Delay clr_disp(); // Clear display delay(2500); // Delay ptr = &data_array[0]; for(i=1;i<sizeof(data_array);i++) { if(i == 17) { temp1 = 0xc0; // Goto 2nd line in the LCD lcd_com(); // Byte to nibble conversion of LCD command delay(800); } // End if data = *ptr; lcd_data(); // Byte to nibble conversion of LCD data ptr++; } // End for loop } // End main void lcd_init(void) // Initialization of LCD { temp2=0x30; // Assign command to temp2 temp2=temp2<<16; // Shift the data by 16 bits left cmd_wrt(); // Command write subroutine delay(800); // Delay temp2=0x30; // Assign command to temp2 temp2=temp2<<16; // Shift the data by 16 bits left cmd_wrt(); // Command write subroutine delay(800); // Delay temp2=0x30; // Assign command to temp2 temp2=temp2<<16; // Shift the data by 16 bits left cmd_wrt(); // Command write subroutine delay(800); // Delay temp2=0x30; // Assign command to temp2 temp2=temp2<<16; // Shift the data by 16 bits left cmd_wrt(); // Command write subroutine delay(800); // Delay temp2=0x20; // Assign command to temp2 temp2=temp2<<16; // Shift the data by 16 bits left cmd_wrt(); // Command write subroutine delay(800); // Delay temp1 = 0x28; // Command for LCD to function in 4 bit mode lcd_com(); delay(800); 15
  • 16. Dr.Y.NARASIMHA MURTHY Ph.D yayavaram@yahoo.com temp1 = 0x0c; // Command for display on, cursor off lcd_com(); delay(800); temp1 = 0x06; // Command for cursor increment lcd_com(); delay(500); temp1 = 0x80; // Command to force the cursor to beginning of 1st line lcd_com(); delay(800); } void delay(unsigned int j) // Delay subroutine { unsigned int k; for(k=0;k<j;k++); } void clr_disp(void) // To clear LCD display { temp1 = 0x01; lcd_com(); delay(320); } void ret_home(void) // To return home { temp1 = 0x02; lcd_com(); delay(320); } void lcd_com(void) // Byte to nibble conversion of LCD command { temp2= temp1 & 0x00f0; temp2=temp2<<16; cmd_wrt(); temp2 = temp1 & 0x000f; temp2 = temp2 << 20; cmd_wrt(); } -------------------xxxxxxx------------- Acknowledgment: I thank all the people without whose contribution ,this class notes would have not been possible ,especially Pantech Solutions website . 16