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:

Send the SET_LINE_CODING request through Endpoint 0x00 with the following parameters:
ParameterValueDescription
bRequest type0x21Host to device
bRequest code0x20SET_LINE_CODING request code
wValue0x0000
wIndex0x0000Interface 0
wPayload length0x0007Payload length
dwBaudrate 0xdwBaudrateBaudrate in 32-bit hexadecimal format
bNumber of Stop bits0x00

0x02

One Stop bit

Two Stop bits

bParity type0x00

0x01

0x02

No parity

Odd parity

Even parity

bData width in bits0x05 - 0x8Data width in bits
Send the SET_CONTROL_LINE_STATE request through Endpoint 0x00 with the following parameters:
ParameterValueDescription
bRequest type0x21Host to device
bRequest code0x22SET_CONTROL_LINE_STATE request code
wValue0x0003RTS line asserted
wIndex0x0000Interface 0
wPayload length0x0000Payload length
When terminal emulators, such as PuTTY, Tera Term, VS Code Serial Monitor, or any other applications are used, they take care of sending the above requests.

Data Transfer

Transmit:

  1. Wait until CTS is asserted (skip this step if flow control is not used).
  2. Write to Endpoint 0x02 (OUT).

Continue the above steps until all the data are transmitted.

Receive:

  1. Read from Endpoint 0x82 (IN)

Repeat the above step until Endpoint 0x82 (IN) is empty.

Abort/Close Communication:

Send the SET_CONTROL_LINE_STATE request through Endpoint 0x00 with the following parameters:
ParameterValueDescription
bRequest type0x21Host to device
bRequest code0x22SET_CONTROL_LINE_STATE request code
wValue0x0000RTS line deasserted
wIndex0x0000Interface 0
wPayload length0x0000Payload 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 error
  • 0x2x → Parity error