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
}

Parents
  •  retry_count = 0;             // set retry_count to 0
     nak_count = 0;               // set nak_count to 0
    
     return(resultcode);     // return the resultcode
    


    These comments are completely worthless as they add nothing that is not directly and immediately obvious from the code itself!

    They should be removed as they just add clutter - ie, they give no benefit and cause a small amount of harm!

Reply
  •  retry_count = 0;             // set retry_count to 0
     nak_count = 0;               // set nak_count to 0
    
     return(resultcode);     // return the resultcode
    


    These comments are completely worthless as they add nothing that is not directly and immediately obvious from the code itself!

    They should be removed as they just add clutter - ie, they give no benefit and cause a small amount of harm!

Children