cancel
Showing results for 
Search instead for 
Did you mean: 

USART communications act strangely with USB & Android

treyvr
Associate II

The FLASH has (what will become) a bootloader, and an application.

I can successfully jump from bootloader to application without issue.

The application communicates over USART, through a CP210x components, to a USB-A connector, and to an Android application I built for communicating over this serial connection.

I copied the .ioc file from the application to configure the bootloader.  And if I plug that USB-A connector into my desktop instead of the Android device, I can see the bootloader's messages over the USB-A connector.  But I cannot see these on the Android device.

So, the bootloader outputs over USART, through the CP210x, to the desktop (running Linux), and displays on the console.  But if I follow the same exact steps to trigger the communication, and I use the Android app instead, it won't display the bootloader's output... but after the bootloader jumps to the application, it will display the application's output (both on my desktop, and my Android device).

The firmware in both cases uses the HAL_UART_Transmit() to send the data, with the 'huart1' handle from usart.c as generated by the .ioc file.

In both cases, the firmware configures the clock and UART identically (same .ioc, same code generated).

I'm stumped about what might be going on.  I should have expected something more consistent (like nothing ever transmit on Android but works on Desktop, maybe), but this doesn't make much sense to me.

Does this look familiar to anyone?

2 REPLIES 2
NEdom.1
Associate III

Are you using the CP210x USB-A TTL UART connector both on the desktop and on Android with OTG?

Maybe you need to check the USART pin setup in the bootloader and your main app. Check what's the difference between such as baud rate, IO driven type (APP, PU or PD).

There are some of the UART hardware which need the USART TX/RX to be pull-up in order to keep he proper voltage level while not driven by either side.

Also, the CP210x need to be setup correctly on Android devices before communication.

RE: Am I using the same CP210x USB-A TTL UART connector on desktop and Android

Yes.  The hardware is the same, and the firmware's setup is the same, the only difference is the device the USB-A end is plugged into (desktop vs. Android OS).  And, of course, the software on those separate devices.

Looked over baud rates, etc.  All identical.  The .ioc files match, as does the resulting code.  This is entirely why I'm baffled as to why I never see output over the line on Android in the bootloader, but I do on the Desktop... yet I do see output over the line from the firmware on Android (as well as the Desktop).

RE: Setting up Android to work with the CP210x...

Setting this up was a bit tricky, but I used a library and some examples to help me out.  I do receive output over the USB-A connection to the app when the device hits the firmware, but not the bootloader, so I know that the app's side is set up correctly.