Posts

SQ_TRI_p-13

 SQUARE #include <lpc21xx.h> void delay(void); int main () { PINSEL0 = 0x00000000 ; // Configure P0.0 to P0.15 as GPIO PINSEL1 = 0x00000000 ; // Configure P0.16 to P0.31 as GPIO IO0DIR  = 0x00FF0000 ;     while(1)     {     IO0PIN = 0x00000000;         delay();         IO0PIN = 0x00FF0000;         delay();     } }    void delay(void) { unsigned int i=0;     for(i=0;i<=95000;i++); } TRIANGULAR #include <LPC21xx.h> int main () { unsigned long int temp=0x00000000;    unsigned int i=0;   IO0DIR=0x00FF0000;         while(1)     {     // output 0 to FE          for(i=0;i!=0xFF;i++)         {         temp=i;           temp = temp << 16;        ...

7seg_p-16

 unsigned int delay; unsigned int Switchcount=0;  unsigned int Disp[16]={0x003F0000, 0x00060000, 0x005B0000, 0x004F0000, 0x00660000,0x006D0000,    0x007D0000, 0x00070000, 0x007F0000, 0x006F0000, 0x00770000,0x007C0000,    0x00390000, 0x005E0000, 0x00790000, 0x00710000 }; #define SELDISP1 0x10000000     //P0.28 #define SELDISP2 0x20000000 //P0.29 #define SELDISP3 0x40000000 //P0.30 #define SELDISP4 0x80000000 //P0.31 #define ALLDISP  0xF0000000 //Select all display #define DATAPORT 0x00FF0000 //P0.16 to P0.23 Data lines connected to drive Seven Segments int main (void) { PINSEL0 = 0x00000000;    PINSEL1 = 0x00000000; IO0DIR  = 0xF0FF0000; IO1DIR  = 0x00000000; while(1) { IO0SET |= ALLDISP; // select all digits IO0CLR = 0x00FF0000; // clear the data lines to 7-segment displays IO0SET = Disp[Switchcount];     // get the 7-segment display value fr...

led_p-15

 #include<lpc214x.h> // Function prototypes void lcd_init(void); void wr_cn(void); void clr_disp(void); void delay(unsigned int); void lcd_com(void);     void wr_dn(void); void lcd_data(void); void LCD(void); void Extint1_Isr(void) __irq; //declaration of ISR unsigned char int_flag, flag; int main(void) { IO1DIR |= 0X02000000; //P1.25 int led     IO1SET = 0X02000000;     PINSEL0 =0X000000c0;          //P0.3 EINT1        EXTMODE =0x01;                //edge i.e falling egge trigger and active low     EXTPOLAR= 0X00;     VICVectAddr0 = (unsigned long) Extint1_Isr;   //Assign the EINT0 ISR function      VICVectCntl0 = 0x20 | 15;      //Assign the VIC channel EINT1 to interrupt priority 0     VICIntEnable |= 0x00008000;    //Enable the E...

stepp_p-11

 #include <LPC21xx.H>  void clock_wise(void);  void anti_clock_wise(void);    unsigned long int var1,var2;  unsigned int i=0,j=0,k=0;  int main(void)  { PINSEL0 = 0x00FFFFFF; //P0.12 to P0.15 GPIo IO0DIR |= 0x0000F000; //P0.12 to P0.15 output while(1) { for(j=0;j<50;j++)       // 20 times in Clock wise Rotation clock_wise(); for(k=0;k<65000;k++);   // Delay to show  anti_clock Rotation  for(j=0;j<50;j++)       // 20 times in  Anti Clock wise Rotation anti_clock_wise(); for(k=0;k<65000;k++);   // Delay to show clock Rotation  } // End of while(1)  } // End of main  void clock_wise(void)  { var1 = 0x00000800;          //For Clockwise     for(i=0;i<=3;i++)          // for A B C D Stepping { var1 = var1<...

Dc_p-10

 #include<lpc214x.h> void clock_wise(void); void anti_clock_wise(void); unsigned int j=0; int main() { IO0DIR= 0X00000900; IO0SET= 0X00000100; //P0.8 should always high.   while(1)   {     clock_wise();     for(j=0;j<400000;j++); //delay     anti_clock_wise();     for(j=0;j<400000;j++); //delay } //End of while(1) } //End of Main void clock_wise(void) { IO0CLR = 0x00000900; //stop motor and also turn off relay     for(j=0;j<10000;j++); //small delay to allow motor to turn off    IO0SET = 0X00000900; //Selecting the P0.11 line for clockwise and turn on motor } void anti_clock_wise(void) { IO0CLR = 0X00000900; //stop motor and also turn off relay   for(j=0;j<10000;j++); //small delay to allow motor to turn off    IO0SET = 0X00000100; //not selecting the P0.11 line for Anti clockwise }

hello_p-9

#include<lpc214x.h> void uart_init(void); unsigned int delay; unsigned char *ptr; unsigned char arr[]="HELLO WORLD\r"; int main() { while(1) { uart_init(); ptr = arr; while(*ptr!='\0') { U0THR=*ptr++; while(!(U0LSR & 0x40)== 0x40); for(delay=0;delay<=600;delay++); } for(delay=0;delay<=60000;delay++); } } void uart_init(void) {   PINSEL0=0X0000005;  //select TXD0 and RXD0 lines U0LCR = 0X00000083; //enable baud rate divisor loading and U0DLM = 0X00;          //select the data format U0DLL = 0x13;      //select baud rate 9600 bps U0LCR = 0X00000003; }