USB Endpoints

Last modified by Microchip on 2023/11/10 11:19

The mechanisms used for Universal Serial Bus (USB) communication are data buffers called endpoints. Endpoints exist on the device and are typically implemented in CPU registers or dual-port memory.

Endpoints are unidirectional, i.e., each endpoint is designed to transmit data in one direction. OUT endpoints send data out of the host to the device. IN endpoints take data from the device intended to go into the host. Endpoints exist in numbered pairs and each pair contains an OUT and an IN endpoint.

Endpoint 0 (EP0IN and EP0OUT) is reserved in every device for control purposes. Control endpoints are used during enumeration, providing the host the ability to read the device descriptor tables and to send control commands to the device during normal application execution.

USB endpoints

A USB device can have up to 32 endpoints (16 OUT and 16 IN). Since EP0IN and EP0OUT are set aside as control endpoints, the maximum number of endpoints available to transmit application data is 30.

Software Considerations

Communication between the host and the device is asynchronous over USB. The device is not informed when a host-initiated transfer starts. A USB device must proactively check if a data packet has been received from the host. If the device were to read or write to an endpoint while a host transaction is accessing the endpoint, the result could corrupt the data.

Microchip’s USB software, combined with the dual-port implementation of the endpoints on PIC® MCUs, prevents the corruption of endpoint data. Microchip arbitrates between the host and the device, resulting in exclusive access to the endpoint memory.

USB endpoint memory

Learn More