0 Replies Latest reply on May 18, 2010 2:24 PM by suresh.kavula

    USB - Firmware - bulksrc modified..

    suresh.kavula

      Hi, I am trying implementing USB firmware to the application. My application generates 20 bytes of information every 10millisecond and transfers to XP Host PC. To try this option, took bulksrc example from demo kit and modified in following way:

         

          

                 

      * For this example I am using EP8IN    

          

                

      void TD_Init(void)             // Called once at startup     

       

         

      {     

       

         

         // set the CPU clock to 48MHz     

       

         

         CPUCS = ((CPUCS & ~bmCLKSPD) | bmCLKSPD1) ;     

       

         

           

                  

         

         // set the slave FIFO interface to 48MHz     

       

         

         IFCONFIG |= 0x40;     

       

         

           

                  

         

      // we are just using the default values, yes this is not necessary...     

       

         

        EP1OUTCFG = 0xA0;     

       

         

        EP1INCFG = 0xA0;     

       

         

        SYNCDELAY;                    // see TRM section 15.14     

       

         

        EP2CFG = 0xA2;     

       

         

        SYNCDELAY;                         

       

         

        EP4CFG = 0xA0;     

       

         

        SYNCDELAY;                         

       

         

        EP6CFG = 0xE2;     

       

         

        SYNCDELAY;                         

       

         

        EP8CFG = 0xE0;     

       

         

           

                  

         

        // out endpoints do not come up armed     

       

         

             

       

         

        // since the defaults are double buffered we must write dummy byte counts twice     

       

         

        SYNCDELAY;                         

       

         

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

       

         

        SYNCDELAY;                         

       

         

        EP2BCL = 0x80;     

       

         

        SYNCDELAY;                         

       

         

        EP4BCL = 0x80;                // arm EP4OUT by writing byte count w/skip.     

       

         

        SYNCDELAY;                         

       

         

        EP4BCL = 0x80;         

       

         

           

                  

         

        // enable dual autopointer feature     

       

         

        AUTOPTRSETUP |= 0x01;     

       

         

      }

         

          

                

         

          

                

         

          

                

         

          

                

         

          

                

         

          

                

         

          

                

         

          

                

         

      void TD_Poll(void)              // Called repeatedly while the device is idle    

       

         

      {    

       

         

      static unsigned char txData = 0x41;    

       

         

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

       

         

           EP8FIFOBUF[i] = txData;     

       

         

           

                  

         

      SYNCDELAY;

         

      EP8BCH = 0x00;    

       

         

                  SYNCDELAY;    

       

         

                  EP8BCL = 0x04;    

       

         

                  txData++;    

       

         

                  if(txData >= 0x5A)    

       

         

                              txData = 0x41;            

         

      }

         

          

                

         

      With this code I am able to simulate code successful under keil environment. After downloading hex file to EZ-USB controller, when I press “BulkTras” for pipe: 3:Endpoint 8 IN following results I will get:

         

          

                

         

      0000  41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41    

       

         

      0010  41 41 41 41    

       

         

      Bulk IN Transfer    

       

         

      Bulk IN success.    

       

         

      Buffer Contents    

       

         

      0000  42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42    

       

         

      0010  42 42 42 42    

       

         

      Bulk IN Transfer    

       

         

      Bulk IN success.    

       

         

      Buffer Contents    

       

         

      0000  41 41 41 41 41 41 41 41 41 41 41 41 4A 4A 4A 4A    

       

         

      0010  4A 4A 4A 4A    

       

         

      Bulk IN Transfer    

       

         

      Bulk IN success.    

       

         

      Buffer Contents    

       

         

      0000  42 42 42 42 58 58 58 58 58 58 58 58 58 58 58 58    

       

         

      0010  58 58 58 58    

       

         

      Bulk IN Transfer    

       

         

      Bulk IN success.    

       

         

      Buffer Contents    

       

         

      0000  41 41 41 41 41 41 41 41 41 41 41 41 4F 4F 4F 4F    

       

         

      0010  4F 4F 4F 4F    

       

         

      Bulk IN Transfer    

       

         

      Bulk IN success.    

       

         

      Buffer Contents    

       

         

      0000  42 42 42 42 58 58 58 58 58 58 58 58 58 58 59 59    

       

         

      0010  59 59 59 59    

       

         

      Bulk IN Transfer    

       

         

      Bulk IN success.    

       

         

      Buffer Contents    

       

         

      0000  41 41 41 41 41 41 41 41 56 56 56 56 56 56 56 56    

       

         

      0010  56 56 56 56    

       

         

      Bulk IN Transfer    

       

         

      Bulk IN success.    

       

         

      Buffer Contents    

       

         

      0000  42 42 42 42 58 58 58 58 58 58 58 58 58 58 58 58    

       

         

      0010  58 58 58 58    

       

         

      Bulk IN Transfer    

       

         

      Bulk IN success.    

       

         

      Buffer Contents    

       

         

      0000  41 41 41 41 41 41 41 41 56 56 56 56 56 56 56 56    

       

         

      0010  56 56 56 58    

       

         

      Bulk IN Transfer    

       

         

      Bulk IN success.    

       

         

      Buffer Contents    

       

         

      0000  42 42 42 42 58 58 58 58 58 58 58 58 58 58 58 58    

       

         

      0010  58 58 58 48    

       

         

      Bulk IN Transfer    

       

         

      Bulk IN success.    

       

         

      Buffer Contents    

       

         

      0000  41 41 41 41 41 41 41 41 56 56 57 57 57 57 57 57    

       

         

      0010  57 57 57 57    

       

         

      Bulk IN Transfer    

       

         

      Bulk IN success.    

       

         

      Buffer Contents    

       

         

      0000  42 42 42 42 58 58 58 58 58 58 58 58 58 58 58 58    

       

         

      0010  58 58 58 50    

       

         

      Bulk IN Transfer    

       

         

      Bulk IN success.    

       

         

      Buffer Contents    

       

         

      0000  41 41 41 41 41 41 41 56 56 56 56 56 56 56 56 56    

       

         

      0010  56 56 56 56    

       

         

      Bulk IN Transfer    

       

         

      Bulk IN success.    

       

         

      Buffer Contents    

       

         

      0000  42 42 42 42 58 58 58 58 58 58 58 49 49 49 49 49    

       

         

      0010  49 49 49 49

         

          

                

         

      As per my code for every “BulkTrans” press, I suppose to get 41, 42, 43, 44, 45, 46, 47…like each byte 20 times.

         

      What’s wrong I am doing at TDPOLL() function?

         

          

                 

         

      Appreciate your quick help.