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... |
|---|---|---|
| Number of the device, starting at 0. | The device number depends of the order in which the device is added using |
| Number of reset event on the bus. | Should be 2 after minimal enumeration. |
| Number of suspend event on the bus. | Should be 2 after minimal enumeration. |
| Number of resume event on the bus. | Should be 1 after minimal enumeration. |
| Number of connection event of the device. | Varies. |
| Number of disconnection event of the device. | Varies. |
| Number of SETUP packets the device received. | Should be 10-11 after minimal enumeration, depending if Windows requests its OS descriptor or not. |
| 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. |
| 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 |
| Number of standard requests having 'interface' as a recipient. | Should be 0 after minimal enumeration. |
| Number of standard requests having 'interface' as a recipient that failed to be processed. | Should normally be equal to 0. |
| Number of standard requests having 'endpoint' as a recipient. | Should be 0 after minimal enumeration. |
| Number of standard requests having 'endpoint' as a recipient that failed to be processed. | Should normally be equal to 0. |
| Number of standard requests having a class as a recipient. | Should be 0 after minimal enumeration. |
| Number of standard requests having a class as a recipient that failed to be processed. | Should normally be equal to 0. |
| Number of | Should be equal to 1 after a successful enumeration. |
| Number of | Should be equal to 1 after a successful enumeration. |
| Number of synchronous receive operation started on a control endpoint type. | Varies with usage. Used throughout enumeration. Should be 0 after minimal enumeration. |
| Number of synchronous receive operation on a control endpoint type that completed successfully. | Should be equal to |
| Number of synchronous transmit operation started on a control endpoint type. | Varies with usage. Used throughout enumeration. Should be 9 after minimal enumeration. |
| Number of synchronous transmit operation on a control endpoint type that completed successfully. | Should be equal to |
| Number of status packets attempted to be received from the host. | Varies with usage. Used throughout enumeration. Should be 9 after minimal enumeration. |
| Number of status packets successfully received from the host | Should be equal to |
| Number of status packets attempted to be sent to the host. | Varies with usage. Used throughout enumeration. Should be 1 after minimal enumeration. |
| Number of status packets successfully sent to the host | Should be equal to |
| Number of synchronous receive operation started on a bulk endpoint type. | Varies with usage. Used by CDC, MSC, PHDC and vendor class synchronous demo. |
| Number of synchronous receive operation on a bulk endpoint type that completed successfully. | Should be equal to |
| Number of synchronous transmit operation started on a bulk endpoint type. | Varies with usage. Used by CDC, MSC, PHDC and vendor class synchronous demo. |
| Number of synchronous transmit operation on a bulk endpoint type that completed successfully. | Should be equal to |
| 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. |
| Number of synchronous receive operation on an interrupt endpoint type that completed successfully. | Should be equal to |
| Number of synchronous transmit operation started on an interrupt endpoint type. | Varies with usage. Used by PHDC and vendor class synchronous demo. |
| Number of synchronous transmit operation on an interrupt endpoint type that completed successfully. | Should be equal to |
| Number of asynchronous receive operation started on a bulk endpoint type. | Varies with usage, used by vendor class asynchronous demo. |
| Number of asynchronous receive operation on a bulk endpoint type that completed successfully. | Should be equal to |
| Number of asynchronous transmit operation started on a bulk endpoint type. | Varies with usage, used by vendor class asynchronous demo. |
| Number of asynchronous transmit operation on a bulk endpoint type that completed successfully. | Should be equal to |
| Number of asynchronous receive operation started on an interrupt endpoint type. | Varies with usage, used by vendor class asynchronous demo. |
| Number of asynchronous receive operation on an interrupt endpoint type that completed successfully. | Should be equal to |
| 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. |
| Number of asynchronous transmit operation on an interrupt endpoint type that completed successfully. | Should be equal to |
| Number of asynchronous receive operation started on an isochronous endpoint type. | Varies with usage, used by audio class when playback is enabled. |
| Number of asynchronous receive operation on an isochronous endpoint type that completed successfully. | Should be equal to |
| Number of asynchronous transmit operation started on an isochronous endpoint type. | Varies with usage, used by audio class when record is enabled. |
| Number of asynchronous transmit operation on an isochronous endpoint type that completed successfully. | Should be equal to |
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_DEV * USBD_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... |
|---|---|---|
| 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. |
|
| 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). |
| Number of times an abort operation has been started. | Should be equal to 0. |
| Number of times an abort operation has completed successfully. | Should be equal to |
| Number of times a close operation has been started. | Should be equal to 1 after minimal enumeration (the endpoint is closed upon device reset). |
| Number of times a close operation has completed successfully. | Should be equal to |
| Number of times a synchronous receive operation has been started. | Should be equal to 0 after minimal enumeration. |
| Number of times a synchronous receive operation has completed successfully. | Should be equal to |
| 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. |
| Number of times an asynchronous receive operation has been started. | Should be equal to 0 after minimal enumeration. |
| Number of times an asynchronous receive operation has completed successfully. | Should be equal to |
| Number of times a zero-length packet receive operation has been started. | Should be equal to 9 after minimal enumeration. |
| Number of times a zero-length packet receive operation has completed successfully. | Should be equal to |
| Number of times a synchronous transmit operation has been started. | Should be equal to 9 after minimal enumeration. |
| Number of times a synchronous transmit operation has completed successfully. | Should be equal to |
| 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. |
| Number of times an asynchronous transmit operation has been started. | Should be equal to 0 after minimal enumeration. |
| Number of times an asynchronous transmit operation has completed successfully. | Should be equal to |
| Number of times a zero-length packet transmit operation has been started. | Should be equal to 1 after minimal enumeration. |
| Number of times a zero-length packet transmit operation has completed successfully. | Should be equal to |
| Number of times the driver's EP_RxStart() function was called. | Should be equal to 9 after minimal enumeration. |
| Number of times the driver's | Should be equal to |
| Number of times the driver's | Should be equal to 0 after minimal enumeration. |
| Number of times the driver's | Should be equal to |
| Number of times the driver's | Should be equal to 9 after minimal enumeration. |
| Number of times the driver's | Should be equal to |
| Number of times the driver has called USBD_EP_RxCmpl(). | Should be equal to 9 after minimal enumeration. |
| Number of times the driver's call to | Should be equal to 0. |
| Number of times the driver's | Should be equal to 9 after minimal enumeration. |
| Number of times the driver's | Should be equal to |