LED interfacing with LPC2148:
LED interfacing with lpc2148 is common anode. so we have to send logic '0' or 0v though GPIO pin. There are eight led connected to port 0 pins namely P0.0 to P0.7.
Circuit diagram:
LED INTERFACING |
1) All led (P0.0 to P0.7) ON and OFF continuously.
/**************************************************************************************************
Expt. 1a.: LED interfacing with to LPC2148
Platform: LPC2148 Development Board.
Hardware Setup:-
LED Pins- P0.0 to P0.7
********************************************************************************/
#include<lpc214x.h> // Include header file
void delay(); // delay function declaration
int main()
{
IODIR0=0xFF<<00; // Assign P0.0 to P0.7 as a output pin
while(1) // Infinite loop
{
IOCLR0= 0xFF<<00; // Set logic 0 to P0.0 to P0.7, LED OFF
delay(); // call delay function
IOSET0=0xFF<<00; // Set logic 1 to P0.0 to P0.7, LED ON
delay();
}
return 0;
}
void delay() // delay definition
{
unsigned int i,j;
for(i=0;i<500;i++)
{
for(j=0;j<32000;j++)
{
}
}
}
/**************************************************************************************************
Expt. 1a.: LED interfacing with to LPC2148
Platform: LPC2148 Development Board.
Hardware Setup:-
LED Pins- P0.0 to P0.7
********************************************************************************/
#include<lpc214x.h> // Include header file
void delay(); // delay function declaration
int main()
{
IODIR0=0xFF<<00; // Assign P0.0 to P0.7 as a output pin
while(1) // Infinite loop
{
IOCLR0= 0xFF<<00; // Set logic 0 to P0.0 to P0.7, LED OFF
delay(); // call delay function
IOSET0=0xFF<<00; // Set logic 1 to P0.0 to P0.7, LED ON
delay();
}
return 0;
}
void delay() // delay definition
{
unsigned int i,j;
for(i=0;i<500;i++)
{
for(j=0;j<32000;j++)
{
}
}
}
2) Led (P0.0 to P0.3) ON and Led (P0.4 to P0.7) OFF and vice versa continuously.
/**************************************************************************************************
Expt. 1b.: LED interfacing with to LPC2148
Platform: LPC2148 Development Board.
Hardware Setup:-
LED Pins- P0.0 to P0.7
********************************************************************************/
#include<lpc214x.h> // Include header file
void delay(); // delay function declaration
int main()
{
IODIR0=0xFF<<00; // Assign P0.0 to P0.7 as a output pin
while(1) // Infinite loop
{
IOCLR0= 0x0F<<00; // Set logic 0 to P0.0 to P0.3, LED OFF
IOSET0= 0xF0<<00; // set logic 1 to P0.4 to P0.7, LED ON
delay(); // call delay function
IOSET0=0x0F<<00; // Set logic 1 to P0.0 to P0.3, LED ON
IOCLR0=0xF0<<00; // set logic 0 to P0.4 to P0.7, LED OFF
delay();
}
return 0;
}
void delay() // delay definition
{
unsigned int i,j;
for(i=0;i<500;i++)
{
for(j=0;j<32000;j++)
{
}
}
/**************************************************************************************************
Expt. 1b.: LED interfacing with to LPC2148
Platform: LPC2148 Development Board.
Hardware Setup:-
LED Pins- P0.0 to P0.7
********************************************************************************/
#include<lpc214x.h> // Include header file void delay(); // delay function declaration int main() { IODIR0=0xFF<<00; // Assign P0.0 to P0.7 as a output pin while(1) // Infinite loop { IOCLR0= 0x0F<<00; // Set logic 0 to P0.0 to P0.3, LED OFF IOSET0= 0xF0<<00; // set logic 1 to P0.4 to P0.7, LED ON
delay(); // call delay function IOSET0=0x0F<<00; // Set logic 1 to P0.0 to P0.3, LED ON
IOCLR0=0xF0<<00; // set logic 0 to P0.4 to P0.7, LED OFF
delay(); }
return 0; } void delay() // delay definition { unsigned int i,j; for(i=0;i<500;i++) { for(j=0;j<32000;j++) { } }
2) Time delay generation using Timer 0 in LPC 2148.
**************************************************************************************************
Expt. 1c.: LED interfacing with to LPC2148 (Time delay 1 sec using timer)
Platform: LPC2148 Development Board.
Hardware Setup:-
LED Pins- P0.0 to P0.7
********************************************************************************/
#include<lpc214x.h> // Include header file
void delay(); // delay function declaration
int main()
{
VPBDIV=0X02;
IODIR0=0xFF<<00; // Assign P0.0 to P0.7 as a output pin
while(1) // Infinite loop
{
IOCLR0= 0xFF<<00; // Set logic 0 to P0.0 to P0.7, LED OFF
delay(); // call delay function
IOSET0=0xFF<<00; // Set logic 1 to P0.0 to P0.7, LED ON
delay();
}
return 0;
}
void delay()
{
T0PR=14999;
T0MR0=1000;
T0TC=0x00000000;
T0TCR=0X01; //START TIMER//
while(T0TC !=T0MR0); //1 SEC //
T0TCR=0X02; //STOP TIMER //
}
************************************************************************************************** Expt. 1c.: LED interfacing with to LPC2148 (Time delay 1 sec using timer) Platform: LPC2148 Development Board. Hardware Setup:- LED Pins- P0.0 to P0.7 ********************************************************************************/ #include<lpc214x.h> // Include header file void delay(); // delay function declaration int main() { VPBDIV=0X02; IODIR0=0xFF<<00; // Assign P0.0 to P0.7 as a output pin while(1) // Infinite loop { IOCLR0= 0xFF<<00; // Set logic 0 to P0.0 to P0.7, LED OFF delay(); // call delay function IOSET0=0xFF<<00; // Set logic 1 to P0.0 to P0.7, LED ON delay(); } return 0; } void delay() { T0PR=14999; T0MR0=1000; T0TC=0x00000000; T0TCR=0X01; //START TIMER// while(T0TC !=T0MR0); //1 SEC // T0TCR=0X02; //STOP TIMER // }
No comments:
Post a Comment