From: summer5 on
HI everyone,

I'm trying to send 16 byte data block from PC to DE2 board and then the DE2
board will transfer back the data to PC using bulk transfer.(working
environment : window Xp)

For the firmware part, I do modify the ReadEndpoint, WriteEndpoint and
SetEndpointConfiguration to read and write 16 bytes data. But I still
can't get the correct result.

What had I miss?
Can somebody help me?

Thanks,
summer




---------------------------------------
Posted through http://www.EmbeddedRelated.com
From: Leo Havmøller on
"summer5" <mhchang514(a)gmail.com> skrev i meddelelsen
news:e7adnYqLapvxZP3WnZ2dnUVZ_tednZ2d(a)giganews.com...
> HI everyone,
>
> I'm trying to send 16 byte data block from PC to DE2 board and then the
> DE2
> board will transfer back the data to PC using bulk transfer.(working
> environment : window Xp)
>
> For the firmware part, I do modify the ReadEndpoint, WriteEndpoint and
> SetEndpointConfiguration to read and write 16 bytes data. But I still
> can’t get the correct result.
>
> What had I miss?

A USB bus analyzer.

> Can somebody help me?

http://www.ellisys.com/

Leo Havmøller.


From: summer5 on
Hi,

Thanks for the reply. :>
i had change the coding.

This is the coding from HAL4D13.c
USHORT Hal4D13_ReadEndpoint(UCHAR bEPIndex, UCHAR *buf, USHORT len)
{
USHORT i, j, c;
IOWR(ISP1362_BASE,D13_COMMAND_PORT, D13CMD_EP_RD_FIFO + bEPIndex);
/* read Buffer */
j = IORD(ISP1362_BASE,D13_DATA_PORT);
if(j > len)
j = len;
i=0;
while (i<j)//<<
//for(i=0; i<j; i=i+2, buf++ )
{
c = IORD(ISP1362_BASE,D13_DATA_PORT);
*buf = (UCHAR)c;
i++;
if (i >= j) break;
buf++;
*buf = (UCHAR)(c>>8);
i++;
buf++;
}
/* Clear Buffer */
IOWR(ISP1362_BASE,D13_COMMAND_PORT, D13CMD_EP_CLEAR_BUF+bEPIndex);
return j;

}

Do anyone knows the meaning of *buf = (UCHAR)(c>>8)? Especially the(c>>8)
in the coding. Is it is shift to right for 8 bytes?

Thanks,
Summer

---------------------------------------
Posted through http://www.EmbeddedRelated.com
From: Jaded Hobo on
summer5 wrote:
> Hi,
>
> Thanks for the reply. :>
> i had change the coding.
>
> This is the coding from HAL4D13.c
> USHORT Hal4D13_ReadEndpoint(UCHAR bEPIndex, UCHAR *buf, USHORT len)
> {
> USHORT i, j, c;
> IOWR(ISP1362_BASE,D13_COMMAND_PORT, D13CMD_EP_RD_FIFO + bEPIndex);
> /* read Buffer */
> j = IORD(ISP1362_BASE,D13_DATA_PORT);
> if(j > len)
> j = len;
> i=0;
> while (i<j)//<<
> //for(i=0; i<j; i=i+2, buf++ )
> {
> c = IORD(ISP1362_BASE,D13_DATA_PORT);
> *buf = (UCHAR)c;
> i++;
> if (i >= j) break;
> buf++;
> *buf = (UCHAR)(c>>8);
> i++;
> buf++;
> }
> /* Clear Buffer */
> IOWR(ISP1362_BASE,D13_COMMAND_PORT, D13CMD_EP_CLEAR_BUF+bEPIndex);
> return j;
>
> }
>
> Do anyone knows the meaning of *buf = (UCHAR)(c>>8)? Especially the(c>>8)
> in the coding. Is it is shift to right for 8 bytes?
>

With the assumption that USHORT == 16bit and UCHAR == 8bit, the code in
the inner loop first copies the lower 8 bits from the 16 bit word in c
to the location pointed to by buf and then copies the higher 8 bits from
the 16 bit word to the next location ion the buffer.

(c>>8) shifts the higher 8 bits in the 16 bit word to the lower 8 bits.

Without knowing much about USB communication, it seems to me that if the
requested len is less than available (j) you loose the difference
because you only copy len characters at most and then declare the
transaction complete!

Antoon
From: summer5 on
>"summer5" <mhchang514(a)gmail.com> skrev i meddelelsen
>news:e7adnYqLapvxZP3WnZ2dnUVZ_tednZ2d(a)giganews.com...
>> HI everyone,
>>
>> I'm trying to send 16 byte data block from PC to DE2 board and then the

>> DE2
>> board will transfer back the data to PC using bulk transfer.(working
>> environment : window Xp)
>>
>> For the firmware part, I do modify the ReadEndpoint, WriteEndpoint and
>> SetEndpointConfiguration to read and write 16 bytes data. But I still
>> can’t get the correct result.
>>
>> What had I miss?
>
>A USB bus analyzer.
>
>> Can somebody help me?
>
>http://www.ellisys.com/
>
>Leo Havmøller.

Hi,

may i know is the USB bus analyzer is in software form like hardware in
SOPC of Quartus II or we need buy a real exist hardware?

Thanks,
Summer

---------------------------------------
Posted through http://www.EmbeddedRelated.com