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

Cypress Sample program question

I'm using the Cypress FX-2 board.
They include a sample called bulkloop.c
that allows you to loop data out to BULK IN EP's 2 & 4 and back via BULK OUT EP's 6 & 8. When i try this the Host Writes to EP's 2 & 4 go just fine but Host Reads from EP's 6 & 8 always send a NAK back to the host. The code for the FX-2 looks simple enough but I cant figure out why BULK IN EP's 6 & 8 always NAK.
Is anyone else working with this board?
I'd sure like to bounce information and ideas around.

Also are there any other forums around for this, any other sample code available anywhere? I'm looking for resources.

Source below:

Thanks
Eric

void TD_Poll(void)             // Called repeatedly while the device is idle
{
WORD i;
WORD count;

   // check EP2 EMPTY(busy) bit (bit0) in EP2468STAT (SFR), core set's this bit when FIFO is empty
   if(!(EP2468STAT & bmEP2EMPTY))  // if EP2 isnt empty
     {
      // check EP6 FULL(busy) bit in EP2468STAT (SFR), core set's this bit when FIFO is full
      if(!(EP2468STAT & bmEP6FULL))  // if EP6 isnt full
        {
         // setup AUTOPOINTER(s) in SFR space
         APTR1H = MSB( &EP2FIFOBUF );
         APTR1L = LSB( &EP2FIFOBUF );

         AUTOPTRH2 = MSB( &EP6FIFOBUF );
         AUTOPTRL2 = LSB( &EP6FIFOBUF );

         count = (EP2BCH << 8) + EP2BCL;

         // loop EP2OUT buffer data to EP6IN
         for( i = 0x0000; i < count; i++ )
           {
            // setup to transfer EP2OUT buffer to EP6IN buffer using AUTOPOINTER(s) in SFR space
            AUTODAT2 = AUTODAT1;
           }
         EP6BCH = EP2BCH;  // high speed usage
         EP6BCL = EP2BCL;  // arm EP6IN
         EP2BCL = 0x80;    // re(arm) EP2OUT
        }
     }

   // check EP4 EMPTY(busy) bit in EP2468STAT (SFR), core set's this bit when FIFO is empty
   if(!(EP2468STAT & bmEP4EMPTY))
     {
      // check EP8 FULL(busy) bit in EP2468STAT (SFR), core set's this bit when FIFO is full
      if(!(EP2468STAT & bmEP8FULL))
        {
         // setup AUTOPOINTER(s) in SFR space
         APTR1H = MSB( &EP4FIFOBUF );
         APTR1L = LSB( &EP4FIFOBUF );

         AUTOPTRH2 = MSB( &EP8FIFOBUF );
         AUTOPTRL2 = LSB( &EP8FIFOBUF );

         count = (EP4BCH << 8) + EP4BCL;

         // loop EP4OUT buffer data to EP8IN
         for( i = 0x0000; i < count; i++ )
           {
            // setup to transfer EP4OUT buffer to EP8IN buffer using AUTOPOINTER(s) in SFR space
            AUTODAT2 = AUTODAT1;
           }
         EP8BCH = EP4BCH;  // high speed usage
         EP8BCL = EP4BCL;  // arm EP8IN
         EP4BCL = 0x80;    // re(arm) EP4OUT
        }
     }
}


Parents
  • My Write/Read Loop on the host goes like this:

    fill a buffer1 with 64 bytes of 0x12
    fill a buffer2 with 64 bytes of 0x24
    Write 64 bytes of Buffer1 to EP2
    Write 64 bytes of Buffer2 to EP4
    Clear both buffers to 0x00
    Read 64 bytes from EP6 into Buffer1
    Read 64 bytes from EP8 into Buffer2
    verify Buffer1 is filled with 0x12's
    verify Buffer2 is filled with 0x24's

    Maybe the TDPoll() function in the device is copying bytes before the EP-2&4 are full and therefore (because the AutoPtr is reset each time) the end result might be a smaller than 64 ByteCount in EP-6&8 and since the host asked for 64 bytes the Device NAKS cuz it only had 17 in EP-6or 24 in EP-8. Does that sound logical, and plausible?

    So I think what your saying is to not take the data from EP2 and store it into EP6 until EP2 is full
    or at some pre-determined value like say 64? So the host will write 64 bytes, the device will wait until EP2 has 64 bytes, copy it to EP6 and then voila! there is data to read back into the host.
    I'll play with that idea and see what cooks.
    Thanks...

Reply
  • My Write/Read Loop on the host goes like this:

    fill a buffer1 with 64 bytes of 0x12
    fill a buffer2 with 64 bytes of 0x24
    Write 64 bytes of Buffer1 to EP2
    Write 64 bytes of Buffer2 to EP4
    Clear both buffers to 0x00
    Read 64 bytes from EP6 into Buffer1
    Read 64 bytes from EP8 into Buffer2
    verify Buffer1 is filled with 0x12's
    verify Buffer2 is filled with 0x24's

    Maybe the TDPoll() function in the device is copying bytes before the EP-2&4 are full and therefore (because the AutoPtr is reset each time) the end result might be a smaller than 64 ByteCount in EP-6&8 and since the host asked for 64 bytes the Device NAKS cuz it only had 17 in EP-6or 24 in EP-8. Does that sound logical, and plausible?

    So I think what your saying is to not take the data from EP2 and store it into EP6 until EP2 is full
    or at some pre-determined value like say 64? So the host will write 64 bytes, the device will wait until EP2 has 64 bytes, copy it to EP6 and then voila! there is data to read back into the host.
    I'll play with that idea and see what cooks.
    Thanks...

Children
No data