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
        }
     }
}


0