10 Replies Latest reply on Jun 5, 2018 1:20 AM by SrinathS_16

    FX2LP ENDPOINTS

    gean_3054931

      Hello,

      I have defined endpoint 2 in the fx2lp slavefifo code.I added descriptors in dscr.a51 file as below.

       

      FullSpeedConfigDscr:

      ;; Endpoint Descriptor

            db   DSCR_ENDPNT_LEN      ;; Descriptor length

            db   DSCR_ENDPNT         ;; Descriptor type

            db   02H               ;; Endpoint number, and direction

            db   ET_BULK            ;; Endpoint type

            db   40H               ;; Maximun packet size (LSB)

            db   00H               ;; Max packect size (MSB)

            db   00H   

       

      FullSpeedConfigDscrEnd:

       

      and also

      HighSpeedConfigDscr:

      ;; Endpoint Descriptor

            db   DSCR_ENDPNT_LEN      ;; Descriptor length

            db   DSCR_ENDPNT         ;; Descriptor type

            db   02H               ;; Endpoint number, and direction

            db   ET_BULK            ;; Endpoint type

            db   40H               ;; Maximun packet size (LSB)

            db   00H               ;; Max packect size (MSB)

            db   00H   

      HighSpeedConfigDscrEnd:

       

      and made changes in the slave.c file as below.

      TD_Init()

      {

      EP2CFG = 0xE2; //endpoint2,IN diection

        SYNCDELAY;

      }

       

      I have configured endpoint for IN bulk,But firmware Renumerates with bulk out endpoint(0x02).

      what whould be the reason?did i miss anything?let me know.

       

      thank you.

        • 1. Re: FX2LP ENDPOINTS
          SrinathS_16

          Hello Geethanjali,

           

          Modify the dscr.a51 file to indicate that the endpoint is an IN endpoint.

           

          FullSpeedConfigDscr:

          ;; Endpoint Descriptor

                db  DSCR_ENDPNT_LEN      ;; Descriptor length

                db  DSCR_ENDPNT        ;; Descriptor type

                db  82H              ;; Endpoint number, and direction

                db  ET_BULK            ;; Endpoint type

                db  40H              ;; Maximun packet size (LSB)

                db  00H              ;; Max packect size (MSB)

                db  00H  

           

          FullSpeedConfigDscrEnd:

           

          and also

          HighSpeedConfigDscr:

          ;; Endpoint Descriptor

                db  DSCR_ENDPNT_LEN      ;; Descriptor length

                db  DSCR_ENDPNT        ;; Descriptor type

                db  82H              ;; Endpoint number, and direction

                db  ET_BULK            ;; Endpoint type

                db  40H              ;; Maximun packet size (LSB)

                db  00H              ;; Max packect size (MSB)

                db  00H  

          HighSpeedConfigDscrEnd:

           

           

          Best regards,

          Srinath S

          1 of 1 people found this helpful
          • 2. Re: FX2LP ENDPOINTS
            gean_3054931

            Hello sir,

            its working fine.

            I have three i2c devices connected to fx2lp.I have modified fx2lp slavefifo firmware with BULIKIN endpoint 2.

            I defined endpoint 2  buffer to commit the data into the USB.but if i click transfer in button,some times device1 values will come,some times with device2 values.please correct me if anything wrong in the below code snippet.

            void TD_Poll( void )

            {

                    EZUSB_WriteI2C(i2c_device1, 0x01, REG01);

              EZUSB_ReadI2C((i2c_device1, 0x02, EP2FIFOBUF);

               

                    EP2BCH=0x00;

                 SYNCDELAY;

                 EP2BCL=0x02;

                 SYNCDELAY;

             

            EZUSB_WriteI2C(i2c_device2, 0x02, REG02);

              EZUSB_ReadI2C((i2c_device2, 0x02, EP2FIFOBUF);

               

                   // EP2BCH=0x00;

                //SYNCDELAY;

                 ///EP2BCL=0x02;

                 //SYNCDELAY;

             

            EZUSB_WriteI2C(i2c_device3, 0x02, REG03);

              EZUSB_ReadI2C((i2c_device3, 0x02, EP2FIFOBUF);

               

                   // EP2BCH=0x00;

                //SYNCDELAY;

                 ///EP2BCL=0x02;

                 //SYNCDELAY;

             

            }

            • 3. Re: FX2LP ENDPOINTS
              SrinathS_16

              Hello Geethanjali,

               

              Please modify the code as follows.

               

              void TD_Poll( void )

              {

                      EZUSB_WriteI2C(i2c_device1, 0x01, REG01);

                      EZUSB_ReadI2C((i2c_device1, 0x02, &EP2FIFOBUF[0]);

                 

                      EZUSB_WriteI2C(i2c_device2, 0x01, REG02);

                      EZUSB_ReadI2C((i2c_device2, 0x02, &EP2FIFOBUF[2]);

                 

                      EZUSB_WriteI2C(i2c_device3, 0x01, REG03);

                      EZUSB_ReadI2C((i2c_device3, 0x02, &EP2FIFOBUF[4]);

                 

                     EP2BCH=0x00;

                     SYNCDELAY;

                     EP2BCL=0x06;

                     SYNCDELAY;

              }    

               

              The first two bytes would be the data received from device 1, next two bytes would be data received from device 2 and the last two bytes would be the data received from device 3.

               

              Please let know if this works fine.

               

              Best regards,

              Srinath S

              1 of 1 people found this helpful
              • 4. Re: FX2LP ENDPOINTS
                gean_3054931

                Hello shrinath,

                its working fine.

                thank you.

                geetha.

                • 5. Re: FX2LP ENDPOINTS
                  gean_3054931

                  Hello shrinath,

                   

                  By default ,general purpose i2c controller works at a speed of 100kHz,by setting the bit 0 of I2CTL to 1,it operates at 400kHz.i have included i2c.c [lp.h and lpreg.h] in my project , located in the path  C:\Cypress\USB\CY3684_EZ-USB_FX2LP_DVK\1.1\Target\Lib\LP but i am not able to find this I2CTL register in the slavefifo firmware and also in i2c.c .

                   

                  where i can find this register?or i need to add externally?let me know.

                   

                  regards,

                  geetha.

                  • 6. Re: FX2LP ENDPOINTS
                    SrinathS_16

                    Hello Geethanjali,

                     

                    The I2CTL register definition is present as part of the FX2REGS.H file. This register can be accessed from the firmware to modify its value and set the frequency to 100/400kHz.

                     

                    Best regards,

                    Srinath S

                    1 of 1 people found this helpful
                    • 7. Re: FX2LP ENDPOINTS
                      gean_3054931

                      Hi shrinath,

                      its there in fx2reg.h

                       

                      /* I2C Control Register (I2CTL) */

                      #define bmSTOPIE     bmBIT1

                      #define bm400KHZ     bmBIT0

                       

                      how can modify this? is it like  #define bm400KHZ     1

                      do i need to place in slave.c or i2c.c ?

                       

                      regards,

                      geetha

                      • 8. Re: FX2LP ENDPOINTS
                        SrinathS_16

                        Hello Geethanjali,

                         

                        You don't have to modify the FX2REGS.H file.

                         

                        To operate the I2C at 400kHz, use the below line of code in the firmware.

                        I2CTL |= 0x01;

                         

                        (or)

                         

                        I2CTL |= bm400KHZ;

                         

                        Best regards,

                        Srinath S

                        1 of 1 people found this helpful
                        • 9. Re: FX2LP ENDPOINTS
                          gean_3054931

                          Hello shrinath,

                          sorry for again asking same thing.what you mean by line of code in the firmware.?

                          do you mean in the fw.c file or slave.c file or i2c.c?

                           

                          regadrs,

                          geetha.

                          • 10. Re: FX2LP ENDPOINTS
                            SrinathS_16

                            Hello Geetha,

                             

                            Add the above mentioned statement in either fw.c or slave.c file which is part of your firmware.

                             

                            Best regards,

                            Srinath S

                            1 of 1 people found this helpful