19. Now since the project is almost setup we can start writing code in the "main.c" file
that was created earlier. For demonstration purpose you can copy the following code and
paste it in the "main.c" file. This code is written to blink LEDs on LPC2148
development board in the sequential order starting from LED1. Refer jumper settings for
LEDs from the hardware description section 3.2.
#include <lpc214x.h>
#define LED1_ON() IO1SET=(1<<16)
#define LED2_ON() IO1SET=(1<<17)
#define LED3_ON() IO1SET=(1<<18)
#define LED4_ON() IO1SET=(1<<19)
#define LED1_OFF() IO1CLR=(1<<16)
#define LED2_OFF() IO1CLR=(1<<17)
#define LED3_OFF() IO1CLR=(1<<18)
#define LED4_OFF() IO1CLR=(1<<19)
void Delay(unsigned char j)
{
unsigned int i;
for(;j>0;j--)
{
for(i=0; i<60000; i++);
}
}
int main(void)
{
PINSEL0 = 0x00000000;
PINSEL1 = 0x00000000;
IO1DIR = (1<<19) | (1<<18) | (1<<17) | (1<<16); // Set P1.16, P1.17,
P1.18, P1.19 as Output
while(1)
{
LED1_ON();
Delay(25);
LED1_OFF();
LED2_ON();
Delay(25);
LED2_OFF();
LED3_ON();
Delay(25);
LED3_OFF();
LED4_ON();
Delay(25);
LED4_OFF();
}
return(0);
}
NEX Robotics Pvt. Ltd.
www.nex-robotics.com
// Enable GPIO on all pins
LPC2148 DEVELOPMENT BOARD
27
Need help?
Do you have a question about the LPC2148 Pro and is the answer not in the manual?
Questions and answers