8 years, 2 months ago.

pin allocations.

Now that I have mbed.h I can compile the program for the MBED LPC1768 - not! I thought that mbed.h took care of pin names, but the compiler does not recognise pin declarations of the form "PA_2". However, it accepts declarations of the form "p9", but does this define the pin on the chip or the pin on the module? Also the code does not specify which pin is SCL or SDA and which pin is TxD or RxD. My recollection is that there was a file called "Pins.h' or "PinNames.h" which would have been specific to the chip and platform.

Question relating to:

Driver for TI TMP007 thermopile. Reads object temperature, internal temperature, and sensor voltage. Temperature

1 Answer

8 years, 2 months ago.

The reason you're getting an error is that there is no PA_2 on the LPC1768.

The pin names in the library match the pins on diagram for that part on it's platform page. For the LPC1768 the pins are p5 to p30 and match the pin numbers and silkscreen on the LPC1768 module.

You can also use port names directly e.g. P0_9 for port 0 pin 9 (NXP use numbered ports not letters so there is still no PA_2) but working out which physical pin that is requires you to then look at the circuit diagram for the module and generally isn't worth the effort.

It is up to the programmer to ensure that the pins they give are compatible with the function they want, the compiler won't check that. If you want an I2C interface make sure you pick pins that are indicated as supporting I2C on your platform. If you get that wrong you'll get a crash at start up with a special blink pattern and text error message on the USB port.

The code does specify which I2C pin is which, it's in the definition of the I2C port in the library, I2C (PinName sda, PinName scl). Same for serial ports, the pin order is the one defined by the mbed library.

You are correct there is a PinNames.h file for each platform. For the LPC1768 it is here.