This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

descriptor

Above example code also supports DMA using conditional compilation.
Search "#if USB_DMA #endif" pair on the example code. The example code will help you to understand the description on the datasheet.

The usbcfg.h defines the keys.

usbcfg.h
#define USB_DMA             0
#define USB_DMA_EP          0x00000040

Modify it directly
OR
apply uVision Config wizard to usbcfg.h to enable DMA on the isoc EPs

There are several scheme for the synchronization of isoc EP. Above example applies synchronized EP, popular for PCM audio. In this scheme, the number of the data on a packet represents the sampling rate.

For example, when the sampling rate is 8kHz, each packet has 8 pairs of data for each channel.
To represent fractional sampling rate, say 44.1kHz, packets with 44 or 45 pairs are used. Usually, 44 pairs are transferred, but 45 pairs are sent every 10 transfers.
44 * 9/10 + 45 * 1/10 = 44.1

This requirement makes the DMA descriptor complicated.

Tsuneo

How would you set write this 44 * 9/10 + 45 * 1/10 = 44.1 in the /* Audio Definitions */

/* Audio Definitions */
#define DATA_FREQ 32000                 /* Audio Data Frequency */
#define P_S       32                    /* Packet Size */
#if USB_DMA
#define P_C       4                     /* Packet Count */
#else
#define P_C       1                     /* Packet Count */
#endif
#define B_S       (8*P_C*P_S)           /* Buffer Size */

  • Your post refers to this topic,
    Isochronus Usb Device in LPC2468
    http://www.keil.com/forum/12396/

    And your question is put on the "synchronization" algorithm of audio stream,
    equipped on these Keil examples
    LPC2148 USB Audio Device Example
    http://www.keil.com/download/docs/308.asp

    LPC2368 / LPC2378 USB Audio Device Example
    http://www.keil.com/download/docs/334.asp

    This algorithm requires major modification to apply to fractional sampling frequency (like 44.1k Hz).
    When it is applied to 44.1kHz without mods, it will add 100Hz artifact to the sound.
    This algorithm assumes that every isoc OUT transaction has the same packet size (the same number of sound samples).
    But for fractional sampling frequency, a greater packet by one comes every 10 transactions.
    It causes artifact on this algorithm.

    When we bundle 10 packets in a chunk, the total sample number on the chunk is constant.
    For 44.1kHz, 441 samples. For this chunk, above algorithm is applied without any problem.
    Therefore, this algorithm is rewritten for 10 packets chunk, instead of every packet.

    Keil's algorithm prevents overrun/underrun of the data buffer.
    This algorithm is also required, but it isn't the synchronization method defined on the USB audio spec.
    Other than this algorithm, decent implementation of synchronization is required.

    Tsuneo