Built-in Statistics

Built-in Statistics

This page details the way to interpret the various statistics that can be accessed within µC/USB-Device.

Configuration

In usbd_cfg.h, USBD_CFG_DBG_STATS_EN must be set to DEF_ENABLED.

By default, constant USBD_CFG_DBG_STATS_CNT_TYPE is set to CPU_INT08U, meaning that the counter will overflow after counting 256 events. This constant can be set to CPU_INT16U or CPU_INT32U to increase the overflow limit.

It is recommended that the statistics feature is turned OFF for 'release' code, since a good amount of RAM is used to keep the statistics counters.

Accessing statistics

The statistics can be accessed easily from any scope (application, class, core, driver, etc), simply by monitoring the variables USBD_DbgStatsDevTbl[] and USBD_DbgStatsEP_Tbl[]. This can usually be done by using a regular debugger.

Content

The statistics are split in two levels: device level and endpoint level. The following tables gives information about the fields of each of these structures. Please note that even though each endpoint has a complete statistics structure associated with it, since an endpoint only works in on direction, only the Rx or Tx fields will be used for a given endpoint. That is, if the endpoint is an IN endpoint, only the Tx fields will be modified. If the endpoint is an OUT endpoint, the Rx fields will be the only ones modified.

Device Level

The table USBD_DbgStatsDevTbl[] contains USBD_CFG_MAX_NBR_DEV number of USBD_DBG_STATS_DEV struct, one for each device. The device number is used as an index to access a specific device's statistics.

Field Name

Explanation

Relates to...

Field Name

Explanation

Relates to...

DevNbr

Number of the device, starting at 0.

The device number depends of the order in which the device is added using USBD_DevAdd.

DevResetEventNbr

Number of reset event on the bus.

Should be 2 after minimal enumeration.

DevSuspendEventNbr

Number of suspend event on the bus.

Should be 2 after minimal enumeration.

DevResumeEventNbr

Number of resume event on the bus.

Should be 1 after minimal enumeration.

DevConnEventNbr

Number of connection event of the device.

Varies.

DevDisconnEventNbr

Number of disconnection event of the device.

Varies.

DevSetupEventNbr

Number of SETUP packets the device received.

Should be 10-11 after minimal enumeration, depending if Windows requests its OS descriptor or not.

StdReqDevNbr

Number of standard requests having 'device' as a recipient.

Should be 10-11 after minimal enumeration, depending if Windows requests its OS descriptor or not and if it fails or not.

StdReqDevStallNbr

Number of standard requests having 'device' as a recipient that failed to be processed.

Should normally be equal to 0. It can be 1, if Windows requests its OS descriptor and it fails (or USBD_CFG_MS_OS_DESC_EN is set to DEF_DISABLED).

StdReqIF_Nbr

Number of standard requests having 'interface' as a recipient.

Should be 0 after minimal enumeration.

StdReqIF_StallNbr

Number of standard requests having 'interface' as a recipient that failed to be processed.

Should normally be equal to 0.

StdReqEP_Nbr

Number of standard requests having 'endpoint' as a recipient.

Should be 0 after minimal enumeration.

StdReqEP_StallNbr

Number of standard requests having 'endpoint' as a recipient that failed to be processed.

Should normally be equal to 0.

StdReqClassNbr

Number of standard requests having a class as a recipient.

Should be 0 after minimal enumeration.

StdReqClassStallNbr

Number of standard requests having a class as a recipient that failed to be processed.

Should normally be equal to 0.

StdReqSetAddrNbr

Number of SET_ADDRESS standard request the device received.

Should be equal to 1 after a successful enumeration.

StdReqSetCfgNbr

Number of SET_CONFIGURATION standard request the device received.

Should be equal to 1 after a successful enumeration.

CtrlRxSyncExecNbr

Number of synchronous receive operation started on a control endpoint type.

Varies with usage. Used throughout enumeration. Should be 0 after minimal enumeration.

CtrlRxSyncSuccessNbr

Number of synchronous receive operation on a control endpoint type that completed successfully.

Should be equal to CtrlRxSyncExecNbr.

CtrlTxSyncExecNbr

Number of synchronous transmit operation started on a control endpoint type.

Varies with usage. Used throughout enumeration. Should be 9 after minimal enumeration.

CtrlTxSyncSuccessNbr

Number of synchronous transmit operation on a control endpoint type that completed successfully.

Should be equal to CtrlTxSyncExecNbr.

CtrlRxStatusExecNbr 

