STC8H8K64U 的 USB 功能測試(未成功)


對 STC8H8K64U 的 USB 功能測試, 因為存在很多問題並且未能解釋/解決, 就不寫到系列里了, 把記錄放上來拋磚引玉吧.

代碼

測試代碼下載地址 http://www.stcmcudata.com/STC8F-DATASHEET/STC8H8K64U-DEMO-CODE.ZIP , 使用其中的"39-通過USB發送命令讀取ADC測試程序", 用於創建一個 USB HID 設備.

連線

USB口的4線順序

USB Layout: 5V | D- | D+ | GND

連線

USB      STC8H8K64U
5V    -> VCC        # 這一部分的連線會有其它情況
D-    -> P3.0
D+    -> P3.1
         P3.2       # 拉高為運行用戶代碼, 拉低為ISP模式
GND   -> GND

VCC的電壓, 對USB功能是否工作會有影響, 下面分3種情況說明. 測試的是一片lqfp48封裝的 STC8H8K64U, 絲印是B版本, 這些問題也許是個體差異, 需要更多測試判斷

測試

VCC直連5V

Win10 能檢測到 USB 設備, 但是不識別.

Ubuntu20.04 dmesg 輸出

[ 2483.709716] usb 2-3: new full-speed USB device number 31 using xhci_hcd
[ 2483.837738] usb 2-3: device descriptor read/64, error -71
[ 2484.073747] usb 2-3: device descriptor read/64, error -71
[ 2484.309721] usb 2-3: new full-speed USB device number 32 using xhci_hcd
[ 2484.437740] usb 2-3: device descriptor read/64, error -71
[ 2484.673739] usb 2-3: device descriptor read/64, error -71
[ 2484.781788] usb usb2-port3: attempt power cycle
[ 2485.437650] usb 2-3: new full-speed USB device number 33 using xhci_hcd
[ 2485.437786] usb 2-3: Device not responding to setup address.
[ 2485.645720] usb 2-3: Device not responding to setup address.
[ 2485.853705] usb 2-3: device not accepting address 33, error -71
[ 2485.981717] usb 2-3: new full-speed USB device number 34 using xhci_hcd
[ 2486.002557] usb 2-3: device descriptor read/8, error -71
[ 2486.130718] usb 2-3: device descriptor read/8, error -71
[ 2486.237826] usb usb2-port3: unable to enumerate USB device

VCC經兩個1N4148串聯降壓到3.7V

Win10 能檢測到 USB 設備, 但是不識別.

Ubuntu20.04 的 dmesg, 此時能檢測到, 但是應該是有問題的. 在剛開始測試時, 會輸出與上面錯誤狀態一樣的dmesg

[ 2035.215017] usb 2-3: new full-speed USB device number 29 using xhci_hcd
[ 2035.343043] usb 2-3: device descriptor read/64, error -71
[ 2035.601374] usb 2-3: New USB device found, idVendor=5354, idProduct=4380, bcdDevice= 1.00
[ 2035.601389] usb 2-3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 2035.601395] usb 2-3: Product: STC USB Device
[ 2035.601399] usb 2-3: Manufacturer: STC
[ 2036.170978] hid: raw HID events driver (C) Jiri Kosina
[ 2036.176067] usbhid 2-3:1.0: can't add hid device: -71
[ 2036.176082] usbhid: probe of 2-3:1.0 failed with error -71
[ 2036.176133] usbcore: registered new interface driver usbhid
[ 2036.176136] usbhid: USB HID core driver
[ 2083.254934] usb 2-3: USB disconnect, device number 29

[ 2085.559301] usb 2-3: new full-speed USB device number 30 using xhci_hcd
[ 2085.709303] usb 2-3: New USB device found, idVendor=5354, idProduct=4380, bcdDevice= 1.00
[ 2085.709318] usb 2-3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 2085.709323] usb 2-3: Product: STC USB Device
[ 2085.709328] usb 2-3: Manufacturer: STC
[ 2085.711834] usbhid 2-3:1.0: can't add hid device: -71
[ 2085.711867] usbhid: probe of 2-3:1.0 failed with error -71
[ 2340.604515] usb 2-3: USB disconnect, device number 30

