Teensy 4.1 USB Host Issues with Silabs CP2105

rogers_sam

New member
Hi all,

Long time lurker, first time posting here.

I've been having an issue using the USBHostt36 library to interface with a specific serial peripheral inside of an existing product. The product has a CP210x USB to UART Bridge between the USB port and the serial port. I only care about bidirectional communication with Device 1 in the diagram below.


image.png

BACKGROUND
When I plug the encoder directly into a pc running the CP210x USB to UART Bridge VCP Drivers, I see two com ports appear, an Enhanced COM Port and a Standard COM Port. The Standard COM Port is the UART connection to Device 1.

2.PNG

Sending commands to the Standard COM Port (Device 1) using Tera Term/Cool Term/Putty yields the expected return message.

3.PNG


I can also send commands to the device through a simple Python script and it was working similarly fine.


WHAT I'VE TRIED
I tried using the native USB port to do direct Serial using Serial.print. No luck.
C++:
void setup() {
    // Initialize Serial Monitor for debugging
    Serial.begin(2000000);
    while (!Serial); // Wait for Serial Monitor to open

    // Initialize Serial1 for communication with the encoder
    Serial1.begin(115200);

    // Initialize pin 13 for LED
    pinMode(13, OUTPUT);
}

void loop() {
    // Blink the LED
    digitalWrite(13, HIGH);
    delay(500); // LED on for 500ms
    digitalWrite(13, LOW);
    delay(500); // LED off for 500ms

    // Check if data is available from Serial1
    if (Serial1.available()) {
        // Read the incoming byte
        char incomingByte = Serial1.read();
        // Print the byte to the Serial Monitor
        Serial.print(incomingByte);
    }
}


I tried using the USB Host cable. This is my latest code. Again, not working. I've tried changing the argument for the USB Serial object, but that still doesn't let me access Device 1. I can, however, read the boot message of Device 0.

C++:
#include <Arduino.h>
#include <USBHost_t36.h>

// USB Host Setup
USBHost nUSB;
USBHub hub1(nUSB);
USBSerial serial1(nUSB);
USBSerial serial2(nUSB);

void setup() {
  Serial.begin(115200);
  while (!Serial); // Wait for serial monitor to connect

  nUSB.begin();

  serial1.begin(115200); // Set baud rate for the first UART device
  serial2.begin(115200); // Set baud rate for the second UART device
  Serial.println("Teensy USB Host Serial started");
}

void loop() {
  nUSB.Task();

  if (serial1.available()) { // Check if data is available on the first UART
    int byteFromDevice1 = serial1.read(); // Read the data
    Serial.print(char(byteFromDevice1)); // Print data from Device 1
  }

  if (serial2.available()) { // Check if data is available on the second UART
    int byteFromDevice2 = serial2.read(); // Read the data
    Serial.print(char(byteFromDevice2)); // Print data from Device 2
  }

  if (Serial.available()) { // Check if data is to be sent from the serial monitor
    char c = Serial.read();
    serial1.write(c); // Send received character to Device 1
    serial2.write(c); // Send received character to Device 2
  }
}

Which I know is from device 0 since it's the HPS UBOOT output:

U-Boot 2014.10 (Aug 10 2023 - 09:46:05)
CPU : Altera SOCFPGA Arria 10 Platform
BOARD : Altera SOCFPGA Arria 10 Dev Kit
I2C: ready
DRAM: WARNING: Caches not enabled
SF: Read data capture delay calibrated to 3 (0 - 6)
SF: Detected N25Q1024 with page size 256 Bytes, erase size 4 KiB, total 128 MiBFull Configuration Succeeded.
SF: Detected N25Q1024 with page size 256 Bytes, erase size 4 KiB, total 128 MiBDDRCAL: Success
INFO : Skip relocation as SDRAM is non secure memory
Reserving 2048 Bytes for IRQ stack at: ffe3a6e8
DRAM : 512 MiB
WARNING: Caches not enabled
SF: Read data capture delay calibrated to 8 (0 - 15)
SF: Detected N25Q1024 with page size 256 Bytes, erase size 4 KiB, total 128 MiB
*** Warning - bad CRC, using default environment


I'm not sure where to go from here, and would appreciate some advice. Not sure if there is something about targeting a specific interface that I'm missing.
 
Judging from the screenshot of the hardware properties, the enhanced port is interface 0 and the standard port is interface 1. From what I can tell the CP210x driver in the USBHost_t36 library only uses interface 0, it would require a bunch of changes to use interface 1.
 
Back
Top