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.

Table 27-2. Available Interrupt Vectors and Sources
NameVector DescriptionInterrupt FlagConditions
TRNCOMPLTransaction Complete interruptTRNCOMPLAn IN or OUT transaction is completed
GNDONEGlobal NAK is enabled and has completely propagated through the USB logic so that all USB transactions will be NAKed
SETUPA SETUP transaction is completed
BUSEVENTBus Event interruptSOFA SOF token has been received
SUSPENDThe bus has been idle for 3 ms
RESUMEA non-idle state is detected when the bus is suspended
RESETA reset condition has been detected on the bus
STALLEDA STALL handshake has been returned to the host
UNFAn endpoint is unable to return data to the host
OVFAn 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:

Table 27-3. Transaction Complete Interrupt Sources
Interrupt SourceDescription
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:

Table 27-4. Bus Event Interrupt Sources
Interrupt SourceDescription
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