Microcontroller not recognized at USB port when connected via pins - c

Im having issues with my TI LAUNCHXL-F28379D. I have it connected to the laptop I am trying to send data to/from via pins P19 (SCIBRxD) and P18 (SCIBTxD), as well as GND and 5V via J16, using a USB Type B cord to which I sautered pin connectors. I'm sure power is being supplied to the board as when I plug the 5V cable of the USB cable, the RGB lights and 3 other small ones turn on. However, the Computer does not recognize ithe controller at the port - it only recognizes if if it is connected via the board's Mini-USB port. I've also written a C Program which opens the COM port and reads data - but this does not work without my knowledge of the COM port number, usually found in Device Manager. I cannot get any further in my project without the port number and it is very annoying. I will attempt to resauter a new USB cable, but if there are any other possible solutions, or if I'm doing something wrong, please let me know.
Absolutely all feedback is appreciated!

The SCIBRxD and SCIBTxD pins belong to the SCI peripheral in the microcontroller. This peripheral implements a UART port (a.k.a. COM port, a.k.a. TTL serial port). It is not a USB port. Nothing useful will happen if you connect it to a USB port, because it is not compatible with USB in any way.
USB-to-UART adapters (a.k.a. USB-to-serial adapters) do exist. There is one built into the LaunchPad. The UART side of the adapter is connected to the SCIB pins, and the USB side of the adapter is connected to the USB port.

Related

How to detect when USB is disconnected?

I use a virtual com port for communication between the microcontroller and the computer.
I have mk. stm32h743 self-powered from its own 3.3V power supply. With the help of a cube, I raised a virtual com port. How can you understand that the USB is disconnected from the device ? When you connect Usb, it calls "CDC_Init_FS" and hUsbDeviceFS.dev_state is set to 3, which corresponds to "USBD_STATE_CONFIGURED". But when you disconnect the USB there is no callback "HAL_PCD_DisconnectCallback (PCD_HandleTypeDef * hpcd);"Why "HAL_PCD_DisconnectCallback (PCD_HandleTypeDef * hpcd);" not called when USB is disabled?
I have no way to track Vbus voltages. So I did it like this :
void HAL_PCD_SuspendCallback(PCD_HandleTypeDef hpcd)
{
USBD_LL_Suspend((USBD_HandleTypeDef)hpcd->pData);
__HAL_PCD_GATE_PHYCLOCK(hpcd);
if (hpcd->Init.low_power_enable)
{
SCB->SCR |= (uint32_t)((uint32_t)(SCB_SCR_SLEEPDEEP_Msk |
SCB_SCR_SLEEPONEXIT_Msk));
}
SBD_LL_DevDisconnected(&hUsbDeviceFS);
}
Hello.
I have a problem with USB working properly - USB CDC (Virtual Com Port) with CubeMX HAL after disconnecting the USB cable and connecting again.
For the test I created a project similar to the one presented here - https://www.youtube.com/watch?v=AYICE0gU-Sg using STM32CubeIDE and STM32CubeMX.
The program writes data in the while (1) loop to the USB port after uploading to STM32.
while(1)
{
CDC_Transmit_FS(buffer, sizeof(buffer));
HAL_Delay(1000);
}
The data is written out, visible in Windows 7 (Tera Term).
When I disconnect the USB cable (OTG FS port) and reconnect, Windows sends the message "USB device not recognized".
Data is not received.
In order for the data to be transferred and the cable to be recognized, I must do a Reset on the board.
Hardware:
MCU: STM32H743VIT
Software: STM32CubeIDE v1.2
Firmware package: STM32Cube_FW_H7_V1.7.0
How to make the USB device work all the time correctly (after disconnecting the cable and reconnecting it), so that it is recognized by Windows and data is transferred?

How does serial console communication work in a microcontroller?

