27.3.5 Interrupts
The peripheral has ten interrupt sources. These are split between two interrupt vectors, the transaction complete (TRNCOMPL) interrupt and the bus event (BUSEVENT) interrupt. An interrupt group is enabled by setting its interrupt level (INTLVL), while different interrupt sources are enabled individually or in groups.
The table below summarizes the interrupts and event sources for the USB peripheral and shows how they are enabled.
Name | Vector Description | Interrupt Flag | Conditions |
---|---|---|---|
TRNCOMPL | Transaction Complete interrupt | TRNCOMPL | An IN or OUT transaction is completed |
GNDONE | Global NAK is enabled and has completely propagated through the USB logic so that all USB transactions will be NAKed | ||
SETUP | A SETUP transaction is completed | ||
BUSEVENT | Bus Event interrupt | SOF | A SOF token has been received |
SUSPEND | The bus has been idle for 3 ms | ||
RESUME | A non-idle state is detected when the bus is suspended | ||
RESET | A reset condition has been detected on the bus | ||
STALLED | A STALL handshake has been returned to the host | ||
UNF | An endpoint is unable to return data to the host | ||
OVF | An endpoint is unable to accept data from the host |
When an interrupt condition occurs, the corresponding interrupt flag is set in the peripheral’s Interrupt Flags (peripheral.INTFLAGS) register.
An interrupt source is enabled or disabled by writing to the corresponding enable bit in the peripheral’s Interrupt Control (peripheral.INTCTRL) register.
An interrupt request is generated when the corresponding interrupt source is enabled, and the interrupt flag is set. The interrupt request remains active until the interrupt flag is cleared. See the peripheral’s INTFLAGS register for details on how to clear interrupt flags.
Transaction Complete Interrupt
The transaction complete interrupt is generated per endpoint. When an interrupt occurs, the associated endpoint number is registered and optionally added to the FIFO. The following three interrupt sources use the interrupt vector:
Interrupt Source | Description |
---|---|
Transfer complete (TRNCOMPL) | An IN or OUT transaction is completed |
GNAK operation done (GNDONE) | Global NAK is enabled and has completely propagated through the USB logic so that all USB transactions will be NAKed |
Setup complete (SETUP) | A SETUP transaction is completed |
Bus Event Interrupt
The bus event (BUSEVENT) interrupt is used for all interrupts that signal various types of USB line events or error conditions. These interrupts are related to the USB lines and are generated for the USB peripheral and per endpoint. The following seven interrupts use the interrupt vector:
Interrupt Source | Description |
---|---|
Start of frame (SOF) | A SOF token has been received |
Suspend (SUSPEND) | The bus has been idle for 3 ms |
Resume (RESUME) | A non-idle state is detected when the bus is suspended. The interrupt is asynchronous and can wake the device from all sleep modes. |
Reset (RESET) | A reset condition has been detected on the bus |
STALL (STALLED) | A STALL handshake has been returned to the host |
Underflow (UNF) | An endpoint is unable to return data to the host |
Overflow (OVF) | An endpoint is unable to accept data from the host |