4.1.5 UART Communication Procedure
This section describes the typical command sequence for using the MCP2222 for I2C communication.
If hardware flow control needs to be enabled, ensure that IO0 and IO1 are configured as CTS and RTS pins, respectively.
Configure UART:
| Parameter | Value | Description |
|---|---|---|
| bRequest type | 0x21 | Host to device |
| bRequest code | 0x20 | SET_LINE_CODING request code |
| wValue | 0x0000 | |
| wIndex | 0x0000 | Interface 0 |
| wPayload length | 0x0007 | Payload length |
| dwBaudrate | 0xdwBaudrate | Baudrate in 32-bit hexadecimal format |
| bNumber of Stop bits | 0x00
| One Stop bit Two Stop bits |
| bParity type | 0x00
| No parity Odd parity Even parity |
| bData width in bits | 0x05 - 0x8 | Data width in bits |
| Parameter | Value | Description |
|---|---|---|
| bRequest type | 0x21 | Host to device |
| bRequest code | 0x22 | SET_CONTROL_LINE_STATE request code |
| wValue | 0x0003 | RTS line asserted |
| wIndex | 0x0000 | Interface 0 |
| wPayload length | 0x0000 | Payload length |
Data Transfer
Transmit:
- Wait until CTS is asserted (skip this step if flow control is not used).
- Write to Endpoint 0x02 (OUT).
Continue the above steps until all the data are transmitted.
Receive:
- Read from Endpoint 0x82 (IN)
Repeat the above step until Endpoint 0x82 (IN) is empty.
Abort/Close Communication:
| Parameter | Value | Description |
|---|---|---|
| bRequest type | 0x21 | Host to device |
| bRequest code | 0x22 | SET_CONTROL_LINE_STATE request code |
| wValue | 0x0000 | RTS line deasserted |
| wIndex | 0x0000 | Interface 0 |
| wPayload length | 0x0000 | Payload length |
Error Notification:
If any error occurs during communication (reception), it is reported using the SERIAL_STATE notification through Interrupt Endpoint 0x01 (IN). The byte indexed 8 represents the error status.
0x1x→ Framing error0x2x→ Parity error