Number of status packets attempted to be received from the host.

Varies with usage. Used throughout enumeration. Should be 9 after minimal enumeration.

CtrlRxStatusSuccessNbr

Number of status packets successfully received from the host

Should be equal to CtrlRxStatusExecNbr.

CtrlTxStatusExecNbr

Number of status packets attempted to be sent to the host.

Varies with usage. Used throughout enumeration. Should be 1 after minimal enumeration.

CtrlTxStatusSuccessNbr

Number of status packets successfully sent to the host

Should be equal to CtrlTxStatusExecNbr.

BulkRxSyncExecNbr

Number of synchronous receive operation started on a bulk endpoint type.

Varies with usage. Used by CDC, MSC, PHDC and vendor class synchronous demo.

BulkRxSyncSuccessNbr

Number of synchronous receive operation on a bulk endpoint type that completed successfully.

Should be equal to BulkRxSyncExecNbr.

BulkTxSyncExecNbr

Number of synchronous transmit operation started on a bulk endpoint type.

Varies with usage. Used by CDC, MSC, PHDC and vendor class synchronous demo.

BulkTxSyncSuccessNbr

Number of synchronous transmit operation on a bulk endpoint type that completed successfully.

Should be equal to BulkTxSyncExecNbr.

IntrRxSyncExecNbr

Number of synchronous receive operation started on an interrupt endpoint type.

Varies with usage. Used by HID class read/write demo and vendor class synchronous demo.

IntrRxSyncSuccessNbr

Number of synchronous receive operation on an interrupt endpoint type that completed successfully.

Should be equal to IntrRxSyncExecNbr.

IntrTxSyncExecNbr

Number of synchronous transmit operation started on an interrupt endpoint type.

Varies with usage. Used by PHDC and vendor class synchronous demo.

IntrTxSyncSuccessNbr

Number of synchronous transmit operation on an interrupt endpoint type that completed successfully.

Should be equal to IntrTxSyncExecNbr.

BulkRxAsyncExecNbr

Number of asynchronous receive operation started on a bulk endpoint type.

Varies with usage, used by vendor class asynchronous demo.

BulkRxAsyncSuccessNbr

Number of asynchronous receive operation on a bulk endpoint type that completed successfully.

Should be equal to BulkRxAsyncExecNbr.

BulkTxAsyncExecNbr

Number of asynchronous transmit operation started on a bulk endpoint type.

Varies with usage, used by vendor class asynchronous demo.

BulkTxAsyncSuccessNbr

Number of asynchronous transmit operation on a bulk endpoint type that completed successfully.

Should be equal to BulkTxAsyncExecNbr.

IntrRxAsyncExecNbr

Number of asynchronous receive operation started on an interrupt endpoint type.

Varies with usage, used by vendor class asynchronous demo.

IntrRxAsyncSuccessNbr

Number of asynchronous receive operation on an interrupt endpoint type that completed successfully.

Should be equal to IntrRxAsyncExecNbr.

IntrTxAsyncExecNbr

Number of asynchronous transmit operation started on an interrupt endpoint type.

Varies with usage, used by CDC, HID class mouse and read/write demo and in vendor class asynchronous demo.

IntrTxAsyncSuccessNbr

Number of asynchronous transmit operation on an interrupt endpoint type that completed successfully.

Should be equal to IntrTxAsyncExecNbr.

IsocRxAsyncExecNbr

Number of asynchronous receive operation started on an isochronous endpoint type.

Varies with usage, used by audio class when playback is enabled.

IsocRxAsyncSuccessNbr

Number of asynchronous receive operation on an isochronous endpoint type that completed successfully.

Should be equal to IsocRxAsyncExecNbr.

IsocTxAsyncExecNbr

Number of asynchronous transmit operation started on an isochronous endpoint type.

Varies with usage, used by audio class when record is enabled.

IsocTxAsyncSuccessNbr

Number of asynchronous transmit operation on an isochronous endpoint type that completed successfully.

Should be equal to IsocTxAsyncExecNbr.

A minimal enumeration is considered to be a successful enumeration without any classes enabled.

Endpoint Level

The table USBD_DbgStatsEP_Tbl[] contains USBD_CFG_MAX_NBR_DEVUSBD_CFG_MAX_NBR_EP_OPEN number of USBD_DBG_STATS_EP struct, one for each potentially opened endpoint of each device. The device number and the endpoint's index are used as indexes to access a specific endpoint's statistics. It is also possible to simply browse the content of the USBD_DBG_STATS_EP struct to find the required endpoint address.

