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

Usb failed packets

Hello,

What could be causing failed packets


Connection Status Device connected
Current Configuration 1
Speed Full
Device Address 1
Number Of Open Pipes 0

Device Descriptor NXP LPC17xx Speaker
Offset Field Size Value Description
0 bLength 1 12h
1 bDescriptorType 1 01h Device
2 bcdUSB 2 0200h USB Spec 2.0
4 bDeviceClass 1 00h Class info in Ifc Descriptors
5 bDeviceSubClass 1 00h
6 bDeviceProtocol 1 00h
7 bMaxPacketSize0 1 40h 64 bytes
8 idVendor 2 1FC7h
10 idProduct 2 4005h
12 bcdDevice 2 0100h 1.00
14 iManufacturer 1 01h "NXP Semicond "
15 iProduct 1 02h "NXP LPC17xx Speaker "
16 iSerialNumber 1 03h "DEMO00000000"
17 bNumConfigurations 1 01h

Configuration Descriptor 1 Bus Powered, 100 mA
Offset Field Size Value Description
0 bLength 1 09h
1 bDescriptorType 1 02h Configuration
2 wTotalLength 2 0076h
4 bNumInterfaces 1 02h
5 bConfigurationValue 1 01h
6 iConfiguration 1 00h
7 bmAttributes 1 80h Bus Powered
 4..0: Reserved  ...00000
 5: Remote Wakeup  ..0.....  No
 6: Self Powered  .0......  No, Bus Powered
 7: Reserved (set to one)
(bus-powered for 1.0)  1.......
8 bMaxPower 1 32h 100 mA

Interface Descriptor 0/0 Audio, 0 Endpoints
Offset Field Size Value Description
0 bLength 1 09h
1 bDescriptorType 1 04h Interface
2 bInterfaceNumber 1 00h
3 bAlternateSetting 1 00h
4 bNumEndpoints 1 00h
5 bInterfaceClass 1 01h Audio
6 bInterfaceSubClass 1 01h Audio Control
7 bInterfaceProtocol 1 00h
8 iInterface 1 00h

Audio Control Interface Header Descriptor
Offset Field Size Value Description
0 bLength 1 09h
1 bDescriptorType 1 24h Audio Control Interface Header
2  7 01 00 01 27 00 01 01

Audio Control Input Terminal Descriptor
Offset Field Size Value Description
0 bLength 1 0Ch
1 bDescriptorType 1 24h Audio Control Input Terminal
2  10 02 01 01 01 00 01 00 00
00 00

Audio Control Feature Unit Descriptor
Offset Field Size Value Description
0 bLength 1 09h
1 bDescriptorType 1 24h Audio Control Feature Unit
2  7 06 02 01 01 03 00 00

Audio Control Output Terminal Descriptor
Offset Field Size Value Description
0 bLength 1 09h
1 bDescriptorType 1 24h Audio Control Output Terminal
2  7 03 03 01 03 00 02 00

Interface Descriptor 1/0 Audio, 0 Endpoints
Offset Field Size Value Description
0 bLength 1 09h
1 bDescriptorType 1 04h Interface
2 bInterfaceNumber 1 01h
3 bAlternateSetting 1 00h
4 bNumEndpoints 1 00h
5 bInterfaceClass 1 01h Audio
6 bInterfaceSubClass 1 02h Audio Streaming
7 bInterfaceProtocol 1 00h
8 iInterface 1 00h

Interface Descriptor 1/1 Audio, 2 Endpoints
Offset Field Size Value Description
0 bLength 1 09h
1 bDescriptorType 1 04h Interface
2 bInterfaceNumber 1 01h
3 bAlternateSetting 1 01h
4 bNumEndpoints 1 02h
5 bInterfaceClass 1 01h Audio
6 bInterfaceSubClass 1 02h Audio Streaming
7 bInterfaceProtocol 1 00h
8 iInterface 1 00h

Audio Streaming Interface Descriptor
Offset Field Size Value Description
0 bLength 1 07h
1 bDescriptorType 1 24h Audio Streaming Interface
2  5 01 01 01 01 00

Audio Streaming Format Type Descriptor
Offset Field Size Value Description
0 bLength 1 0Bh
1 bDescriptorType 1 24h Audio Streaming Format Type
2  9 02 01 01 02 10 01 40 1F
00

Endpoint Descriptor 03 3 Out, Isochronous, 1 ms
Offset Field Size Value Description
0 bLength 1 09h
1 bDescriptorType 1 05h Endpoint
2 bEndpointAddress 1 03h 3 Out
3 bmAttributes 1 05h Isochronous, Asynchronous, Data
 1..0: Transfer Type  ......01  Isochronous
 3..2: Sync Type  ....01..  Asynchronous
 5..4: Usage Type  ..00....  Data
 7..6: Reserved  00......
4 wMaxPacketSize 2 0012h 18 bytes
6 bInterval 1 01h 1 ms
7 bRefresh 1 00h
8 bSynchAddress 1 83h

Audio Streaming Isochronous Audio Data Endpoint Descriptor
Offset Field Size Value Description
0 bLength 1 07h
1 bDescriptorType 1 25h Audio Streaming Isochronous Audio Data Endpoint
2  5 01 00 02 00 00

Endpoint Descriptor 83 3 In, Isochronous, 1 ms
Offset Field Size Value Description
0 bLength 1 09h
1 bDescriptorType 1 05h Endpoint
2 bEndpointAddress 1 83h 3 In
3 bmAttributes 1 01h Isochronous, No Sync, Data
 1..0: Transfer Type  ......01  Isochronous
 3..2: Sync Type  ....00..  No Sync
 5..4: Usage Type  ..00....  Data
 7..6: Reserved  00......
