USB Audio Speaker Tutorial: Step 3

Step 3: Configure USB Library for Audio Device

1

Expand the Harmony Framework Configuration > USB Library selection tree.

2

Check the Use USB Stack? Box.

3

Make sure the Interrupt Mode box is checked.

4

Expand the Select Host or Device Stack option.

5

The USB stack is used in Device mode. Make sure the USB Device option is checked.

6

Next, set the Number of Endpoints Used to 2. This includes the default control endpoint 0 which will be used for USB device control transfers and USB audio control transfers. The other endpoint will be used for streaming USB audio data.

7

Endpoint 0 Buffer Size must be left to the default value of 64 (Maximum buffer size). For full speed devices, the USB specification allows the Endpoint 0 buffer to be of size 8, 16, 32 or 64 bytes.

8

Keep the (default) checked USB Device Instance 0 option and expand it.

Since there is only one USB peripheral on the device, there is only one USB instance (selected by default).

9

Select the USB Speed to USB_SPEED_FULL. This is used to load the appropriate USB driver (Full Speed or High Speed).

10

Number of Functions Registered to this Device Instance must be left to the default value of 1, as only Audio 1.0 device class is used.

11

Next, keep the (default) checked Function 1 option and expand it.

12

Since the end application is USB Audio 1.0, select the USB audio device class. Change the Device Class to AUDIO

13

Set the configuration value to which this function driver is tied. There will be only one configuration and hence retain the default Configuration Value of 1.

14

Retain the default Start Interface Number of 0.

15

Next, configure the number of interfaces used by this function driver. Change the Number of Interfaces to 2. One interface will be used for the transfer of audio controls (volume and mute), and the other will be used for transfer of the audio data stream.

16

Set the Speed to USB_SPEED_FULL. This is used to populate the device descriptors for USB full speed operation.
Stereo audio files with 48 KHz sampling rate and 16-bit resolution will be played. USB high speed may be used to play high resolution audio files.

17

Next, set the read and write queue size used by the function driver.

  • Keep the default value 1 for Audio Write Queue Size
  • Change the Audio Read Queue Size to 2. For a continuous reception of audio stream, and to avoid the loss of audio data, the read queue size must be at least 2 to allow for ping-pong buffer operation.

18

Number of Audio Streaming Interfaces must be left to the default value of 1, as there is only one audio streaming interface: from USB host to device.

19

Two alternate settings will be used: one to reclaim the bandwidth when the audio functionality is not being used, and the other when the audio functionality is used. Keep the Maximum Number of Interface Alternate Settings to the default value of 2.

20

This application falls into the category of USB speaker. Set the Product ID Selection to "usb_speaker_demo" from the drop-down box. Notice that when the "usb_speaker_demo" is selected, these fields are populated as follows:

  • Enter Vendor ID: 0x04D8
  • Enter Product ID: 0x0064
  • Manufacturer String: “Microchip Technology Inc.”
  • Product String: “Harmony USB Speaker Example”

You can rename the Product String to “Harmony USB Speaker" if you want to.

21

Leave the Suspend in Sleep option unchecked.

22

Next, set the USB interrupt priorities:

  • Change the USB Interrupt Priority to INT_PRIORITY_LEVEL1
  • Keep the default value of USB Interrupt Sub-priority as INT_SUBPRIORITY_LEVEL0
  • Keep the default value of USB DMA Interrupt Priority as INT_PRIORITY_LEVEL4
  • Keep the default value of USB DMA Interrupt Sub-priority as INT_SUBPRIORITY_LEVEL0

23

Keep the default value of SYS_MODULE_POWER_RUN_FULL for Power State

24

The other options must be left unchecked:

  • Enable SOF Events
  • Enable Set Descriptor Events
  • Enable Sync Frame Events
  • Use Remote Wakeup Feature
  • Enable BOS Descriptor Support
  • Enable advanced String Descriptor Table

See the following screen shot of the USB library configuration:

image_32.png


This finishes the configuration of USB library for your application. Save the configuration.



Next Step >

© 2016 Microchip Technology, Inc.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.