Translate

Wednesday 8 November 2017

Textual description of firstImageUrl

Welcome to Embedded world (ARM Based)

Welcome to Embedded World






Glowing of Led Program:

using ARM LPC2148
 
#include<lpc214x.h>
void delay();
int main()
{
 IO0DIR=IO0DIR|(1<<0);
 while(1)
 {
  IO0SET=IO0SET|(1<<0);
  delay();
  IO0CLR=IO0CLR|(1<<0);
  delay();
 }
return 0;
}
void delay()
{
 unsigned int i;
 for(i=0;i<=59999;i++);
}
 
 
 
 
 
 
 
 
2-
 
 
/*#include<lpc214x.h>
void delay();
int main()
{
 IO0DIR=IO0DIR|(1<<20);
 while(1)
 {
  IO0SET=IO0SET|(1<<20);
  delay();
  IO0CLR=IO0CLR|(1<<20);
  delay();
 }
return 0;
}
void delay()
{
 unsigned int i;
 for(i=0;i<=59999;i++);
}
*/
/*
#include<lpc214x.h>
void delay();
int main()
{
 IO0DIR=IO0DIR|(1<<20)|(1<<21);
 while(1)
 {
  IO0SET=IO0SET|(1<<20)|(1<<21);
  delay();
  IO0CLR=IO0CLR|(1<<20)|(1<<21);
  delay();
 }
return 0;
}
void delay()
{
 unsigned int i;
 for(i=0;i<=59999;i++);
}
*/
/*
#include<lpc214x.h>
void delay();
int main()
{
 IO0DIR=IO0DIR|(3<<20);
 while(1)
 {
  IO0SET=IO0SET|(3<<20);
  delay();
  IO0CLR=IO0CLR|(3<<20);
  delay();
 }
return 0;
}
void delay()
{
 unsigned int i;
 for(i=0;i<=59999;i++);
}*/
/*
#include<lpc214x.h>
void delay();
int main()
{
 IO0DIR=IO0DIR|(0xf<<20);
 while(1)
 {
  IO0SET=IO0SET|(0xf<<20);
  delay();
  IO0CLR=IO0CLR|(0xf<<20);
  delay();
 }
return 0;
}
void delay()
{
 unsigned int i;
 for(i=0;i<=59999;i++);
}
*/

#include<lpc214x.h>
void delay();
int main()
{
 IO0DIR=IO0DIR|(0xff<<16);
 while(1)
 {
  IO0SET=IO0SET|(0xff<<16);
  delay();
  IO0CLR=IO0CLR|(0xff<<16);
  delay();
 }
return 0;
}
void delay()
{
 unsigned int i;
 for(i=0;i<=59999;i++);
} 






3-






#include<lpc214x.h>
void delay(int );
int main()
{ 
 int i;
 IO0DIR=IO0DIR|0xffff;
 while(1)
 {
   for(i=0;i<=15;i++)
  {
   IO0SET=(1<<i);
   delay(4);
   IO0CLR=(1<<i);
  }
 }
return 0;
}
void delay(int k)
{
 unsigned int i,j;
 for(j=0;j<=k;j++)
 {
   for(i=0;i<=59999;i++);
 }
}
 
 
 
 
 

 
 
 
LCD Programming

 8bit
 
/*
#include<lpc214x.h>
void lcd_init();
void lcdcmd(char);
void lcddata(char);
void delay(int );
int main()
{
 lcd_init(); 
 while(1)
 {
  lcdcmd(0x80);
  lcddata('A');
  delay(10);
  lcddata('B');
  delay(10);
  lcdcmd(0x01);
 }
return 0;
}
void lcd_init()
{
 IO0DIR=IO0DIR|0x7ff;
 lcdcmd(0x38);//select 8bit 5x7 mode
 lcdcmd(0x0E);//display on cursor on
 lcdcmd(0x06);//shift cursor to right
}
void lcddata(char x)
{
 IO0SET=IO0SET|x;
 IO0SET=IO0SET|(1<<8); //rs=1
 IO0CLR=IO0CLR|(1<<9); //rw=0
 IO0SET=IO0SET|(1<<10);//en=1
 delay(1);
 IO0CLR=IO0CLR|(1<<10);//en=0
 delay(2);
 IO0CLR=IO0CLR|x;
 
}
void lcdcmd(char x)
{
 IO0SET=IO0SET|x;
 IO0CLR=IO0CLR|(1<<8); //rs=0
 IO0CLR=IO0CLR|(1<<9); //rw=0
 IO0SET=IO0SET|(1<<10);//en=1
 delay(1);
 IO0CLR=IO0CLR|(1<<10);//en=0
 delay(2);
 IO0CLR=IO0CLR|x;
}
void delay(int k)
{
 int i,j;
 for(i=0;i<k;i++)
 for(j=0;j<=59999;j++);
}
*/





