8 years, 11 months ago.

Serial comunication

Hi everyone, I start to program Arch gprs V2 and from the schematic sheet i see that the lpc11U37 micro has got 4 serial port:

1) P0_26, P0_27 (RX, TX to sim900);

2) P1_14, P1_13 (RX, TX on UART connector);

3) USB_DM, USB_DP (serial port to USB cable);

4) P0_18, P0_19 (RX, TX - pin0, pin1 Arduino like).

I'd like to know how all this serial port can be handle singly and separately, and if there are some libraries to use for this purpose.

Thanks and Sorry for my bad english,

Matteo

Question relating to:

Arch GPRS V2 is an mbed enabled development board with Arduino form factor and Grove connectors. It’s convenient to connect existing Shields and Grove products to Arch GPRS V2. You …

1 Answer

8 years, 11 months ago.

Yes, see the Serial class in the mbed library.

#include "mbed.h"
Serial port1(P0_26, P0_27);
Serial port2(P1_14, P1_13);
Serial port3(USB_DM, USB_DP);
Serial port4(P0_18, P0_19 );

main() {
  port1.printf("Hello port 1\r\n");
  port2.printf("Hello port 2\r\n");
  port3.printf("Hello port 3\r\n");
  port4.printf("Hello port 4\r\n");
}

Accepted Answer

Thanks Andy!! I tried the code you posted but the compiler returns an error on port3

(Error: Identifier "USB_DM" is undefined in "main.cpp", Line: 4, Col: 14 Error: Identifier "USB_DP" is undefined in "main.cpp", Line: 4, Col: 22).

I also tried the code for only 2 ports (port 2 and port 4) and the result is:

Hello port 2

Hello port 4

In both ports!!! I think the real result should be:

Hello port 2 on Serial port2(P1_13, P1_14);

Hello port 4 on Serial port4(P0_19, P0_18);

I need 3 separate serial ports with different baud rate, bit parity and stop bit. (port1 9600 8E1; port2 19200 8N1; port3 9600 8N2); how can I get this target??

posted by Matteo Cipriani 11 May 2015

I think you've misread the specs on the CPU you are using.

I didn't double check the pinout that you had, I just copy and pasted the pins you had listed.

Looking into it now the lpc11U37 only has 1 serial port, see page 4 of the datasheet for the CPU: http://www.nxp.com/documents/data_sheet/LPC11U3X.pdf

The reason for multiple pins on the schematic is that the uart hardware in the CPU can be internally connected to a number of different pins. When you try connecting it to multiple locations all of the outputs are connected to the same signal, normally only the last input specified is connected. Which is why you got the same output on both port 2 and port 4. If you tried reading data you'd probably only see data input on port 4.

On a part with several separate UARTs (e.g. the LPC1768 CPU has 4 but not all 4 are connected to IO pins on all mbed boards using that CPU) then you can set each one to a different baud rate and parity.

posted by Andy A 11 May 2015