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

Usb maxim

Using it in host mode I find very often return code (0x0D == hrJERR) when using the following routine:extracted from the sample 10 - differently my board uses a PS80C435 processor.

BYTE Send_Packet(BYTE token,BYTE endpoint)
{
 BYTE resultcode,retry_count;
 retry_count = 0;             // set retry_count to 0
 nak_count = 0;               // set nak_count to 0
 //
 while(1) // If the response is NAK or timeout, keep  sending until either NAK_LIMIT or RETRY_LIMIT is reached.
         // Returns the HRSL code.
 {
  Hwreg(rHXFR,(token|endpoint));        // laugh at the transfer
  while(!(Hrreg(rHIRQ) & bmHXFRDNIRQ)); // wait for the completion IRQ
  Hwreg(rHIRQ,bmHXFRDNIRQ); // clear the IRQ
  resultcode = (Hrreg(rHRSL) & 0x0F); // get the result
  if (resultcode==hrNAK)

  {
   nak_count++;                       // raize the count
   if(nak_count==NAK_LIMIT) break;
   else continue;                     // continue
  }

  if (resultcode==hrTIMEOUT)
  {
   retry_count++;                     // raize the other count
   if (retry_count==RETRY_LIMIT) break; // hit the max allowed retries. Exit and return result code
   else continue;
  }
  else break; // all other cases, just return the success or error code
 }
 return(resultcode);     // return the resultcode
}

0