My doubt is regarding the physical layer of the communication, I know from practice that for using for example teraterm to communicate with a MCU is simply enabling and configuring an UART peripheral, and then connect via USB the microcontroller and voila.
But it doesnt make sense to me yet that if USB connects to DN and DP, and an UART uses RX and TX, how does the host effectively communicates to the microcontroller?
There are two possibilities.
You connect to a USB/UART bridge such as devices made by FTDI or Prolific,
The microcontroller has a USB device controller and USB stack implementing the CDC/ACM device class (virtual COM port).
In the first instance, the bridge chip presents the CDC/ACM device to the host and exchanges data with a UART connected to the microcontroller UART. I/O control such as setting the baud rate have no impact on the USB connection, rather they are used to configure the UART link.
In the bridge arrangement, the bridge chip may be on the micro board, or it may be in a USB/serial adapter cable. Moreover internally the bridge chip is a microcontroller with a CDC/ACM device stack.
Unlike say RS-232, USB is not a peer-to-peer full duplex connection, and is not merely an electrical connection; USB requires quite complex device and host controllers and is more analogous to a device bus such as PCI than it is to UART serial connections. A CDC/ACM class device conforms to a specific protocol to allow a "virtual" UART to appear at the host. The UART you see at the PC is emulated, and is not physically the UART in the bridge.
The physical actual USB connection is a master-slave connection, with data and I/O control commands (such as baud rate and flow control) sent in USB packets to be unpacked, interpreted and transferred to the application layer via the CDC/ACM USB stack. In this arrangement the device, acting as a slave cannot initiate an exchange; rather the host continuously polls the device to which the device may return a packet containing its "tx" data. The polling and data rate of USB are fast enough to allow the simplex master-slave exchange to emulate a full-duplex UART connection, at higher throughput than can normally be achieved by a typical real UART, and certainly faster than a physical RS-xxx connection.
You can get an idea of how all this works by observing the raw USB data exchange using a tool such as WireShark. You will see that a lot more than just your application "serial" data is being exchanged.
You need to use a uart-usb interface IC that can convert uart to usb (and vice versa).

Verify whether two usb devices are connected on the same hub

I have a microcontroller board which has a USB hub to which several CP2108 USB to serial modules are connected and one PIC Microcontroller is connected.
The USB hub is connected to Laptop USB Port..
The CP2108 devices are assigned /dev/ttyUSB0, /dev/ttyUSB1 ID's, whereas the PIC Microcontroller is assigned a /dev/usb/abc.
If I connect another USB device to Laptop USB Port, it will get /dev/ttyUSB2
I want to verify whether /dev/ttyUSB and /dev/usb/abc are on the same hub and not on different one..
Is there any way to find out through code.. I tried to look into sysfs , but I am unable to find out the difference

Linux Serial Device Server over USB?

I have an embedded Linux solution and want to create a command service over serial USB. The idea being that when a computer connects to my embedded via USB, they see a serial device and send serial commands to me through that port and I send responses back.
I need some help in the direction to proceed. Do I need to emulate a serial device so they see me as a COM port? Is there build in Linux solutions to broadcast my details as a serial device? Are there code examples? I can see block devices connect with my embedded solution like a USB storage device. When I plug into another computer, I would like it to see me as a serial COM port.
I just need help in the direction of which path I should go down to solve this.
Thanks in advance.
What you are looking for is the Linux USB serial gadget. The Linux USB gadgets framework allows devices to behave as a variety of standard USB devices, including serial devices, Ethernet adapters, and mass storage devices.
Note that USB gadgets will only work on targets with a USB controller that can be set to operate as a USB device. Not all USB controllers and target devices are compatible with this configuration. For instance, most PCs have a host-only USB controller, and the Raspberry Pi Model B is not compatible with gadgets because it contains an embedded USB hub upstream of the USB ports. (However, the Pi Zero is fully compatible with gadgets.)

How to read data from USB port using C

I have sensor node connected to USB port that sense temperature, humidity and light and send the data to PC.
What piece of code will help me to read that data from the USB port in normal C.
Application of the nodes is built on C using Eclipse.
I looked into the specifications of your board and it seems like it's a FTDI chip. This means it's exactly the same way you read from a serial port.
Here is how you program the serial port in Windows (it hasn't changed in a long time).

Resources