Forum > Embedded - ARM

Getting a USB stack to work on STM32

<< < (7/7)

petex:
Definitely works better than the old code. Looking quite reliable with my test PC program talking to the STM32. Nice one Laksen and MiR  :P

petex:
I have been writing some test code and the USB services are hanging.....


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- function TCDCDevice.Write(const AData; ASize: SizeInt): SizeInt;var  ptr: pbyte;  left: SizeInt;begin  result:=0;  ptr:=@AData;   while ASize>0 do  begin    if fTXPos>=fTXBufferSize then // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< HANGING    begin      if fBlocking then        fDevice^.Poll      else        break;    end         
I am doing a succession of transmits which is different to the request/response protocol on the previous test. The request sizes of the transmits can exceed the TXBuffer size.

The CDC Write procedure is meant to issue several TX buffer transmits until all the application data is sent and blocks until this is done.

I can get it to hang where it is always repeating as shown in the above code excerpt. The write procedure does not return to the application.

fTXPos = 64 and
fTXBufferSize = 64 and
fBlocking = true

Laksen:
Can you consistently reproduce this? What's the value of fTxDone when it hangs?

petex:
hello,
I have changed my app somewhat and the problem manifests itself in a different way. This time it is in the receiver:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function TCDCDevice.Read(var ABuffer; ASize: SizeInt): SizeInt;var  left: SizeInt;  ptr: pbyte;begin  Result:=0;   ptr:=@ABuffer;   while ASize>0 do  begin    if fRXPos<=0 then    begin      if fBlocking then        fDevice^.Poll      else        break;  // <<<<<<<<<<<<<< NEVER EXITS    end 
I am requesting 1 byte but the receiver does not return and sits polling the USB.

RXPos=0
fBlocking = true
TXpos=0
TXDone=true


The comms is request/response
THe request is 4 bytes
This works fine when the response is small ~ 8-16 bytes
When I increase the response size (probably over the TX buffer size of 64 bytes), there is a point when it hangs.

Is the problem due to the operation of "fBlocking", I have not looked at the code in any detail so i am guessing here.

edit:
I can normally plug and unplug the usb when the STM32 app is running with no problem. In the hang situation, when i plug it in Windows registers an error handling the USB interface.

Laksen:
I found a way to reproduce this bug. It seems to be related to how the hardware is driven in high throughput cases. The bulk out endpoint can get stuck in a case where it's not sending but all bits indicate that it should send. Might be a timing or bus issue

Navigation

[0] Message Index

[*] Previous page

Go to full version