Monday, 22 May 2017

ARM HARDWARE PROGRAMS

ARM HARDWARE PROGRAMS

LAB PROGRAM 12: 

To interface LCD with ARM Processor-ARM7TDMI/LPC2148. Write and execute program in C language for displaying the text messages and numbers on LCD.

#include <LPC21xx.H>

char disp1[] = "EWIT 2017"; 

void delay()

{

            int i;

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

 }


/* Function to display the character  */

void Disp_Key(unsigned long c)

{

  unsigned long l;

  l = c << 16;

  IOCLR1 = 0x00FF0000;        /*Instruction IOCLR1 = 0x00FF0000 instructs the CPU to write a Digital LOW logic on pin number 16 to 23 of PORT1. (IOCLR => Input Output Port CLEAR Register). */                                     

  IOSET1 = l;

  IOCLR0 = 0x003F8000;                                                        /* E      R/W* RS */                 

  IOSET0 = 0xfa << 15;                                                           /* 0      1          0  */

  IOCLR0 = 0x003F8000;

  IOSET0 = 0xf9 << 15;                                                           /* 0    0    1  */

  IOCLR0 = 0x003F8000;

  IOSET0 = 0xfd << 15;                                                           /* 1      0          1  */

  IOCLR0 = 0x003F8000;

  IOSET0 = 0xf9 << 15;                                                           /* 0    0    1  */

  IOCLR0 = 0x003F8000;

  delay();

}  


/* Function to issue the series of commands to the LCD module */

void Command_Write(unsigned long com_word)

{ 

  IOCLR1 = 0x00FF0000;

  IOSET1 = com_word;                                                            /* Send commands to the LCD through GPIO1 */

  IOCLR0 = 0x003F8000;                                                        /* E      R/W* RS */

  IOSET0 = 0xfb << 15;                                                           /* 0    1    1  */

  IOCLR0 = 0x003F8000;

  IOSET0 = 0xf8 << 15;                                                           /* 0    0    0  */

  IOCLR0 = 0x003F8000;

  IOSET0 = 0xfc << 15;                                                           /* 1    0    0  */

  IOCLR0 = 0x003F8000;

  IOSET0 = 0xf8 << 15;                                                           /* 0    0    0  */

  IOCLR0 = 0x003F8000;

  delay();

}


/* Function to read characters from a string and displaying the same by calling the

   Disp_key fucntion */

void Disp_String(char * c)

{

  int i=0;

  while(c[i] != 0x00)

  {

    Disp_Key(c[i]);

    i ++;

  }

}


/* Function to initialize the LCD module */

void LCD_init(void)

{

  unsigned long command;

  command = 0x38 << 16;                                            /* Function set 8-bit, 1 line 5*7 font*/

  Command_Write(command);

  command = 0x0c << 16;                                /* Display on off control. Diplay on, cursor off, */

  Command_Write(command);                                                /* blink off */

  command = 0x01 << 16;                                                        /* Clear the LCD display */

  Command_Write(command);

}     

int main()

{

  unsigned long com_word;

            IODIR0 = 0x007F8000;              /* Configure the GPIO0 (P0.15 TO P0.22) Port B as output } */

            IODIR1 = 0x00FF0000;           /*GPIO1 (P1.16 to P1.22)Port A as O/P */

  LCD_init();                    /* Initialize LCD module */

 

            com_word = 0x80 << 16;         /* displaying on the first line*/

  Command_Write(com_word);

  Disp_String(disp1);                                           /* Displays the message on LCD */

}



LAB PROGRAM 13:


To interface stepper motor with ARM processor ARM7TDMI/LPC2148. Write a program to rotate stepper motor.


Clockwise rotation


#include <LPC214X.H> //header for LPC2148 header files

void delay(unsigned int count)
{
  unsigned int i ,j= 0;
  for(i = 0; i <= count; i ++)
  for(j = 0; j <= 5; j ++);
}
//unsigned long i;
int main()
{
  IODIR1 = 0x00FF0000; //making the port1 as output port
 // i = 0x00110000;
  while(1)
  {
    IOSET1 = 0x00880000; //send the sequence 10001000 to port1
      delay(10000);
      IOCLR1 = 0x00FF0000; //clear the pins of port 1
      IOSET1 = 0x00440000; //send the sequence 01000100 to port1
      delay(10000);
      IOCLR1 = 0x00FF0000; ; //clear the pins of port 1
      IOSET1 = 0x00220000; //send the sequence 00100010 to port1
      delay(10000);
      IOCLR1 = 0x00FF0000; //clear the pins of port 1
      IOSET1 = 0x00110000; //send the sequence 00010001 to port1
      delay(10000);
      IOCLR1 = 0x00FF0000; //clear the pins of port 1
  }
}

Counter Clockwise rotation

#include <LPC214X.H>

void delay(unsigned int count)
{
  unsigned int i,j = 0;
  for(i = 0; i <= count; i ++){
  for(j=0;j<=5;j++);
  }
}
int main()
{
  IODIR1 = 0x00FF0000; //making the port1 as output port

  while(1)
  {
    IOSET1 = 0x00110000; //send the sequence 00010001 to port1
      delay(10000);
      IOCLR1 = 0x00FF0000; //clear the pins of port 1
      IOSET1 = 0x00220000; //send the sequence 00100010 to port1
      delay(10000);
      IOCLR1 = 0x00FF0000; //clear the pins of port 1
      IOSET1 = 0x00440000; //send the sequence 01000100 to port1
      delay(10000);
      IOCLR1 = 0x00FF0000; //clear the pins of port 1
      IOSET1 = 0x00880000; //send the sequence 10001000 to port1
      delay(10000);
      IOCLR1 = 0x00FF0000; //clear the pins of port 1
  }
}


Download Text Books

Download All TextBooks from 1st to 10th standard Click Here to Download http://www.ktbs.kar.nic.in/New/index.html#!/textbook