Wednesday, 25 December 2013

LCD interfacing program in C for ARM (LPC 2XXX)

#include<LPC21XX.h>
#define RS (1<<0)
#define RW (1<<1)
#define EN (1<<2)
void display(unsigned char i);
void cmd(unsigned char j);
void lcd_string(unsigned char *p);
void delay(unsigned char k);
int main()
{
     PINSEL0=0x00000000;
IODIR0|=0X00000FFF;
  cmd(0x38);
  cmd(0x01);
  cmd(0x06);
  cmd(0x0E);
  cmd(0x84);
  lcd_string("JAYPEE");
cmd(0xc2);
lcd_string("UNIVERSITY");
  while(1);
  }

 void cmd(unsigned char j)
 {
IOCLR0|=0X00000FFF;
    IOSET0|=(j<<4);
IOCLR0|=RS;
IOCLR0|=RW;
IOSET0|=EN;
delay(100);
IOCLR0|=EN;
}
void lcd_string(unsigned char *p)
{
while(*p!=0)
{

display(*p);
p++;
}
}
void display(unsigned char i)
{
IOCLR0|=0X00000FFF;
IOSET0|=(i<<4);
IOSET0|=RS;
IOCLR0|=RW;
IOSET0|=EN;
delay(100);
IOCLR0|=EN;
}
void delay(unsigned char k)
{
int l,m;
for(l=0;l<k;l++)
{
for(m=0;m<1000;m++);
}
}

LED Blinking program in C for ARM (LPC 2xxx)

#include<lpc21xx.h>
void delay1 (unsigned int);
int main()
{
IO0DIR=(1<<0);
PINSEL0=0x00000000;
while(1)
{
IO0SET=(1<<0);
delay1(1000);
IO0CLR=(1<<0);
delay1(1000);
}
}
void delay1 (unsigned int x)
{
unsigned int i;
for (i=0;i<x; i++);
}

Friday, 1 November 2013

ARM (LPCXXXX) Assembly Program for LED control by taking input from sensor

@;======================================================================
@;      LED ON and OFF Program by taking input from sensor
@;           
@;      Modified by GAURAV VERMA
@;     
@;
@;======================================================================

        AREA PROGRAM, CODE, READONLY
                                ENTRY
PINSEL0 EQU 0xE002C000
PINSEL1 EQU 0xE002C004
IOPIN   EQU 0xE0028000
IODIR   EQU 0xE0028008
IOSET   EQU 0xE0028004
IOCLR   EQU 0xE002800C
                               
                                ldr     r1,=PINSEL0             ; PINSEL0 controls pin 0-15
                                ldr     r2,=0x00000000      ;default GPIO function 00
                                str     r2, [r1]
                                ldr     r1,=IODIR
                                 ldr     r2,=0xFFFFFFFE  ; 0-INPUT 1-OUTPUT 0:31
                                str     r2, [r1]

BACK                     ldr     r0,=IOSET
                                ldr     r1,=0x7BFFFFFF ; SET ALL
                                str     r1, [r0]

                                ldr     r0,=IOPIN
key                          ldr     r3, [r0]
                                CMPS    r3, #0x03FFFFFF ; checking whether switch is pressed or not
                                beq     key
                               
                                ldr     r0,=IOCLR
                                ldr     r2,=0x00000010 ; CLR p0.4
                                str     r2, [r0]
                                BL WAIT
                                BAL BACK

WAIT                     MOV r4, #0x00100000
BACK1                   nop
                                SUBS r4, r4, #1
                                bne     BACK1
                                bx R14
                                           END

Thursday, 31 October 2013

ARM PPT











ARM (LPCXXXX) Assembly Program for LED Blinking

@;===========================================================================
@;      LED Blinking program
@;     
@;      Modified by GAURAV VERMA
@;      
@;===========================================================================

AREA PROGRAM, CODE, READONLY
                        ENTRY
                                               
PINSEL0 EQU 0xE002C000
PINSEL1 EQU 0xE002C004

IOPIN   EQU 0xE0028000
IODIR   EQU 0xE0028008
IOSET   EQU 0xE0028004
IOCLR   EQU 0xE002800C
                               
                        ldr     r1,=PINSEL0             ; PINSEL0 controls pin 0-15,@; PINSEL1 controls pin 16-31
                        ldr     r2,=0x00000000    ;default GPIO function 00
                        str     r2, [r1]
                                                               
                        ldr     r1,=IODIR
                        ldr     r2,=0xFFFFFFFF  ; 0-INPUT 1-OUTPUT 0:31 (12 -LED)
                        str     r2, [r1]
                               
                         ; ON LED (GPIO) (GPIO LOW-ON)
BACK              ldr     r0,=IOCLR
                         ldr     r1,=0xFFFFFFFF ; CLR ALL
                         str     r1, [r0]
                         BL WAIT
                               
                       ; OFF LED (GPIO) (GPIO HIGH-OFF)
                          ldr     r0,=IOSET
                          ldr     r1,=0xFFFFFFFF ; SET ALL
                          str     r1, [r0]
                          BL WAIT
                          BAL BACK

WAIT                MOV r4, #0x00100000
BACK1              nop
                           SUBS r4, r4, #1
                            bne  BACK1
                            bx R14

                            END