recognized by both, but sometimes fails on PC.
Using Bulk.
any possible reason?
or any thing else I can check?

christian wrote:This probably means that Sharity was not fast enough sending an ACK so that the host did a USB retry after some time.
What clock frequency do you use? Can you reproduce this? If yes, do you have a digital storage scope to analyze it? Would be really interesting to find out why this happens since bulk endpoints cause problems on some computers.


/// Token recorded when receive DATA package
uchar lastTok;
///
/// @brief AVRUSB will call this function when DATA package is received
/// @param data received data to process
/// @param len received data length
///
void usbFunctionWriteOut(uchar *data, uchar len)
{
#if 1
static uchar preTok;
// not first package, same tok as last package, then ignore
if(CMD_Len_tmp && (preTok == lastTok))
{
uint8 i;
EEPROM_Write(0x01,preTok);
EEPROM_Write(0x02,lastTok);
for(i = 0;i < CMD_Len_tmp;i++)
EEPROM_Write(0x10 + i,AVR_Device_DataBuff[i]);
for(i = 0;i < len;i++)
EEPROM_Write(0x80 + i,data[i]);
return;
}
preTok = lastTok;
#endif
......
}

/// Token recorded when receive DATA package
uchar lastTok;
///
/// @brief AVRUSB will call this function when DATA package is received
/// @param data received data to process
/// @param len received data length
///
void usbFunctionWriteOut(uchar *data, uchar len)
{
#if 1
static uchar preTok;
// not first package, same tok as last package, then ignore
if(CMD_Len_tmp && (preTok == lastTok))
{
uint8 i;
EEPROM_Write(0x01,preTok);
EEPROM_Write(0x02,lastTok);
EEPROM_Write(0x03,CMD_Len_tmp);
EEPROM_Write(0x04,len);
for(i = 0;i < CMD_Len_tmp;i++)
EEPROM_Write(0x10 + i,AVR_Device_DataBuff[i]);
for(i = 0;i < len;i++)
EEPROM_Write(0x80 + i,data[i]);
LED_On(LED_Green);
while(1);
return;
}
preTok = lastTok;
#endif
memcpy(AVR_Device_DataBuff + CMD_Len_tmp,data,len);
CMD_Len_tmp += len;
......
}

handleData:
mov x3, token
lds token, usbCurrentTok;[18]
tst token ;[20]
breq doReturn ;[21]
lds x2, usbRxLen ;[22]
tst x2 ;[24]
brne sendNakAndReti ;[25]
; 2006-03-11: The following two lines fix a problem where the device was not
; recognized if usbPoll() was called less frequently than once every 4 ms.
cpi cnt, 4 ;[26] zero sized data packets are status phase only -- ignore and ack
brmi sendAckAndReti ;[27] keep rx buffer clean -- we must not NAK next SETUP
sts lastTok, x3
sts usbRxLen, cnt ;[28] store received data, swap buffers
sts usbRxToken, token ;[30]
lds x2, usbInputBufOffset;[32] swap buffers
ldi cnt, USB_BUFSIZE ;[34]
sub cnt, x2 ;[35]
sts usbInputBufOffset, cnt;[36] buffers now swapped
rjmp sendAckAndReti ;[38] 40 + 17 = 57 until SOP
Users browsing this forum: Bing [Bot] and 4 guests