Skip to content

Connecting to Serial

RJ edited this page Apr 6, 2017 · 2 revisions

Debian-based Linux instructions

The following is instructions on connecting the STM32F0 board to the Minicom program in order to use the serial port for transmitting characters when printing.

In order to set the Minicom program up for the correct settings:

  1. Install Minicom. If running a Debian based distro, this can be done through the package manager. For other OS's please refer to Google to figure it out.

  2. For initial setup, type minicom -s at the terminal.

    • Go to: Serial Port Setup

    • Type A to go to Serial Device.

      • Enter the tty that the microcontroller is registered as.

      • An example of this is listed here:

        `dmesg | grep tty`  
        `[    0.000000] console [tty0] enabled`  
        `[    0.743375] tty tty33: hash matches`  
        `[34573.231000] cdc_acm 1-12:1.2: ttyACM0: USB ACM device`  
        
      • In this example the serial device is: /dev/ttyACM0

        • Note: the tty registered on your computer may be different as seen here.
    • For Bps/Par/Bits the setting should be: 115200 8N1 for the current configuration of the Usart2 peripheral.

    • Hardware Flow Control and Software Flow Control should both be set to: No

    • Press Enter to return to the main menu.

      • In order to save this configuration, go to: Save setup as dfl
        • Note: You may need to run the minicom program as sudo in order to write out the configuration.
    • Go to exit or exit from Minicom (if you do wish to connect at this time).

    • Once minicom is properly setup, you can start the program with just the command: minicom at the terminal (assuming the configuration was properly saved).

    • The program will then wait to receive bytes transmitted from the serial port.

The serial driver is currently set to the following configuration: 9600 8N1 This stands for: 9600 Kb/s (baud rate), 8 bit word length, no parity, and 1 stop bit. Also, Hardware Flow Control and Software Flow Control both need to be disabled.

There are two different classifications of print commands: kernel printing and user printing. Kernel printing is for printing inside the core OS. This can be done using the kprint! and kprintln! macros. User printing is for printing outside of the core OS can be done using the print! and println! macros.

MacOS instructions

This was tested on MacOS 10.12.3. We will be using screen to connect to the serial port as it ships with the OS by default.

Before plugging in the device:

SHELL$ ls /dev/cu.*
/dev/cu.Bluetooth-Incoming-Port /dev/cu.lpss-serial1            /dev/cu.lpss-serial2

After plugging in device:

SHELL$ ls /dev/cu.*
/dev/cu.Bluetooth-Incoming-Port /dev/cu.lpss-serial1            /dev/cu.lpss-serial2            /dev/cu.usbmodem1453

We can see the device shows up as /dev/cu.usbmodem1453. Your results may vary, so we will call the previous dev device <dev device>. Now we want to connect to it. We can use screen to do this, or minicom if you prefer. screen ships with MacOS, so it may be easier to try.

Connect:

screen <dev device> 9600
# with our previous device handle
screen /dev/cu.usbmodem1453 9600

You may have to hit return/enter a few times to get screen to display the serial prompt. If you get permission denied errors for the device, prefix the command with sudo.

Clone this wiki locally