#AP ARM7 LED Interfacing

Circuit Diagram:


//Code for LED blinking using software delay:

#include <LPC214x.h>

void delay(void);

void main()

{

PINSEL0= 0x00000000; // All pins are GPIO

IO0DIR = 0xFFFFFFFF; // Lower 4 pins (P0.3….P0.0) declared output

while(1)

{

IO0SET = 0xFFFFFFFF; // Set lower 4 pins to HIGH logic

  delay();

IO0CLR = 0xFFFFFFFF; // Set lower 4 pins to LOW logic

  delay();

}

}

void delay()

{

int i,j;

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

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

}



// Code for LED blinking with using Timer generated delay

#include<lpc214x.h>

void delay (int);

void delay (int i)

{

  T0TCR=0x02; //Reset

  T0TCR=0x01; //Enable

  while (T0TC < i); //Count upto 1000 MS

  T0TCR=0x00; //Disable Timer0

}

int main()

{

  PINSEL0=0x00;

  IO0DIR=0xFFFFFFFF;

  PLL0CON = 0x01;

  PLL0CFG = 0x24;

  PLL0FEED = 0xAA;

  PLL0FEED = 0x55;

  while(!(PLL0STAT & 0x00000400));

  PLL0CON = 0x03;

  PLL0FEED = 0xAA;

  PLL0FEED = 0x55;

  VPBDIV = 0x01; 

  T0CTCR=0x00;

  T0PR=59999;

  T0TCR=0x02;  

  while(1)

{

  IO0SET=0xFFFFFFFF;

  delay(1000);

  IO0CLR=0xFFFFFFFF;

  delay(1000);

}

Comments