28.3.2.5.1 Control Endpoint

  • If the Respond with STALL (DOSTALL) bit in the Endpoint CTRL is set, the incoming data are discarded. A STALL handshake is returned to the host. The Endpoint STALLED Flags (STALLED) in Endpoint STATUS and in the Interrupt Flags A (INTFLAGSA) register are set.
  • If the Endpoint SETUP Complete Flag (EPSETUP) in the Endpoint STATUS is set, the incoming data are discarded. The Underflow/Overflow Flag (UNFOVF) in the Endpoint STATUS and Underflow Interrupt Flag (UNF) in INTFLAGSA are set. A NAK handshake is returned to the host.
  • If the Data Buffer Not Acknowledge Flag (BUSNAK) in the Endpoint STATUS or the Global NAK (GNAK) bit in the Control B (USB.CTRLB) register is set, the incoming data are discarded. UNFOVF and UNF are set. A NAK handshake is returned to the host.

The data in the data buffer in RAM pointed to by the Endpoint Data Pointer (EP[n].IN.DATAPTR) register is sent to the host in a DATA0 or DATA1 packet according to the Data Toggle (TOGGLE) bit in endpoint STATUS. When the number of data bytes specified in the endpoint’s CNT is sent, the CRC is appended and sent to the host.

The USB peripheral is waiting for an ACK handshake from the host. If an ACK handshake is not received within 16-bit times, the USB peripheral returns to idle and waits for the next token packet. If successfully receiving an ACK handshake, then BUSNACK and Transaction Complete Flag (TRNCOMPL) are set, and TOGGLE is toggled. The endpoint address is written to the FIFO if this is enabled.