4 wMaxPacketSize 2 0003h 3 bytes
6 bInterval 1 01h 1 ms
7 bRefresh 1 01h
8 bSynchAddress 1 00h

http://pastebin.com/gbdKGnwQ


URB     0006-0003       4:11:41.526     6.746 ms        71 us   Sync Reset Pipe and Clear Stall                         01:01:83        83DEC6F0h       USBPDO-5        usbhub  84E65E00h       Success (Success)
URB     0007-0002       4:11:41.526     6.749 ms        88 us   Sync Reset Pipe and Clear Stall                         01:01:83        83DC8C80h       0000007a        usbccgp 84E65E00h       Success (Success)
URB     0008    4:11:41.526     6.758 ms                Isoch Transfer  3 bytes buffer          in      01:01:83        83DC8C80h       0000007a        usbccgp 84FD5790h
URB     0009    4:11:41.526     6.763 ms                Isoch Transfer  3 bytes buffer          in      01:01:83        83DEC6F0h       USBPDO-5        usbhub  84FD5790h
URB     0010-0009       4:11:41.526     6.831 ms        69 us   Isoch Transfer                  in      01:01:83        83DEC6F0h       USBPDO-5        usbhub  84FD5790h       Unsuccessful (Internal HC Error)
URB     0011-0008       4:11:41.526     6.834 ms        77 us   Isoch Transfer                  in      01:01:83        83DC8C80h       0000007a        usbccgp 84FD5790h       Unsuccessful (Internal HC Error)
URB     0012    4:11:41.526     6.847 ms                Sync Reset Pipe and Clear Stall                         01:01:83        83DC8C80h       0000007a        usbccgp 83DD4008h
URB     0013    4:11:41.526     6.853 ms                Sync Reset Pipe and Clear Stall                         01:01:83        83DEC6F0h       USBPDO-5        usbhub  83DD4008h
URB     0014-0013       4:11:41.526     6.889 ms        36 us   Sync Reset Pipe and Clear Stall                         01:01:83        83DEC6F0h       USBPDO-5        usbhub  83DD4008h       Success (Success)
URB     0015-0012       4:11:41.526     6.892 ms        45 us   Sync Reset Pipe and Clear Stall                         01:01:83        83DC8C80h       0000007a        usbccgp 83DD4008h       Success (Success)



