5 Replies Latest reply on Aug 21, 2018 10:26 PM by SrinathS_16

    EZ-USB FX2LP(CY7C68013A):USB Audio Device(UAC 2.0) with Multichannel Input MIC and stereo output Speaker.

      Hi All:

       

      I am working on a USB audio device(UAC 2.0) with multichannel input MIC and stereo output speaker,the format 48KHz,16bit.

      I have write a project,but it doesn't work.

      Do anyone have a similar example code?

      Attached is my firmware, can anyone have some suggestion?

      Thanks a lot.

       

      Update2018.08.09

       

      1.Two Clock uint descriptors are

      ;; Clock Source Descriptor

      db     0x08                            ;; bLength                          

      db     0x24                            ;; bDescriptorType           CS_Interface

      db     0x0A                                     ;; bDescriptorSubType             Clock Source

      db     0x10                            ;; bClockID  another ID is 0x11

      db     0x05                            ;; bmAttributes                           Internal Fixed Clock Locked to SOF 8000Hz

      db     0x03                            ;; bmControls

      db     0x00                            ;; bAssociatedTerminal

      db     0x00                            ;; iClockSource

      The format descriptor is

      ;; FORMAT_TYPE_I descriptor   

      db     06H                    ;; bLength

      db     DSCR_AS_INTRFC             ;; bDescriptorType CS_INTERFACE

      db     02H                    ;; bDescriptorSubType   FORMAT_TYPE

      db     01H                    ;; bFormatType         FORMAT_TYPE_I

      db     04H                    ;; bSubSlotSize

      db     18H                    ;; bBitResolution 24bit

      SOF interrupt service function looping the input(EP2)-output(EP6) is 

      void ISR_Sof(void) interrupt 0

      {

        int i;

        int count;

        IOA|=0x80; //output 1 on PA.7

        SYNCDELAY;

      // Transfer EP6-OUT buffer to EP2-IN buffer when there is a packet in one of the EP6-OUT buffers, AND

      // there is an available EP2-IN buffer. The FIFO status flags update after full packets are transferred.

      // Therefore EP2-OUT "Not Empty" means a packet is available, and "EP6-IN "Not Full" means there is an

      // available buffer. Using the flags this way handles any packet size and takes multiple buffering

      // into account.

       

      if(!(EP2468STAT & bmEP2EMPTY))           // Is EP2-OUT buffer not empty (has at least one packet)?

      {

                 if(!(EP2468STAT & bmEP6FULL))      // YES: Is EP6-IN buffer not full (room for at least 1 pkt)?

                   {

      APTR1H = MSB( &EP2FIFOBUF );

              APTR1L = LSB( &EP2FIFOBUF );

      AUTOPTRH2 = MSB( &EP6FIFOBUF );

      AUTOPTRL2 = LSB( &EP6FIFOBUF );

       

              count = (EP2BCH << 8) + EP2BCL;

              // loop EP2OUT buffer data to EP6IN

              for( i = 0; i < 0x0200; i++ )

              {

                  EXTAUTODAT2 = EXTAUTODAT1;      // Autopointers make block transfers easy...

              }

      EP6BCH = 0x02;                  // Send the same number of bytes as received

      SYNCDELAY; 

      EP6BCL = 0x00;        // arm EP6IN

                                   SYNCDELAY;                    //

                                   EP2BCH = 0x02;    

                                   SYNCDELAY;                    //

                                   EP2BCL = 0x00;                // arm EP2OUT by writing byte count w/skip.

                                   SYNCDELAY;

                            }

        }

       

       

      //         for( i = 0; i < 192; i++ )

      //    {

      // EP6FIFOBUF[i] = i+2;

      //    }

      // EP6BCH = 0x00;

      // SYNCDELAY;                    //

      //   EP6BCL = 0xC0;

      // SYNCDELAY;

        IOA&=0x7F; //output 0 on PA.7

        SYNCDELAY;

      EZUSB_IRQ_CLEAR();

         USBIRQ = bmSOF;            // Clear SOF IRQ

      }

      Under such conditions the device driver works well, but datas on endpoint(EP6) are not narmal, like log.file1.txt over bus hound

       

      2、After I modified the SOF interrupt service function like below

      void ISR_Sof(void) interrupt 0

      {

        int i;

        int count;

        IOA|=0x80; //output 1 on PA.7

        SYNCDELAY;

      // Transfer EP6-OUT buffer to EP2-IN buffer when there is a packet in one of the EP6-OUT buffers, AND

      // there is an available EP2-IN buffer. The FIFO status flags update after full packets are transferred.

      // Therefore EP2-OUT "Not Empty" means a packet is available, and "EP6-IN "Not Full" means there is an

      // available buffer. Using the flags this way handles any packet size and takes multiple buffering

      // into account.

       

      //       if(!(EP2468STAT & bmEP2EMPTY))           // Is EP2-OUT buffer not empty (has at least one packet)?

      //       {

      //                 if(!(EP2468STAT & bmEP6FULL))      // YES: Is EP6-IN buffer not full (room for at least 1 pkt)?

      //          {

      // APTR1H = MSB( &EP2FIFOBUF );

      // APTR1L = LSB( &EP2FIFOBUF );

      // AUTOPTRH2 = MSB( &EP6FIFOBUF );

      // AUTOPTRL2 = LSB( &EP6FIFOBUF );

       

      // count = (EP2BCH << 8) + EP2BCL;

      //        // loop EP2OUT buffer data to EP6IN

      // for( i = 0; i < 0x0200; i++ )

      //        {

      // EXTAUTODAT2 = EXTAUTODAT1;  // Autopointers make block transfers easy...

      //        }

      // EP6BCH = 0x02;               // Send the same number of bytes as received

      // SYNCDELAY;

      // EP6BCL = 0x00;        // arm EP6IN

      //                                   SYNCDELAY;                    //

      //                                   EP2BCH = 0x02;   

      //                                   SYNCDELAY;                    //

      //                                   EP2BCL = 0x00;                // arm EP2OUT by writing byte count w/skip.

      //                                   SYNCDELAY;

      //                            }

      //  }

      //     

       

         for( i = 0; i < 192; i++ )

          {

      EP6FIFOBUF[i] = i+2;

          }

        EP6BCH = 0x00;

      SYNCDELAY;                    //

         EP6BCL = 0xC0;

        SYNCDELAY;

        IOA&=0x7F; //output 0 on PA.7

        SYNCDELAY;

      EZUSB_IRQ_CLEAR();

         USBIRQ = bmSOF;            // Clear SOF IRQ

      }

      I got the logfile2.txt

      3、If I modify the Format FORMAT_TYPE_I descriptor:

      Before:

      ;; FORMAT_TYPE_I descriptor    

      db     06H                    ;; bLength

      db     DSCR_AS_INTRFC             ;; bDescriptorType CS_INTERFACE

      db     02H                    ;; bDescriptorSubType   FORMAT_TYPE

      db     01H                    ;; bFormatType         FORMAT_TYPE_I

      db     04H                    ;; bSubSlotSize

      db     18H                    ;; bBitResolution

      After:

      ;; FORMAT_TYPE_I descriptor    

      db     06H                    ;; bLength

      db     DSCR_AS_INTRFC             ;; bDescriptorType CS_INTERFACE

      db     02H                    ;; bDescriptorSubType   FORMAT_TYPE

      db     01H                    ;; bFormatType         FORMAT_TYPE_I

      db     02H                    ;; bSubSlotSize

      db     10H                    ;; bBitResolution

       

      Or if I modify Clock Source Des criptor and sampling rate(48KHz)

      Before:

      ;; Clock Source Des criptor

      db     0x08                            ;; bLength                          

      db     0x24                            ;; bDescriptorType           CS_Interface

      db     0x0A                                     ;; bDescriptorSubType             Clock Source

      db     0x11                            ;; bClockID

      db     0x05                            ;; bmAttributes                           Internal Fixed Clock Locked to SOF

      db     0x03                            ;; bmControls

      db     0x00                            ;; bAssociatedTerminal

      db     0x00                            ;; iClockSource

       

      After:

      ;; Clock Source Des criptor

      db     0x08                            ;; bLength                          

      db     0x24                            ;; bDescriptorType           CS_Interface

      db     0x0A                                     ;; bDescriptorSubType             Clock Source

      db     0x11                            ;; bClockID

      db     0x03                            ;; bmAttributes                           Internal programmable Clock

      db     0x07                            ;; bmControls

      db     0x00                            ;; bAssociatedTerminal

      db     0x00                            ;; iClockSource

       

       

      The device can’t work , and I got the logfile3.txt, logfile4.txt and shortcuts Modify Format.PNG、Modify Format MIC.PNG.

       

      BRs

      Shoukuan

      SrinathS_16