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

EZ-USB FX2LP IN/OUT (Read/Write) problem

Hi Friends,

I have been working on CY7C68013A EZ-FX2LP USB based micro controller, I have written code for IN/OUT operation i.e, Read and Write operation of USB.

I am initially reading data from HOST a bulk 64 Bytes of data and storing it in a location starting from 0xE000 which is the starting address of scrachpad memory of 512 Bytes, after which if i want to read data from this location I am initially getting a JUNK first time ,latter next read I get actual value, I mean to say that after write is done to this memory location in RAM, every first time i read I get previous value and the actual value is only reflected in the next read operation,

I tried a lot , but i am not able to find out what is the exact problem, I have pasted code below.

  // INITIALIZATION CODE

        void TD_Init(void)             // Called once at startup
        {

                          BYTE i=0;

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

                                  EP1OUTCFG  = 0xA0;
                                  SYNCDELAY;
                                  EP1INCFG   = 0xA0;
                                  SYNCDELAY;                    // see TRM section 15.14
                                  EP1INCS        = 0x00;
                                  SYNCDELAY;
                                  EP2CFG     = 0x82;
                                  SYNCDELAY;
                                  EP2BCL     = 0xC0;                // arm EP2OUT by writing byte count w/skip.
                                  SYNCDELAY;
                                  EP2BCL     = 0xC0;                // arm EP2OUT by writing byte count w/skip.
                                  SYNCDELAY;
                                  EP1INBC    = 0x40;
        //                        EP2BCH     = 0x02;                // arm EP2OUT by writing byte count w/skip.
        //                        SYNCDELAY;
        //                        EP2BCH     = 0x02;                // arm EP2OUT by writing byte count w/skip.
        //                        SYNCDELAY;
                                                                                                         // enable dual autopointer feature
                                  SYNCDELAY;
                                  AUTOPTRSETUP |= 0x01;
                }



  TD_Poll()
{

 /*     -> USB OUT PACKET TRANSFER  MODULE
                                -> BULK - 64BYTES
                                -> EP2 - ENDPOINT 2 -OUT DATA TRANSFER
                  */
                        if(!(EP2468STAT & 0x01))
                        {

                                                 ACC      =XBYTE[0x8800];
                                                 Addr     = 0xE000;    // scrachpad area starting Addr
                                                 AddrFIFO = 0xF000; //EP2FIFO starting Addr
                                                 for( i = 0x0000; i < 64; i++ )
                                         {
                                                         XBYTE[Addr++]= XBYTE[AddrFIFO++];

                                         }
                                                 SYNCDELAY;
                                                 EP2BCL = 0xC0;
                                                 ACC=XBYTE[0x8800];


                         }
                           /*   -> USB IN PACKET TRANSFER    MODULE
                                        -> BULK - 64BYTES
                                        -> EP1 - ENDPOINT 1 -IN DATA TRANSFER
                           */

                                        if(!(EP1INCS & bmEPBUSY))                           //check for EP1IN bit, wait for BUSY Bit =0
                                        {

                                                count=EP1INBC;                                          // Load count with EP1 received buffer size

                        /*                      for(Addr=0xE000;Addr<0xE040;Addr++)  // load data to scrachpad RAM ,starting from 0xE000     to 0xE040 (64Bytes)
                                                {
                                                           XBYTE[Addr]=in;                              // Incremental data for every read operation from HOST

                                                }
                                                in++;           */                                               // Increment value for one Read operation
                                                Addr=0xE000     ;                                                // Intial ScrachPad Address
                                                for(i=0;i<count;i++)                          //     64 Bytes Loop Count
                                                {
                                        //              EP1INBUF[j]=BufferOUT[i];                // Transfer Data from scrachpad RAM Area to EP1
                                                        EP1INBUF[j]=XBYTE[Addr++];
                                                        j++;
                                                }

                                                SYNCDELAY;                                                       // Sychronization Delay
                                                j=0;
                                                EP1INBC = 0x40;                                          // Re-Arm  EP1 Byte Count
                                                SYNCDELAY;                                                       // Sychronization Delay



                                                ACC=XBYTE[0x9800];                                       // LED 3  ON
                                                SYNCDELAY;
                                                ACC=XBYTE[0xA800];                                       //     LED 4 ON
                                                SYNCDELAY;




                                }

                                ACC=XBYTE[0x8000];
                                SYNCDELAY;
                                ACC=XBYTE[0x9000];                                       // LED 3  ON
                                SYNCDELAY;
                                ACC=XBYTE[0xA000];                                       //     LED 4 ON
                                SYNCDELAY;

                        }

}

Please reply me if there is any mistake,
waiting for a positive reply,

Abhilash

Parents
  • Respected Mr Rahib,

    I don't know from which planet u r from?? I read all u r discussions in Keil Threads, It was more funny rather than any useful information, Looking at the discussion u had with Keil Forum, I have very good , decent n smart suggestions for u., The suggestions are mentioned as below, Kindly take every point seriously..,

    1. Re -join School from 1st Standard onwards. 2. At least now concentrate on English 3. Then Do some Engineering in computer science / electronics. 4. Try to learn Basics. 5. understand concepts well.

    If possible kindly reply back me after u complete all as i have said above, if I am alive i will reply u back..,

    Take care,

    Have a Nice day,

    Abhilash

Reply
  • Respected Mr Rahib,

    I don't know from which planet u r from?? I read all u r discussions in Keil Threads, It was more funny rather than any useful information, Looking at the discussion u had with Keil Forum, I have very good , decent n smart suggestions for u., The suggestions are mentioned as below, Kindly take every point seriously..,

    1. Re -join School from 1st Standard onwards. 2. At least now concentrate on English 3. Then Do some Engineering in computer science / electronics. 4. Try to learn Basics. 5. understand concepts well.

    If possible kindly reply back me after u complete all as i have said above, if I am alive i will reply u back..,

    Take care,

    Have a Nice day,

    Abhilash

Children
  • "2. At least now concentrate on English"

    Please take your own advice, and refrain from stuff like 'u' instead of "you", 'n' instead of "and", 'r' instead of "are", etc, etc...

    It really makes your post much harder to read!

  • mister abhilidash,

    i think you joke at where me???

    sorry why you say my english is no very good but i study from book for long time and have degree for to year now

    you have big bug in code and i fix you for work by add line if fix you can

    you send me and i now me fix you for also plz

    K