Parents
No data
Reply Children
  • And this is Endpoint 3 in according to the config wizard, what you say to set is endpoint 3 out

    #define USB_DMA_EP          0x00000080
    

  • > It works and plays audio at 8000khz But I am losing packets

    Then, before applying Async, get back to the 8k sampling change, and find the cause of packet loss, first.

    You declare 18 bytes wMaxPacketSize of EP3 OUT on the endpoint descriptor.
    The original example defines P_S (packet size) value on usbaudio.h, as follows.
    How do you change P_S value?

    usbaudio.h
    /* 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 */
    

    The original example assumes P_S value as a number of power of 2, like 2, 4, 8, 16, 32, ...
    If your firmware set P_S to 18, the firmware will show unexpected behavior.

    Tsuneo

  • usbaudio.h
    /* Audio Definitions */
    #define DATA_FREQ 8000                 /* Audio Data Frequency */
    #define P_S       8                    /* 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 */
    

    Does this seem right to you? do I need to power on the timer

    LPC_SC->PCONP |= 1 << 2;     // Power on Timer'
    LPC_TIM1->TCR = 1;           // TC1 Enable
    
     current_timer_count = LPC_TIM1->TCR;<<<<<----- is that the correct way to write it you use  T1TC
    

  • TCR (Timer Control Register) is wrong. It's TC (Timer Counter).

    current_timer_count = LPC_TIM1->TCR  //<-- LPC_TIM1->TC
    

    What do you mean "packet loss"?
    How do you detect it?
    If you hear distorted sound on 8k sample change, additional Async modification doesn't improve it.

    Tsuneo

  • Lost code:(

    I start a fresh, but still not luck

    
    Connection Status Device connected
    Current Configuration 1
    Speed Full
    Device Address 1
    Number Of Open Pipes 0
    
    Device Descriptor NXP LPC17xx Speaker
    Offset Field Size Value Description
    0 bLength 1 12h
    1 bDescriptorType 1 01h Device
    2 bcdUSB 2 0200h USB Spec 2.0
    4 bDeviceClass 1 00h Class info in Ifc Descriptors
    5 bDeviceSubClass 1 00h
    6 bDeviceProtocol 1 00h
    7 bMaxPacketSize0 1 40h 64 bytes
    8 idVendor 2 1FC9h
    10 idProduct 2 4002h
    12 bcdDevice 2 0100h 1.00
    14 iManufacturer 1 01h "NXP Semicond "
    15 iProduct 1 02h "NXP LPC17xx Speaker "
    16 iSerialNumber 1 03h "DEMO00000000"
    17 bNumConfigurations 1 01h
    
    Configuration Descriptor 1 Bus Powered, 100 mA
    Offset Field Size Value Description
    0 bLength 1 09h
    1 bDescriptorType 1 02h Configuration
    2 wTotalLength 2 0076h
    4 bNumInterfaces 1 02h
    5 bConfigurationValue 1 01h
    6 iConfiguration 1 00h
    7 bmAttributes 1 80h Bus Powered
     4..0: Reserved  ...00000
     5: Remote Wakeup  ..0.....  No
     6: Self Powered  .0......  No, Bus Powered
     7: Reserved (set to one)
    (bus-powered for 1.0)  1.......
    8 bMaxPower 1 32h 100 mA
    
    Interface Descriptor 0/0 Audio, 0 Endpoints
    Offset Field Size Value Description
    0 bLength 1 09h
    1 bDescriptorType 1 04h Interface
    2 bInterfaceNumber 1 00h
    3 bAlternateSetting 1 00h
    4 bNumEndpoints 1 00h
    5 bInterfaceClass 1 01h Audio
    6 bInterfaceSubClass 1 01h Audio Control
    7 bInterfaceProtocol 1 00h
    8 iInterface 1 00h
    
    Audio Control Interface Header Descriptor
    Offset Field Size Value Description
    0 bLength 1 09h
    1 bDescriptorType 1 24h Audio Control Interface Header
    2  7 01 00 01 27 00 01 01
    
    Audio Control Input Terminal Descriptor
    Offset Field Size Value Description
    0 bLength 1 0Ch
    1 bDescriptorType 1 24h Audio Control Input Terminal
    2  10 02 01 01 01 00 01 00 00
    00 00
    
    Audio Control Feature Unit Descriptor
    Offset Field Size Value Description
    0 bLength 1 09h
    1 bDescriptorType 1 24h Audio Control Feature Unit
    2  7 06 02 01 01 03 00 00
    
    Audio Control Output Terminal Descriptor
    Offset Field Size Value Description
    0 bLength 1 09h
    1 bDescriptorType 1 24h Audio Control Output Terminal
    2  7 03 03 01 03 00 02 00
    
    Interface Descriptor 1/0 Audio, 0 Endpoints
    Offset Field Size Value Description
    0 bLength 1 09h
    1 bDescriptorType 1 04h Interface
    2 bInterfaceNumber 1 01h
    3 bAlternateSetting 1 00h
    4 bNumEndpoints 1 00h
    5 bInterfaceClass 1 01h Audio
    6 bInterfaceSubClass 1 02h Audio Streaming
    7 bInterfaceProtocol 1 00h
    8 iInterface 1 00h
    
    Interface Descriptor 1/1 Audio, 2 Endpoints
    Offset Field Size Value Description
    0 bLength 1 09h
    1 bDescriptorType 1 04h Interface
    2 bInterfaceNumber 1 01h
    3 bAlternateSetting 1 01h
    4 bNumEndpoints 1 02h
    5 bInterfaceClass 1 01h Audio
    6 bInterfaceSubClass 1 02h Audio Streaming
    7 bInterfaceProtocol 1 00h
    8 iInterface 1 00h
    
    Audio Streaming Interface Descriptor
    Offset Field Size Value Description
    0 bLength 1 07h
    1 bDescriptorType 1 24h Audio Streaming Interface
    2  5 01 01 01 01 00
    
    Audio Streaming Format Type Descriptor
    Offset Field Size Value Description
    0 bLength 1 0Bh
    1 bDescriptorType 1 24h Audio Streaming Format Type
    2  9 02 01 01 02 10 01 00 7D
    00
    
    Endpoint Descriptor 03 3 Out, Isochronous, 1 ms
    Offset Field Size Value Description
    0 bLength 1 09h
    1 bDescriptorType 1 05h Endpoint
    2 bEndpointAddress 1 03h 3 Out
    3 bmAttributes 1 05h Isochronous, Asynchronous, Data
     1..0: Transfer Type  ......01  Isochronous
     3..2: Sync Type  ....01..  Asynchronous
     5..4: Usage Type  ..00....  Data
     7..6: Reserved  00......
    4 wMaxPacketSize 2 0042h 66 bytes
    6 bInterval 1 01h 1 ms
    7 bRefresh 1 00h
    8 bSynchAddress 1 83h
    
    Audio Streaming Isochronous Audio Data Endpoint Descriptor
    Offset Field Size Value Description
    0 bLength 1 07h
    1 bDescriptorType 1 25h Audio Streaming Isochronous Audio Data Endpoint
    2  5 01 00 02 00 00
    
    Endpoint Descriptor 83 3 In, Isochronous, 1 ms
    Offset Field Size Value Description
    0 bLength 1 09h
    1 bDescriptorType 1 05h Endpoint
    2 bEndpointAddress 1 83h 3 In
    3 bmAttributes 1 01h Isochronous, No Sync, Data
     1..0: Transfer Type  ......01  Isochronous
     3..2: Sync Type  ....00..  No Sync
     5..4: Usage Type  ..00....  Data
     7..6: Reserved  00......
    4 wMaxPacketSize 2 0003h 3 bytes
    6 bInterval 1 01h 1 ms
    7 bRefresh 1 01h
    8 bSynchAddress 1 00h
    
    

  • /* Endpoint - Standard Descriptor */
      AUDIO_STANDARD_ENDPOINT_DESC_SIZE,    /* bLength */
      USB_ENDPOINT_DESCRIPTOR_TYPE,         /* bDescriptorType */
      USB_ENDPOINT_OUT(3),                  /* bEndpointAddress */
      USB_ENDPOINT_TYPE_ISOCHRONOUS |
      USB_ENDPOINT_SYNC_ASYNCHRONOUS,           /* bmAttributes */ <<------corrected here
      WBVAL(66),                            /* wMaxPacketSize */
      0x01,                                 /* bInterval */
      0x00,                                 /* bRefresh */
      0x83,                                 /* bSynchAddress */
    
    
    /*----------------------------------------------------------------------------
     *      U S B  -  K e r n e l
     *----------------------------------------------------------------------------
     * Name:    usbdesc.c
     * Purpose: USB Descriptors
     * Version: V1.20
     *----------------------------------------------------------------------------
     *      This software is supplied "AS IS" without any warranties, express,
     *      implied or statutory, including but not limited to the implied
     *      warranties of fitness for purpose, satisfactory quality and
     *      noninfringement. Keil extends you a royalty-free right to reproduce
     *      and distribute executable files created using this software for use
     *      on NXP Semiconductors LPC family microcontroller devices only. Nothing
     *      else gives you the right to use this software.
     *
     * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
     *----------------------------------------------------------------------------
     * History:
     *          V1.20 Changed string descriptor handling
     *          V1.00 Initial Version
     *----------------------------------------------------------------------------*/
    #include "type.h"
    
    #include "usb.h"
    #include "audio.h"
    #include "usbcfg.h"
    #include "usbdesc.h"
    
    
    /* USB Standard Device Descriptor */
    const uint8_t USB_DeviceDescriptor[] = {
      USB_DEVICE_DESC_SIZE,              /* bLength */
      USB_DEVICE_DESCRIPTOR_TYPE,        /* bDescriptorType */
      WBVAL(0x0200), /* 2.00 */          /* bcdUSB */
      0x00,                              /* bDeviceClass */
      0x00,                              /* bDeviceSubClass */
      0x00,                              /* bDeviceProtocol */
      USB_MAX_PACKET0,                   /* bMaxPacketSize0 */
      WBVAL(0x1FC9),                     /* idVendor */
      WBVAL(0x4002),                     /* idProduct */
      WBVAL(0x0100), /* 1.00 */          /* bcdDevice */
      0x01,                              /* iManufacturer */
      0x02,                              /* iProduct */
      0x03,                              /* iSerialNumber */
      0x01                               /* bNumConfigurations: one possible configuration*/
    };
    
    /* USB Configuration Descriptor */
    /*   All Descriptors (Configuration, Interface, Endpoint, Class, Vendor */
    const uint8_t USB_ConfigDescriptor[] = {
    /* Configuration 1 */
      USB_CONFIGUARTION_DESC_SIZE,          /* bLength */
      USB_CONFIGURATION_DESCRIPTOR_TYPE,    /* bDescriptorType */
      WBVAL(                                /* wTotalLength */
        USB_CONFIGUARTION_DESC_SIZE         +
        USB_INTERFACE_DESC_SIZE             +
        AUDIO_CONTROL_INTERFACE_DESC_SZ(1)  +
        AUDIO_INPUT_TERMINAL_DESC_SIZE      +
        AUDIO_FEATURE_UNIT_DESC_SZ(1,1)     +
        AUDIO_OUTPUT_TERMINAL_DESC_SIZE     +
        USB_INTERFACE_DESC_SIZE             +
        USB_INTERFACE_DESC_SIZE             +
        AUDIO_STREAMING_INTERFACE_DESC_SIZE +
        AUDIO_FORMAT_TYPE_I_DESC_SZ(1)      +
        AUDIO_STANDARD_ENDPOINT_DESC_SIZE   +
        AUDIO_STREAMING_ENDPOINT_DESC_SIZE  +
            AUDIO_STANDARD_ENDPOINT_DESC_SIZE  <--------------
      ),
      0x02,                                 /* bNumInterfaces */
      0x01,                                 /* bConfigurationValue */
      0x00,                                 /* iConfiguration */
      USB_CONFIG_BUS_POWERED,               /* bmAttributes */
      USB_CONFIG_POWER_MA(100),             /* bMaxPower */
    /* Interface 0, Alternate Setting 0, Audio Control */
      USB_INTERFACE_DESC_SIZE,              /* bLength */
      USB_INTERFACE_DESCRIPTOR_TYPE,        /* bDescriptorType */
      0x00,                                 /* bInterfaceNumber */
      0x00,                                 /* bAlternateSetting */
      0x00,                                 /* bNumEndpoints */
      USB_DEVICE_CLASS_AUDIO,               /* bInterfaceClass */
      AUDIO_SUBCLASS_AUDIOCONTROL,          /* bInterfaceSubClass */
      AUDIO_PROTOCOL_UNDEFINED,             /* bInterfaceProtocol */
      0x00,                                 /* iInterface */
    /* Audio Control Interface */
      AUDIO_CONTROL_INTERFACE_DESC_SZ(1),   /* bLength */
      AUDIO_INTERFACE_DESCRIPTOR_TYPE,      /* bDescriptorType */
      AUDIO_CONTROL_HEADER,                 /* bDescriptorSubtype */
      WBVAL(0x0100), /* 1.00 */             /* bcdADC */
      WBVAL(                                /* wTotalLength */
        AUDIO_CONTROL_INTERFACE_DESC_SZ(1) +
        AUDIO_INPUT_TERMINAL_DESC_SIZE     +
        AUDIO_FEATURE_UNIT_DESC_SZ(1,1)    +
        AUDIO_OUTPUT_TERMINAL_DESC_SIZE
      ),
      0x01,                                 /* bInCollection */
      0x01,                                 /* baInterfaceNr */
    /* Audio Input Terminal */
      AUDIO_INPUT_TERMINAL_DESC_SIZE,       /* bLength */
      AUDIO_INTERFACE_DESCRIPTOR_TYPE,      /* bDescriptorType */
      AUDIO_CONTROL_INPUT_TERMINAL,         /* bDescriptorSubtype */
      0x01,                                 /* bTerminalID */
      WBVAL(AUDIO_TERMINAL_USB_STREAMING),  /* wTerminalType */
      0x00,                                 /* bAssocTerminal */
      0x01,                                 /* bNrChannels */
      WBVAL(AUDIO_CHANNEL_M),               /* wChannelConfig */
      0x00,                                 /* iChannelNames */
      0x00,                                 /* iTerminal */
    /* Audio Feature Unit */
      AUDIO_FEATURE_UNIT_DESC_SZ(1,1),      /* bLength */
      AUDIO_INTERFACE_DESCRIPTOR_TYPE,      /* bDescriptorType */
      AUDIO_CONTROL_FEATURE_UNIT,           /* bDescriptorSubtype */
      0x02,                                 /* bUnitID */
      0x01,                                 /* bSourceID */
      0x01,                                 /* bControlSize */
      AUDIO_CONTROL_MUTE |
      AUDIO_CONTROL_VOLUME,                 /* bmaControls(0) */
      0x00,                                 /* bmaControls(1) */
      0x00,                                 /* iTerminal */
    

  • /* Audio Output Terminal */
      AUDIO_OUTPUT_TERMINAL_DESC_SIZE,      /* bLength */
      AUDIO_INTERFACE_DESCRIPTOR_TYPE,      /* bDescriptorType */
      AUDIO_CONTROL_OUTPUT_TERMINAL,        /* bDescriptorSubtype */
      0x03,                                 /* bTerminalID */
      WBVAL(AUDIO_TERMINAL_SPEAKER),        /* wTerminalType */
      0x00,                                 /* bAssocTerminal */
      0x02,                                 /* bSourceID */
      0x00,                                 /* iTerminal */
    /* Interface 1, Alternate Setting 0, Audio Streaming - Zero Bandwith */
      USB_INTERFACE_DESC_SIZE,              /* bLength */
      USB_INTERFACE_DESCRIPTOR_TYPE,        /* bDescriptorType */
      0x01,                                 /* bInterfaceNumber */
      0x00,                                 /* bAlternateSetting */
      0x00,                                 /* bNumEndpoints */
      USB_DEVICE_CLASS_AUDIO,               /* bInterfaceClass */
      AUDIO_SUBCLASS_AUDIOSTREAMING,        /* bInterfaceSubClass */
      AUDIO_PROTOCOL_UNDEFINED,             /* bInterfaceProtocol */
      0x00,                                 /* iInterface */
    /* Interface 1, Alternate Setting 1, Audio Streaming - Operational */
      USB_INTERFACE_DESC_SIZE,              /* bLength */
      USB_INTERFACE_DESCRIPTOR_TYPE,        /* bDescriptorType */
      0x01,                                 /* bInterfaceNumber */
      0x01,                                 /* bAlternateSetting */
      0x02,                                 /* bNumEndpoints */  <----------
      USB_DEVICE_CLASS_AUDIO,               /* bInterfaceClass */
      AUDIO_SUBCLASS_AUDIOSTREAMING,        /* bInterfaceSubClass */
      AUDIO_PROTOCOL_UNDEFINED,             /* bInterfaceProtocol */
      0x00,                                 /* iInterface */
    

  • /* Audio Streaming Interface */
      AUDIO_STREAMING_INTERFACE_DESC_SIZE,  /* bLength */
      AUDIO_INTERFACE_DESCRIPTOR_TYPE,      /* bDescriptorType */
      AUDIO_STREAMING_GENERAL,              /* bDescriptorSubtype */
      0x01,                                 /* bTerminalLink */
      0x01,                                 /* bDelay */
      WBVAL(AUDIO_FORMAT_PCM),              /* wFormatTag */
    /* Audio Type I Format */
      AUDIO_FORMAT_TYPE_I_DESC_SZ(1),       /* bLength */
      AUDIO_INTERFACE_DESCRIPTOR_TYPE,      /* bDescriptorType */
      AUDIO_STREAMING_FORMAT_TYPE,          /* bDescriptorSubtype */
      AUDIO_FORMAT_TYPE_I,                  /* bFormatType */
      0x01,                                 /* bNrChannels */
      0x02,                                 /* bSubFrameSize */
      16,                                   /* bBitResolution */
      0x01,                                 /* bSamFreqType */
      B3VAL(32000),                         /* tSamFreq */
    /* Endpoint - Standard Descriptor */
      AUDIO_STANDARD_ENDPOINT_DESC_SIZE,    /* bLength */
      USB_ENDPOINT_DESCRIPTOR_TYPE,         /* bDescriptorType */
      USB_ENDPOINT_OUT(3),                  /* bEndpointAddress */
      USB_ENDPOINT_TYPE_ISOCHRONOUS |
      USB_ENDPOINT_SYNC_ASYNCHRONOUS,           /* bmAttributes */ <---------------
      WBVAL(66),                            /* wMaxPacketSize */
      0x01,                                 /* bInterval */
      0x00,                                 /* bRefresh */
      0x83,                                 /* bSynchAddress */ <------
    /* Endpoint - Audio Streaming */
      AUDIO_STREAMING_ENDPOINT_DESC_SIZE,   /* bLength */
      AUDIO_ENDPOINT_DESCRIPTOR_TYPE,       /* bDescriptorType */
      AUDIO_ENDPOINT_GENERAL,               /* bDescriptor */
      0x00,                                 /* bmAttributes */
      0x02,                                 /* bLockDelayUnits */
      WBVAL(0x0000),                        /* wLockDelay */
    
    
    /* Endpoint - Standard Descriptor */                       // <-------- additional feedback EP
      AUDIO_STANDARD_ENDPOINT_DESC_SIZE,    /* bLength */
      USB_ENDPOINT_DESCRIPTOR_TYPE,         /* bDescriptorType */
      USB_ENDPOINT_IN(3),                   /* bEndpointAddress */
      USB_ENDPOINT_TYPE_ISOCHRONOUS,        /* bmAttributes */
      WBVAL(3),                             /* wMaxPacketSize */
      0x01,                                 /* bInterval */
      0x01,                                 /* bRefresh, every 2ms */
      0x00,                                 /* bSynchAddress */
    
    
    
    
    
    
    
    
    /* Terminator */
      0                                     /* bLength */
    };
    
    /* USB String Descriptor (optional) */
    const uint8_t USB_StringDescriptor[] = {
    /* Index 0x00: LANGID Codes */
      0x04,                              /* bLength */
      USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */
      WBVAL(0x0409), /* US English */    /* wLANGID */
    /* Index 0x01: Manufacturer */
      (13*2 + 2),                        /* bLength (13 Char + Type + lenght) */
      USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */
      'N',0,
      'X',0,
      'P',0,
      ' ',0,
      'S',0,
      'e',0,
      'm',0,
      'i',0,
      'c',0,
      'o',0,
      'n',0,
      'd',0,
      ' ',0,
    /* Index 0x02: Product */
      (20*2 + 2),                        /* bLength ( 20 Char + Type + lenght) */
      USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */
      'N',0,
      'X',0,
      'P',0,
      ' ',0,
      'L',0,
      'P',0,
      'C',0,
      '1',0,
      '7',0,
      'x',0,
      'x',0,
      ' ',0,
      'S',0,
      'p',0,
      'e',0,
      'a',0,
      'k',0,
      'e',0,
      'r',0,
      ' ',0,
    /* Index 0x03: Serial Number */
      (12*2 + 2),                        /* bLength (12 Char + Type + lenght) */
      USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */
      'D',0,
      'E',0,
      'M',0,
      'O',0,
      '0',0,
      '0',0,
      '0',0,
      '0',0,
      '0',0,
      '0',0,
      '0',0,
      '0',0,
    };
    

  • /* 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 */
    
    uint32_t last_timer_count;
    #if USB_SOF_EVENT
    void USB_SOF_Event (void) {
    uint32_t current_timer_count;
      uint32_t feedback_value;
      uint32_t pclk;
                                                            // feedback
      current_timer_count = LPC_TIM1->TC;                   // capture current SOF timing on the Timer1
      if ( USB_AltSetting[1] == 1 ) {               // When interface 1 / alt 1 is enabled,
                                                    // calculate master/SOF frequency ratio in 10.10 (10.14) format
        feedback_value = ((current_timer_count - last_timer_count) << 14) / (pclk/DATA_FREQ);
                                                    // and send it to the feedback IN EP
        USB_WriteEP( 0x83, (uint8_t *)&feedback_value, 3 );
      }
      last_timer_count = current_timer_count;       // update the last SOF timing
    
    

  • Duration was reduced but still some in the us seconds

    (Iso Request Failed)
    URB     5654-5653       5:37:35.394     1.286303 s      1.866 ms        Isoch Transfer                  in      01:01:83        871826F0h       USBPDO-5        usbhub  85CBDB60h       Unsuccessful (Iso Request Failed)
    URB     5655-5652       5:37:35.394     1.286307 s      1.873 ms        Isoch Transfer                  in      01:01:83        870442C8h       0000010f        usbccgp 85CBDB60h       Unsuccessful (Iso Request Failed)
    URB     5662-5661       5:37:35.395     1.287303 s      928 us  Isoch Transfer                  in      01:01:83        871826F0h       USBPDO-5        usbhub  85CBDB60h       Unsuccessful (Iso Request Failed)
    URB     5663-5660       5:37:35.395     1.287306 s      935 us  Isoch Transfer                  in      01:01:83        870442C8h       0000010f        usbccgp 85CBDB60h       Unsuccessful (Iso Request Failed)
    URB     5706-5705       5:37:35.405     1.297317 s      1.829 ms        Isoch Transfer                  in      01:01:83        871826F0h       USBPDO-5        usbhub  85CBDB60h       Unsuccessful (Iso Request Failed)
    URB     5707-5704       5:37:35.405     1.297320 s      1.838 ms        Isoch Transfer                  in      01:01:83        870442C8h       0000010f        usbccgp 85CBDB60h       Unsuccessful (Iso Request Failed)
    URB     6522-6521       5:37:35.589     1.481314 s      1.651 ms        Isoch Transfer                  in      01:01:83        871826F0h       USBPDO-5        usbhub  85CBDB60h       Unsuccessful (Iso Request Failed)
    URB     6523-6520       5:37:35.589     1.481319 s      1.660 ms        Isoch Transfer                  in      01:01:83        870442C8h       0000010f        usbccgp 85CBDB60h       Unsuccessful (Iso Request Failed)
    URB     10384-10383     5:37:36.459     2.351312 s      1.299 ms        Isoch Transfer                  in      01:01:83        871826F0h       USBPDO-5        usbhub  85CBDB60h       Unsuccessful (Iso Request Failed)
    URB     10385-10382     5:37:36.459     2.351315 s      1.307 ms        Isoch Transfer                  in      01:01:83        870442C8h       0000010f        usbccgp 85CBDB60h       Unsuccessful (Iso Request Failed)
    URB     11192-11191     5:37:36.644     2.536358 s      1.723 ms        Isoch Transfer                  in      01:01:83        871826F0h       USBPDO-5        usbhub  85CBDB60h       Unsuccessful (Iso Request Failed)
    URB     11193-11190     5:37:36.644     2.536364 s      1.734 ms        Isoch Transfer                  in      01:01:83        870442C8h       0000010f        usbccgp 85CBDB60h       Unsuccessful (Iso Request Failed)
    URB     11200-11199     5:37:36.646     2.538304 s      1.847 ms        Isoch Transfer                  in      01:01:83        871826F0h       USBPDO-5        usbhub  85CBDB60h       Unsuccessful (Iso Request Failed)
    URB     11201-11198     5:37:36.646     2.538308 s      1.855 ms        Isoch Transfer                  in      01:01:83        870442C8h       0000010f        usbccgp 85CBDB60h       Unsuccessful (Iso Request Failed)
    URB     11210-11207     5:37:36.647     2.539328 s      954 us  Isoch Transfer                  in      01:01:83        871826F0h       USBPDO-5        usbhub  85CBDB60h       Unsuccessful (Iso Request Failed)
    URB     11211-11206     5:37:36.647     2.539331 s      961 us  Isoch Transfer                  in      01:01:83        870442C8h       0000010f        usbccgp 85CBDB60h       Unsuccessful (Iso Request Failed)
    URB     11220-11219     5:37:36.649     2.541319 s      1.476 ms        Isoch Transfer                  in      01:01:83        871826F0h       USBPDO-5        usbhub  85CBDB60h       Unsuccessful (Iso Request Failed)
    URB     11221-11218     5:37:36.649     2.541323 s      1.486 ms        Isoch Transfer                  in      01:01:83        870442C8h       0000010f        usbccgp 85CBDB60h       Unsuccessful (Iso Request Failed)
    URB     13076-13075     5:37:37.073     2.965537 s      2.165 ms        Isoch Transfer                  in      01:01:83        871826F0h       USBPDO-5        usbhub  85CBDB60h       Unsuccessful (Iso Request Failed)
    URB     13077-13074     5:37:37.073     2.965540 s      2.172 ms        Isoch Transfer                  in      01:01:83        870442C8h       0000010f        usbccgp 85CBDB60h       Unsuccessful (Iso Request Failed)
    URB     13084-13083     5:37:37.075     2.967927 s      2.315 ms        Isoch Transfer                  in      01:01:83        871826F0h       USBPDO-5        usbhub  85CBDB60h       Unsuccessful (Iso Request Failed)
    URB     13085-13082     5:37:37.075     2.967931 s      2.322 ms        Isoch Transfer                  in      01:01:83        870442C8h       0000010f        usbccgp 85CBDB60h       Unsuccessful (Iso Request Failed)
    URB     13094-13091     5:37:37.079     2.971425 s      2.582 ms        Isoch Transfer                  in      01:01:83        871826F0h       USBPDO-5        usbhub  85CBDB60h       Unsuccessful (Iso Request Failed)
    URB     13095-13090     5:37:37.079     2.971427 s      2.589 ms        Isoch Transfer                  in      01:01:83        870442C8h       0000010f        usbccgp 85CBDB60h       Unsuccessful (Iso Request Failed)
    URB     13104-13103     5:37:37.081     2.973315 s      1.326 ms        Isoch Transfer                  in      01:01:83        871826F0h       USBPDO-5        usbhub  85CBDB60h       Unsuccessful (Iso Request Failed)
    URB     13105-13102     5:37:37.081     2.973320 s      1.335 ms        Isoch Transfer                  in      01:01:83        870442C8h       0000010f        usbccgp 85CBDB60h       Unsuccessful (Iso Request Failed)
    URB     13112-13111     5:37:37.082     2.974307 s      908 us  Isoch Transfer                  in      01:01:83        871826F0h       USBPDO-5        usbhub  85CBDB60h       Unsuccessful (Iso Request Failed)
    URB     13113-13110     5:37:37.082     2.974311 s      916 us  Isoch Transfer                  in      01:01:83        870442C8h       0000010f        usbccgp 85CBDB60h       Unsuccessful (Iso Request Failed)
    URB     13120-13119     5:37:37.083     2.975306 s      924 us  Isoch Transfer                  in      01:01:83        871826F0h       USBPDO-5        usbhub  85CBDB60h       Unsuccessful (Iso Request Failed)
    URB     13121-13118     5:37:37.083     2.975309 s      933 us  Isoch Transfer                  in      01:01:83        870442C8h       0000010f        usbccgp 85CBDB60h       Unsuccessful (Iso Request Failed)
    
    LPC_SC->PCONP |= (1 << 2);     // Power on Timer'
    

  • Audio is fine no distortion, I am not sure what impact the errors are having, all I know is I am getting them:(

  • Why is the bSynchAddress 129 when the bEndpointAddress is 0x81 EP 1 IN

    IN this usb code you posted in the usb asynchronous thread this code.

       bLength                 9
            bDescriptorType         5
            bEndpointAddress     0x01  EP 1 OUT
            bmAttributes            5
              Transfer Type            Isochronous
              Synch Type               Asynchronous
              Usage Type               Data
            wMaxPacketSize     0x0246  1x 582 bytes
            bInterval               1
            bRefresh                0
            bSynchAddress         129
            AudioControl Endpoint Descriptor:
              bLength                 7
              bDescriptorType        37
              bDescriptorSubtype      1 (EP_GENERAL)
              bmAttributes         0x01
                Sampling Frequency
              bLockDelayUnits         2 Decoded PCM samples
              wLockDelay              0 Decoded PCM samples
          Endpoint Descriptor:
            bLength                 9
            bDescriptorType         5
            bEndpointAddress     0x81  EP 1 IN
            bmAttributes            1
              Transfer Type            Isochronous
              Synch Type               None
              Usage Type               Data
            wMaxPacketSize     0x0003  1x 3 bytes
            bInterval               1
            bRefresh                1
            bSynchAddress           0
    
    

  • I think it is MARSet tried like this

    
    void USB_Reset (void) {
    
    #if USB_DMA
      LPC_USB->USBUDCAH   = USB_RAM_ADR;
      LPC_USB->USBDMARClr = 0xFFFFFFFF;
      LPC_USB->USBEpDMADis  = 0xFFFFFFFF;
      LPC_USB->USBEpDMAEn   = USB_DMA_EP;
      LPC_USB->USBEoTIntClr = 0xFFFFFFFF;
      LPC_USB->USBNDDRIntClr = 0xFFFFFFFF;
      LPC_USB->USBSysErrIntClr = 0xFFFFFFFF;
      LPC_USB->USBDMAIntEn  = 0x00000007;
      LPC_USB->USBDMARSet = 1 << EPAdr(0x83);<--------------
      //LPC_USB->USBDMARSet = USB_ENDPOINT_IN(3);<------------
      //DMA_REQ_SET = 1 << EPAdr(0x83);<------------------
    //LPC_USB->USBDMARSet = 1<<EPAdr(USB_DMA_EP;);<------------
    
      DDMemMap[0] = 0x00000000;
      DDMemMap[1] = 0x00000000;
      for (n = 0; n < USB_EP_NUM; n++) {
        udca[n] = 0;
        UDCA[n] = 0;
      }
    #endif
    }
    

  • After I go back I misunderstood what you were saying it just does not seem to want to work properly in Slave mode,

    The firmware handles the isoc IN endpoint (0x83) in "slave mode" (ie. not in DMA mode).
    USB_SOF_Event() processes this endpoint.
    So, don't register this EP at USB_DMA_EP
    
    usbcfg.h
    #define USB_DMA_EP          0x000000C0 // <--- 0x00000040
    Tsuneo
    

    Can it not be set up for the in endpoint to work in DMA MODE I have been trying with no success can you help.

  • anything like this?? I see in the orignal code in the SOF_EVENT endpoint 3 out is call in slave mode, and then in the USB_EndPoint3 (uint32_t event) it is then put in DMA MODE

    If I just leave it how you orignal set it both in and out endpoint 3 will both be called in slave mode first then if I can figure out how it should be written I can call them both in DMA MODE
    at void USB_EndPoint3 (uint32_t event) {

    Becasue like I said the IN Endpoint 3 just does not want to work properly with out adding it into void USB_EndPoint3 (uint32_t event) { in DMA MODE after being first called in SLAVE MODE at the SOF EVENT

     uint32_t last_timer_count;
    #if USB_SOF_EVENT
    void USB_SOF_Event (void) {
    #if USB_DMA == 0 <----- don't need this??
    uint32_t current_timer_count;
      uint32_t feedback_value;
    
      uint32_t pclk;
    
                                                            // feedback
      current_timer_count = LPC_TIM1->TC;                   // capture current SOF timing on the Timer1
      if ( USB_AltSetting[1] == 1 ) {               // When interface 1 / alt 1 is enabled,
                                                    // calculate master/SOF frequency ratio in 10.10 (10.14) format
        feedback_value = ((current_timer_count - last_timer_count) << 14) / (pclk/DATA_FREQ);
                                                    // and send it to the feedback IN EP
        USB_WriteEP( 0x83, (uint8_t *)&feedback_value, 3 );
      }
      last_timer_count = current_timer_count;       // update the last SOF timing
    
    
    void USB_EndPoint3 (uint32_t event) {
    #if USB_DMA
      USB_DMA_DESCRIPTOR DD;
      uint32_t current_timer_count;
      uint32_t feedback_value;
    
      uint32_t pclk;
    
      if (event & USB_EVT_IN_DMA_EOT) {
        /* End of Transfer */
    current_timer_count = LPC_TIM1->TC;                   // capture current SOF timing on the Timer1
      if ( USB_AltSetting[1] == 1 ) {               // When interface 1 / alt 1 is enabled,
                                                    // calculate master/SOF frequency ratio in 10.10 (10.14) format
        feedback_value = ((current_timer_count - last_timer_count) << 14) / (pclk/DATA_FREQ);
                                                    // and send it to the feedback IN EP
    
        if (USB_DMA_BufAdr(0x83) != ((uint8_t *)&feedback_value, 3 )); {
    
        }
    
    }
      last_timer_count = current_timer_count;       // update the last SOF timing
    
      }
      if (event & (USB_EVT_IN_DMA_EOT) | (USB_EVT_IN_DMA_NDR)) {
        /* End of Transfer or New Descriptor Request */
        DD.BufAdr  = ((uint8_t*)&feedback_value, 3)); /* DMA Buffer Address */
        DD.BufLen  = P_C;                       /* DMA Packet Count */
        DD.MaxSize = 0;                         /* Must be 0 for Iso Transfer */
        DD.InfoAdr = (uint32_t)InfoBuf;            /* Packet Info Buffer Address */
        DD.Cfg.Val = 0;                         /* Initial DMA Configuration */
        DD.Cfg.Type.IsoEP = 1;                  /* Iso Endpoint */
        USB_DMA_Setup (0x83, &DD);              /* Setup DMA */
        USB_DMA_Enable(0x83);                   /* Enable DMA */
      }
    #else
      event = event;
    #endif
    }
    

    Could would please try to get it work like this even if you don't think it is the problem.