2014-10-19 10:48 PM
I am using STM32F2xx and I emulate it as a VCP driver, I used the sample code from STM32 for the USB device example
I wrote a .NET application to open the serial port communication, but I have problem to open the port.The error stack is below:System.IO.IOException The parameter is incorrectMy problem could be well summarised in the link below, I have the identical problem with it! I could open the serial port using a terminal program(TeraTerm) but my application cant openhttp://stackoverflow.com/questions/14885288/io-exception-error-when-using-serialport-openI believe it is the firmware problem, anyone face this problem and managed to solve this?2014-10-20 02:05 AM
I believe it is the firmware problem, anyone face this problem and managed to solve this?
Which firmware do you mean? Is this related to your thread '' '' in which you confirmed that it is working fine? Or this is a new issue? -Mayla-To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2014-10-20 02:24 AM
Yes, that is working fine and this is a new issue.
This doest not happen all the time, sometimes it occurs sometimes it doesnt, even using the same firmware2014-10-20 02:56 AM
Hi
First verify that the problem is in the STM32 and not your .net code. Do this by using another program (eg terminal emulator) with the STM32 USB CDC device. Your problem may be with your 'faulty .net' code. If the PC does not close (and release) the COMM port then the USB disconnect and USB connect/re-enumeration will fail because the COMM port is in use still.2014-10-20 03:27 AM
Yup I have verified the problem,
when I failed to open using my .NET application, I used terminal emulator (TeraTerm) application to open it, and it can open without any problem.Then, I close the TeraTerm application, and retry to open the port using .NET it fails again.2014-10-20 03:50 AM
Hi
''when I failed to open using my .NET application, I used terminal emulator (TeraTerm) application to open it, and it can open without any problem. Then, I close the TeraTerm application, and retry to open the port using .NET it fails again.'' This points to your .net application being the problem NOT the STM32 USB CDC device implementation. This is the wrong forum to ask about .Net stuff. Try a Windows .Net forum.2014-10-20 05:50 PM
Thank you, I will check again!
I have one more question, currently I am sending 512 bytes every second from my STM using the STM VCP driverI am able to receive the data in my PC, but it takes about 8 second before the data is callback into my application, I notice that the PC needs to wait for 4096 bytes before the data is callback, Is there anyway I can set the STM VCP driver or the firmware for the data receive buffer to be smaller (512 bytes) so it can callback faster or set the latency timer to 1ms?2014-10-21 01:11 AM
''I am able to receive the data in my PC, but it takes about 8 second before the data is callback into my application,
I notice that the PC needs to wait for 4096 bytes before the data is callback, Is there anyway I can set the STM VCP driver or the firmware for the data receive buffer to be smaller (512 bytes) so it can callback faster or set the latency timer to 1ms?'' It is unclear from you post whether your problem is on the PC send/receive or in the STM32. Yes, both have issues : The PC VCP driver has issues about buffer size and emptying it. Depending on how the STM32 has been implemented, it too can have problems with buffer latency. I am affraid that I do not have a solution for this, we worked around the issues.2014-10-21 01:22 AM
I have problem when I receive the data in PC using the STM VCP,
it needs to wait 4096 bytes to fill up before I receive the data..May I know how do you work around it?I need it to get the data every 1 ms (timeout) or set the buffer to be 512 bytes.2014-10-21 02:10 AM
''I have problem when I receive the data in PC using the STM VCP,
it needs to wait 4096 bytes to fill up before I receive the data.. May I know how do you work around it?'' The main work around was on the PC side but that does not sound like your problem. (The work around was to do a Send of data followed by another send with no data, for some reason this would force the PC USB VCP driver to send a packet if it was less than 64bytes) You problem is the STM32 side. Look at your implementation for uint16_t USBDataTx( uint8_t * Buf, uint32_t Len ) How does it interact with the buffer APP_Rx_Buffer and the index pointer into it APP_Rx_ptr_in Do a search for these 2 and work out what the STM USB driver is doing with these!