Difference between revisions of "WCH CH9325"
Uwe Hermann (talk | contribs) m |
|||
Line 1: | Line 1: | ||
[[File:Uni-t ut61d cable pcb front.jpg|thumb|right|WCH CH9325 in the [[Device_cables#UNI-T_UT-D04|UNI-T UT-D04]] DMM cable.]] | |||
[[File:Uni-t ut325 wch ch9325.jpg|thumb|right|WCH CH9325 in the [[UNI-T UT325]] temperature logger.]] | |||
[http://www.wch.cn/ WCH], also known as Nanjing Qin Heng Electronics, makes a series of microcontrollers, PCI interface chips, and USB interface chips. | [http://www.wch.cn/ WCH], also known as Nanjing Qin Heng Electronics, makes a series of microcontrollers, PCI interface chips, and USB interface chips. | ||
Revision as of 18:39, 3 August 2013
WCH, also known as Nanjing Qin Heng Electronics, makes a series of microcontrollers, PCI interface chips, and USB interface chips.
The CH9325 is a USB interface chip, which converts data received via UART to USB and vice versa. The chip presents a HID (Human Interface Device) USB profile, in an effort to not require USB driver installation: this is typically handled by the OS kernel. An example of the profile, in Linux 'lsusb' output format, is here.
The chip runs off of a 12MHz oscillator.
Pin layout
1- | O | -16 | ||
UART TX | 2- | -15 | USB +5V | |
UART RX | 3- | -14 | ||
4- | -13 | |||
5- | -12 | |||
USB D+ | 6- | -11 | ||
USB D- | 7- | -10 | OSC+ | |
GND | 8- | -9 | OSC- |
Protocol
The chip stores bytes received via the UART RX pin into a buffer. It transfers the contents of the buffer to a HID packet at regular intervals (maximum 12ms). The HID packets are always 8 bytes long, with the first byte containing the number of payload bytes. This is encoded as 0xf0 + length. The next 7 bytes contain the payload, padded with zeroes. Thus, even if no data is ever received on the UART, the chip always sends at least one packet every 12ms containing:
f0 00 00 00 00 00 00 00
Here's a packet with 2 bytes payload:
f2 35 41 00 00 00 00 00
Extracting the UART stream on the other side of the USB bus simply entails the reverse process: for every received packet, extract the payload according to the length byte (nibble).