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 功能还是存在一些问题, 也许是使用的方法不对, 这些记录对其他人也许会有帮助. 待有更多资料再试吧.
参考
- USB下载的说明 https://www.stcisp.com/stc15-usb-isp-d1.html
- USB HID 跨平台库 libusb/hidapi
标签:USB,STC,STC8H8K64U,功能测试,Device,71,device,usb 来源: https://www.cnblogs.com/milton/p/15864540.html