Close

Hello World - UART Edition

A project log for Electronic Load 3.3V-16V 1A

Electronic load that supports 3.3V-16V at 1A of current. Equipped with keypad, LCD, rotary encoder, STM32 Microcontroller and more!

schwarzrmsuschwarzrmsu 12/19/2019 at 02:042 Comments

The next goal for me is to get my UART running.  This will be a huge accomplishment since using a serial monitor is going to be very helpful when debugging code.  I found two really helpful functions online which allow you to pass a character array (char) and it will send the string via the defined UART interface:

void UART_printString(UART_HandleTypeDef *huart, char _out[])
{
    HAL_UART_Transmit(huart, (uint8_t *) _out, strlen(_out), 10);
}

void UART_printlnString(UART_HandleTypeDef *huart, char _out[])
{
    HAL_UART_Transmit(huart, (uint8_t *) _out, strlen(_out), 10);
    char newline[2] = "\r\n";
    HAL_UART_Transmit(huart, (uint8_t *) newline, 2, 10);
}

I plugged in my USB connection and passed a simple "Hello World" string into the UART_printlnString() function:

UART_printlnString(&huart2,"Hello World");
delay_ms(1000);

Unfortunately this did not work right away.  Through some quick trouble shooting, I noticed the USB VBUS fuse F3 had blown open:

I knew this to be the case because I could measure 5V at J70 when connected to my computer, but J72 was reading ~0V.  After some head scratching, I looked into the details of my USB ESD protection U9 a bit further.  What I noticed is my silk screen did not have any pin 1 identification, and this device definitely needs to be oriented correctly when soldered:

After some further investigation, I did in fact solder D9 backwards which results in a forward biased diode directly from VBUS to ground through fuse F3.  I corrected the issue by simply removing D9 for now, and replacing F3 with a new fuse.  (I will be fixing the silkscreen in future revisions of the PCB)

After this change I got the re-assuring ba-da-da-boo from my PC that it recognized a USB device was plugged in.  

I opened my serial monitor and wah lah:

Discussions

schwarzrmsu wrote 12/19/2019 at 03:56 point

I feel like your comment is totally on topic, and is most welcome haha

  Are you sure? yes | no

Ken Yap wrote 12/19/2019 at 02:44 point

A long time ago a humour article in Byte (remember that magazine?) defined UART as a modern version of "thou art"". Sorry for the off topic joke. 😉

Oh and the same article defined serial interface as feeding the baby.

  Are you sure? yes | no