Project

General

Profile

Serial communication (UART) through MitySOM-1810F PROFIBUS

Added by Jesus Alejandro Alvarez Trejo almost 8 years ago

Hello, Good day
I am beginner working with the MitySOM-1810F PROFIBUS Development kit. I would like to use the UART communication to share information with an external device, I know the UART0 is used to send information through the console so I can not use the UART0. Therefore I am trying to implement the serial communication in c++ language.
My questions are:

Do you have some example in C++ language about how communicate trough serial communication(UART)?
How could I enable the UART communication?
Which external pins could I use?

Thanks for your time.
Alex


Replies (3)

RE: Serial communication (UART) through MitySOM-1810F PROFIBUS - Added by Jonathan Cormier almost 8 years ago

Jesus Alejandro Alvarez Trejo wrote:

Hello, Good day
I am beginner working with the MitySOM-1810F PROFIBUS Development kit. I would like to use the UART communication to share information with an external device, I know the UART0 is used to send information through the console so I can not use the UART0. Therefore I am trying to implement the serial communication in c++ language.
My questions are:

Do you have some example in C++ language about how communicate trough serial communication(UART)?

UART communication in linux is done by read/writing to the /dev/tty* files. There are many examples about how to do this using std c. Here are a few examples.
https://stackoverflow.com/questions/6947413/how-to-open-read-and-write-from-serial-port-in-c
https://softexpert.wordpress.com/2007/10/18/how-to-connect-to-a-serial-port-in-linux-using-c/
https://jazprojects.wordpress.com/2012/12/23/serial-communication-in-c-in-the-beaglebones-linux-environment-with-an-xbee-example/

I'm personally not accustomed to doing the serial communication using plain c++. I've used Qt and QSerialPort to access it in a more object oriented fashion. https://wiki.qt.io/Qt_Serial_Port or qextserialport https://qextserialport.github.io/

Or try to use a third party library. Note just found this through google, never tried it. https://github.com/wjwwood/serial

How could I enable the UART communication?
Which external pins could I use?

You will need to make sure the proper pins are pinmuxed.

If we look at the devkit schematic, the first page you can see UART[2] comes out to a 10-pin header. UART2 should appear as /dev/ttyS2 in linux.

On page 6 we see the J504 header, which we've labeled as RS485 but this can be used for RS232 as well. Note that the RS232 will be 3.3V signal levels.

Note the pinout of that connector.

To enable the pinmux for that UART, you need to change the config in u-boot. Boot into u-boot and run config set, keep pressing enter until you get to the "UART - 2 Configuration" and then configure the uart, after keep pressing enter until back at u-boot prompt. Run config save and then reboot. See below for example.

U-Boot > config set
MityDSP-L138 Configuration:
Config Version  : 1.0
Config Size     : 264
Manufacturer    : Critical Link
Ethernet Config : 2
Ethernet Name   : GENERIC @ 0x03
Ethernet PHYMask: 8
LCD Config      : 0
MMC0 Config     : 1
MMC1 Config     : 0
U-Boot > config set
Ethernet Config : 2
UART - 0 Configuration ---
Enable UART : 0
UART - 1 Configuration ---
Enable UART : 1
Baud : 115200
HW Flow Control : 0
Is Console : 1
UART - 2 Configuration ---
Enable UART : 1
Baud : 115200
HW Flow Control : 0
Is Console : 0
SPI - 0 Configuration ---
Enable SPI : 0
SPI - 1 Configuration ---
Enable SPI : 1
CLK is Output : 1
Chip Select [0] Enable : 01
Chip Select [1] Enable : 00
Chip Select [2] Enable : 00
Chip Select [3] Enable : 00
Chip Select [4] Enable : 00
Chip Select [5] Enable : 00
Chip Select [6] Enable : 00
Chip Select [7] Enable : 00
ENA ENable : 0
CLK Rate : 30000000
LCD Configuration
LCD Enable : 0
MMC 0 Configuration
MMC 0 Enable : 1
Write Protect Pin bank : 4
Write Protect Pin bank offset : 1
Card Detect Pin bank : 4
Card Detect Pin bank offset : 0
U-Boot > config save
Configuration Saved
U-Boot > reset

Note if you want to test the serial port, you can use microcom which should be installed on the filesystem. You can exit microcom using ctrl-x.

RE: Serial communication (UART) through MitySOM-1810F PROFIBUS - Added by Jesus Alejandro Alvarez Trejo almost 8 years ago

Hello, Good Day

Thanks for your answer it is so useful, I am going to try step by step in order to achieve the serial communication (UART).

Thanks for your time.
Alex

    (1-3/3)
    Go to top
    Add picture from clipboard (Maximum size: 1 GB)