#include<lpc214x.h>
#include"lcd_init.h"
#include"delay.h"
#include"lcd.h"
void lcd_init();
void lcdcmd(char);
void lcddata(char);
void delay(int );
void lcdstring(char  *);
int main()
{
 lcd_init(); 
 while(1)
 {
  lcdcmd(0x80);
  lcdstring("ABCDEFGHIJKLM");
  lcdcmd(0xc0);
  lcdstring("NOPQRSTUVWXYZ");
  lcdcmd(0x01);
 }
return 0;
}
void lcdstring(char  *x)
{
 while( *x != '\0')
 {
  lcddata(*x);
  x++;
 }
} 
 
 
 
2-

8bit
 
#include<lpc214x.h>
#define rs 8
#define rw 9
#define en 10
void lcd_init();
void lcdcmd(char);
void lcddata(char);
void delay(int );
void lcdstring(char  *);
int main()
{
 lcd_init(); 
 while(1)
 {
  lcdcmd(0x80);
  lcdstring("ABCDEFGHIJKLM");
  lcdcmd(0xc0);
  lcdstring("NOPQRSTUVWXYZ");
  lcdcmd(0x01);
 }
return 0;
}
void lcd_init()
{
 IO0DIR=IO0DIR|0x7ff;
 lcdcmd(0x38);//select 8bit 5x7 mode
 lcdcmd(0x0E);//display on cursor on
}
void lcdstring(char  *x)
{
 while( *x != '\0')
 {
  lcddata(*x);
  x++;
 }
}

void lcddata(char x)
{
 IO0SET=IO0SET|x;
 IO0SET=IO0SET|(1<<rs); 
 IO0CLR=IO0CLR|(1<<rw); 
 IO0SET=IO0SET|(1<<en);
 delay(1);
 IO0CLR=IO0CLR|(1<<en);
 delay(2);
 IO0CLR=IO0CLR|x;
 
}
void lcdcmd(char x)
{
 IO0SET=IO0SET|x;
 IO0CLR=IO0CLR|(1<<rs);
 IO0CLR=IO0CLR|(1<<rw); 
 IO0SET=IO0SET|(1<<en);
 delay(1);
 IO0CLR=IO0CLR|(1<<en);
 delay(2);
 IO0CLR=IO0CLR|x;
}
void delay(int k)
{
 int i,j;
 for(i=0;i<k;i++)
 for(j=0;j<=59999;j++);
}

 

3-

4bit



#include<lpc214x.h>
#define rs 0
#define rw 1
#define en 2
void lcd_init();
void lcdcmdwrite();
void lcddatawrite();
void lcdcmd(char);
void lcddata(char);
void delay(int );
void lcdstring(char  *);
void display();
int main()
{
 PINSEL0=0x00000000;
 //PINSEL1=0x00000000;
 //PINSEL2=0x00000000;
 lcd_init(); 
 while(1)
 {
  display();
 }
return 0;
}
void display()
{
 lcdcmd(0x80);
  lcdstring("ABCDEFGHIJKLM");
  lcdcmd(0xc0);
  lcdstring("NOPQRSTUVWXYZ");
  lcdcmd(0x01);
}
void lcd_init()
{
 IO0DIR=IO0DIR|0x7f;
 lcdcmd(0x02);
 lcdcmd(0x28);
 lcdcmd(0x0E);
 lcdcmd(0x06);
}
void lcdstring(char  *x)
{
 while( *x != '\0')
 {
  lcddata(*x);
  x++;
 }
}

void lcddata(char x)
{
 IO0SET=IO0SET|((x&0xf0)>>1);
 lcddatawrite();
 IO0CLR=IO0CLR|((x&0xf0)>>1);
 IO0SET=IO0SET|(((x<<4)&0xf0)>>1);
 lcddatawrite();
 IO0CLR=IO0CLR|(((x<<4)&0xf0)>>1);
 
}
void lcdcmd(char x)
{
 IO0SET=IO0SET|((x&0xf0)>>1);
 lcdcmdwrite();
 IO0CLR=IO0CLR|((x&0xf0)>>1);
 IO0SET=IO0SET|(((x<<4)&0xf0)>>1);
 lcdcmdwrite();
 IO0CLR=IO0CLR|(((x<<4)&0xf0)>>1); 
}
void lcdcmdwrite()
{
 IO0CLR=IO0CLR|(1<<rs);
 IO0CLR=IO0CLR|(1<<rw); 
 IO0SET=IO0SET|(1<<en);
 delay(1);
 IO0CLR=IO0CLR|(1<<en);
 delay(2);
}
void lcddatawrite()
{
 IO0SET=IO0SET|(1<<rs);
 IO0CLR=IO0CLR|(1<<rw); 
 IO0SET=IO0SET|(1<<en);
 delay(1);
 IO0CLR=IO0CLR|(1<<en);
 delay(2);
}
void delay(int k)
{
 int i,j;
 for(i=0;i<k;i++)
 for(j=0;j<=59999;j++);
} 
 
 
plzz comment on comment box 
 
 

                                      Give Something to the world and it will never let you down. 
                                                                                           Onkar Dubey 

No comments:

Post a Comment