You are on page 1of 5

LPC2148 – MCB2140

LEDs
Home » Theory of Operation » LEDs

The LEDs on the MCB2140 board are:

 The POWER LED indicates that power is present on the board.


 P1.16 - P1.23 connect to eight Port 1 pins when jumper J6 is installed. These LEDs can
display program status while testing your applications. Removing Jumper J6 disables the
LED drivers.
Speaker
Home » Theory of Operation » Speaker

The MCB2140 board includes a speaker controlled by the output of the on-chip D/A converter.
The LM386M low voltage power amplifier (IC4) amplifies the D/A output to drive the speaker.

Jumper J13 connects the D/A output (Port 0, pin 25, P0.25/AOUT) to the input of the LM386M
amplifier. Removing this jumper disables the speaker.
Push Buttons
Home » Theory of Operation » Push Buttons

The two push buttons on the MCB2140 board are:

 The RESET push button connects to the reset circuit. This resets the microcontroller.
 The INT1 push button connects to the external interrupt 1 (EINT1) of the
microcontroller. Removing Jumper J7 disables this button.

PROGRAMMING

1. IOxPIN (x=port number) : This register can be used to Read or Write values directly to the
pins. Regardless of the direction set for the particular pins it gives the current start of the GPIO
pin when read.
2. IOxDIR : This is the GPIO direction control register. Setting a bit to 0 in this register will
configure the corresponding pin to be used as an Input while setting it to 1 will configure it as
Output.

3. IOxSET : This register can be used to drive an ‘output’ configured pin to Logic 1 i.e HIGH.
Writing Zero does NOT have any effect and hence it cannot be used to drive a pin to Logic 0 i.e
LOW. For driving pins LOW IOxCLR is used which is explained below.

4. IOxCLR : This register can be used to drive an ‘output’ configured pin to Logic 0 i.e LOW.
Writing Zero does NOT have any effect and hence it cannot be used to drive a pin to Logic 1.

Example 1
#include <lpc214x.h>

void delay(void);

int main(void)
{
IO0DIR = 0xF; // Configure pins(0 to 3) on Port 0 as Output

while(1)
{
IO0SET = 0xF; // Turn on LEDs
delay();
IO0CLR = 0xF; // Turn them off
delay();
}
return 0; // normally this wont execute
}

void delay(void)
{
int z,c;
c=0;
for(z=0; z<4000000; z++) // You can edit this as per your needs
{
c++; // something needs to be here else KEIL ARM compiler will
remove the for loop!
}

Example 2

#include <lpc214x.h>

int main(void)
{
IO0DIR &= ~((1<<7)) ; // explicitly making P0.7 as Input - even though
by default its already Input
IO0DIR |= (1<<30); // Configuring P0.30 as Output
while(1)
{
if( !(IO0PIN & (1<<7)) ) // Evaluates to True for a 'LOW' on
P0.7
{
IO0SET |= (1<<30); // drive P0.30 High
}
}
return 0; // this wont execute ever :P
}

You might also like