VCC使用USB2TTL提供的3.3V

USB 與 USB2TTL 共地

Win10 情況依舊, 在很少數的情況, 能識別出 HID Input 設備, 但是上位機軟件無法檢測識別.

Ubuntu20.04 可以正常識別, 分兩種情況:

將P32通過2KR電阻接3.3V上拉, 最初加電未正常工作, 經過兩次加電, 能看到正確的輸出

[ 1902.282379] usb 2-2: new full-speed USB device number 42 using xhci_hcd
[ 1902.432752] usb 2-2: New USB device found, idVendor=5354, idProduct=4380, bcdDevice= 1.00
[ 1902.432766] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 1902.432771] usb 2-2: Product: STC USB Device
[ 1902.432776] usb 2-2: Manufacturer: STC
[ 1902.436845] input: STC STC USB Device as /devices/pci0000:00/0000:00:14.0/usb2/2-2/2-2:1.0/0003:5354:4380.0003/input/input22
[ 1902.494766] hid-generic 0003:5354:4380.0003: input,hidraw0: USB HID v1.01 Device [STC STC USB Device] on usb-0000:00:14.0-2/input0

USB設備信息

$ lsusb -v
Bus 002 Device 042: ID 5354:4380 Meyer Instruments (MIS) STC USB Device
Couldn't open device, some information will be missing
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x5354 Meyer Instruments (MIS)
  idProduct          0x4380 
  bcdDevice            1.00
  iManufacturer           1 
  iProduct                2 
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x0029
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      iInterface              0 
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.01
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      27
         Report Descriptors: 
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               1
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               1

P32懸空, 會進入ISP模式

[ 1645.193000] usb 2-2: new full-speed USB device number 30 using xhci_hcd
[ 1645.341751] usb 2-2: device descriptor read/all, error -71
[ 1645.468940] usb 2-2: new full-speed USB device number 31 using xhci_hcd
[ 1645.597259] usb 2-2: Device not responding to setup address.
[ 1645.805130] usb 2-2: Device not responding to setup address.
[ 1646.012966] usb 2-2: device not accepting address 31, error -71
[ 1646.013086] usb usb2-port2: attempt power cycle
[ 1646.668947] usb 2-2: new full-speed USB device number 32 using xhci_hcd
[ 1646.669156] usb 2-2: Device not responding to setup address.
[ 1646.877105] usb 2-2: Device not responding to setup address.
[ 1647.084924] usb 2-2: device not accepting address 32, error -71
[ 1647.212913] usb 2-2: new full-speed USB device number 33 using xhci_hcd
[ 1647.238924] usb 2-2: New USB device found, idVendor=34bf, idProduct=1001, bcdDevice= 1.00
[ 1647.238934] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 1647.238939] usb 2-2: Product: USB-ISP
[ 1647.238942] usb 2-2: Manufacturer: STC
[ 1647.242464] input: STC USB-ISP as /devices/pci0000:00/0000:00:14.0/usb2/2-2/2-2:1.0/0003:34BF:1001.0002/input/input21
[ 1647.301225] hid-generic 0003:34BF:1001.0002: input,hidraw0: USB HID v1.01 Device [STC USB-ISP] on usb-0000:00:14.0-2/input0

lsusb -v

Bus 002 Device 033: ID 34bf:1001 STC USB-ISP
Couldn't open device, some information will be missing
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x34bf 
  idProduct          0x1001 
  bcdDevice            1.00
  iManufacturer           1 
  iProduct                2 
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x0029
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      iInterface              0 
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.01
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      23
         Report Descriptors: 
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x84  EP 4 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               1
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x04  EP 4 OUT
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               1

問題

綜上, STC8H 的 USB 功能還是存在一些問題, 也許是使用的方法不對, 這些記錄對其他人也許會有幫助. 待有更多資料再試吧.

參考


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM