mbed IO to LPC2368 pin mapping

18 Jun 2009

Hi,

 

I have worked out that the LCP2368 ports map to the mbed IO as shown in the spreadsheet at:

 

ftp://internal.hitex.co.uk/pub/hitex/mbed/mbed-lpc2368mapping.xls

 

It looks like analog 2 and analog 3 are RXD and TXD pins for the UART3 in the LPC2368.  However these are not declared as being a serial port on the mbed pinout. 

 

For what we are doing, it might be useful to make use of these two pins as a serial port.  The question then arises of whether the mbed C++ library can support a serial port on these pins?

Having done this pin mapping exercise it does raise the general point about whether mbed users can make use of alternate pin functions that are not officially declared as mbed IO.

Thanks

 

Mike Beach, Hitex

 

18 Jun 2009

Hi Mike

It looks like analog 2 and analog 3 are RXD and TXD pins for the UART3 in the LPC2368.  However these are not declared as being a serial port on the mbed pinout.

 

For what we are doing, it might be useful to make use of these two pins as a serial port.  The question then arises of whether the mbed C++ library can support a serial port on these pins?

Good question. The answer is, yes, it does support all the pinout options of the underlying chip.

For simplicity, we only specified one of the available pinout options for each underlying hardware block. Specifying only one means people don't have to think about resource conflicts (e.g. describing the concept that it can pinout in multiple places, and hence you can't use both independently!)

However, the libraries quite happily support all the pinout options for a block. So for your UART3 example, TX comes out on pins 9 or 17 and RX on 10 and 18. So you could do:

// The following are valid pinouts for the underlying UART3 hardware block
// note: that means you can only choose one of these options at a time!
Serial uart(9, 10);   // tx, rx
Serial uart(17, 18);  // tx, rx
Serial uart(9, 18);   // tx, rx
Serial uart(17, 10);  // tx, rx

It is the same for any of the resources; all options are available, even if not in the primary quick-reference. Hope this makes it clear. We'll perhaps document all available options in our Ninja section!

Simon

19 Jun 2009

Hi,

LPC2368 PORT0 pins can create interrupts on falling, rising and any edge.  Does the mbed library know about this?  We will need to use it.

Thanks

Mike Beach, Hitex

19 Jun 2009

Hi Mike,

LPC2368 PORT0 pins can create interrupts on falling, rising and any edge.  Does the mbed library know about this?  We will need to use it.

Yep, tak a look at http://mbed.co.uk/handbook/DigitalIn

To attach a function or method to a rising or falling edge, just attach it with the corresponding rise() or fall() method. e.g.

#include "mbed.h"

DigitalIn button(21);
DigitalOut led1(LED1);

// Flip the LED at a rising edge interrupt
void flip (void) {
    led1 = !led1;
}

int main() {

    // Associate flip function with rising edge
    button.rise(&flip);

    // do nothing
    while(1) {}

}

Hope this does what you need.

btw, we'll likely split this functionality out to a seperate class (maybe InterruptIn), to simplify DigitalIn, and make this functionality easier to find. Any thoughts welcome.

Simon