Field Name

Explanation

Relates to...

Field Name

Explanation

Relates to...

Addr

Address of the endpoint. The statistics of a given endpoint are kept if it is closed and then re-opened, if it uses the same endpoint structure. Otherwise, the statistics are reset when the endpoint is opened.

 

EP_OpenNbr

Number of times the endpoint was opened successfully.

Should be equal to 2 after minimal enumeration (the endpoint is closed and re-opened upon device reset).

EP_AbortExecNbr

Number of times an abort operation has been started.

Should be equal to 0.

EP_AbortSuccessNbr

Number of times an abort operation has completed successfully.

Should be equal to EP_AbortExecNbr.

EP_CloseExecNbr

Number of times a close operation has been started.

Should be equal to 1 after minimal enumeration (the endpoint is closed upon device reset).

EP_CloseSuccessNbr

Number of times a close operation has completed successfully.

Should be equal to EP_CloseExecNbr.

RxSyncExecNbr

Number of times a synchronous receive operation has been started.

Should be equal to 0 after minimal enumeration.

RxSyncSuccessNbr

Number of times a synchronous receive operation has completed successfully.

Should be equal to RxSyncExecNbr.

RxSyncTimeoutErrNbr

Number of times a synchronous receive operation has timed out.

Varies with the type of application and transfer used, whether transfers are blocking or non-blocking, the protocol used by the application, etc.

RxAsyncExecNbr

Number of times an asynchronous receive operation has been started.

Should be equal to 0 after minimal enumeration.

RxAsyncSuccessNbr

Number of times an asynchronous receive operation has completed successfully.

Should be equal to RxAsyncExecNbr. At this point, the receive operation has been successfully signaled to the USB-Device core. It does not mean that the whole transfer has completed.

RxZLP_ExecNbr

Number of times a zero-length packet receive operation has been started.

Should be equal to 9 after minimal enumeration.

RxZLP_SuccessNbr

Number of times a zero-length packet receive operation has completed successfully.

Should be equal to RxZLP_ExecNbr.

TxSyncExecNbr

Number of times a synchronous transmit operation has been started.

Should be equal to 9 after minimal enumeration.

TxSyncSuccessNbr

Number of times a synchronous transmit operation has completed successfully.

Should be equal to TxSyncExecNbr.

TxSyncTimeoutErrNbr

Number of times a synchronous transmit operation has timed out.

Varies with the type of application and transfer used, whether transfers are blocking or non-blocking, the protocol used by the application, etc.

TxAsyncExecNbr

Number of times an asynchronous transmit operation has been started.

Should be equal to 0 after minimal enumeration.

TxAsyncSuccessNbr

Number of times an asynchronous transmit operation has completed successfully.

Should be equal to TxAsyncExecNbr. At this point, the transmit operation has been successfully signaled to the USB-Device core. It does not mean that the whole transfer has completed.

TxZLP_ExecNbr

Number of times a zero-length packet transmit operation has been started.

Should be equal to 1 after minimal enumeration.

TxZLP_SuccessNbr

Number of times a zero-length packet transmit operation has completed successfully.

Should be equal to TxZLP_ExecNbr.

DrvRxStartNbr

Number of times the driver's EP_RxStart() function was called.

Should be equal to 9 after minimal enumeration.

DrvRxStartSuccessNbr

Number of times the driver's EP_RxStart() function was called successfully.

Should be equal to DrvRxStartNbr.

DrvRxNbr

Number of times the driver's EP_Rx() function was called.

Should be equal to 0 after minimal enumeration.

DrvRxSuccessNbr

Number of times the driver's EP_Rx() function was called successfully.

Should be equal to DrvRxNbr.

DrvRxZLP_Nbr

Number of times the driver's EP_RxZLP() function was called.

Should be equal to 9 after minimal enumeration.

DrvRxZLP_SuccessNbr

Number of times the driver's EP_RxZLP() function was called successfully.

Should be equal to DrvRxZLP_Nbr.

RxCmplNbr

Number of times the driver has called USBD_EP_RxCmpl().

Should be equal to 9 after minimal enumeration.

RxCmplErrNbr

Number of times the driver's call to USBD_EP_RxCmpl failed.

Should be equal to 0.

DrvTxNbr

Number of times the driver's EP_Tx() function was called.

Should be equal to 9 after minimal enumeration.

DrvTxSuccessNbr

Number of times the driver's EP_Tx() function was called successfully.

Should be equal to DrvTxNbr.