2005-11-13 08:43 PM
2005-11-07 08:04 PM
According to the str71x reference manual,where it says 'as the token packet of a new transaction is received, the actual endpoint status will be masked as ‘10’ (NAK) when a buffer conflict between the USB Peripheral and the application software is detected (this condition is identified by DTOG and SW_BUF having the same value)',I don't know wether the status bits are masked by hardware or by software? :o
Another question, I can't see any code initializing SW_BUF bit to be different from DTOG bit, and I found both bits are 0 after USB Device configuration. I can't find any NAK tokens when I use Bus Hound to get 256 bytes data. But as the reference manual points out, there should be a buffer confflict. Please help :D [ This message was edited by: DanLiang on 08-11-2005 09:40 ] [ This message was edited by: DanLiang on 08-11-2005 09:41 ]2005-11-07 08:07 PM
I used USB Analyzer to trace the data flow on USB Bus
2005-11-08 07:49 PM
Hi, I am using the double buffer feature on my application, and it works great.
The meaning of what you are wondering is, as long as you don't switch buffers in your application by switching the value of SW_BUF, if a new transaction arrives on the USB for your bulk endpoint, as the buffer has not been freed, the SIE cannot write into it, so it sends back NAK to the host as long as you don't switch buffers. It is your responsability to order the switch, but the switch process is automaticaly done by the SIE. For exemple, lets call the buffer used by the application the application buffer, and the buffer used by the SIE the SIE buffer. You initialize the buffer as buffer0 = application buffer, and buffer1 = SIE buffer. Once there has been a transaction on the USB, the SIE will write into the buffer1, so you have to switch buffer0 and buffer1 by changing SW_BUF value to access buffer1 data from your application and allow the SIE to write into buffer0. If you don't do that, then the SIE cannot write into buffer0 and won't overwrite buffer1 data... So it sends back NAK to each transaction on the specified endpoint as long as the switch has not occured. I hope this is clear enough. Take care Julien PS: I attach the bulk exemple provided by ST ________________ Attachments : USBBulk.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HtRJ&d=%2Fa%2F0X0000000aQ3%2F__udU1CU.TePa7LBZTib8NvDl5cb6ApgwacT22.4C1Y&asPdf=false2005-11-10 08:16 PM
Hi,ruliano!
Thank you for your reply. I've tried the example you gave me, it works well during OUT transfer.Still I can't find any intialization code about the two buffers, both SW_BUF and DTOG bits are '0' after finishing ''StartDblBuff()''.You just explained what happened during the transfering, but I still have no idea about the first step. Besides, my application will use IN transfer mainly, and now I testing the code.I wrote data from '0' to '255' sequentially to a array of 1024 bytes in advance, and transfered them in the Bulk in interrupt service routine. I used Bus Hound to request 1024 bytes data from device at a time, but the received data was not in order.I attached the received data, please help me ;) Best regards ________________ Attachments : USB_receive.txt : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I18n&d=%2Fa%2F0X0000000bm5%2FVr8nQtaC_GnMxhXDGccUNrREMffPOKjkP9kc0xdvIZM&asPdf=false2005-11-13 08:43 PM
Hi DanLiang,
the buffer init is done in the StartDblBuff() function, the code bRxBufUsedFromCell=EP_BUF0; bTxBufUsedFromCell=EP_BUF0; initialize the buffers used by the application, and the functions SetEPRxValid(BULK_OUT_ENDP); SetEPTxValid(BULK_IN_ENDP); initialize the Dtog value. When you want to write data into the Packet Buffer Memory (where the bulk buffers are), you have to becarefull how you write them. indeed, the structure of the USB memory is word based, so on 16 bits and not on 32 bits, as noticed in the reference manual, in the chapter 14.4.1: Packet Memory: This is the local memory that physically contains the Packet Buffers. It can be used by the Packet Buffer interface, which creates the data structure and can be accessed directly by the application software. The size of the Packet Memory is 512 Bytes, structured as 256 words by 16 bits. So you have to use the function UserToPMABufferCopy(BYTE *pbUsrBuf,WORD wPMABufAddr, WORD wNBytes) if you want the data to be written correctly. Hope this will help. Regards Julien