2013-04-24 01:30 AM
Hi, I'm getting started, would like to see some USB / PC interfacing. I have the STM3210C-EVAL, I'm using IAR and JLINK and have my own project compiling and running ok.
I downloaded the doc athttp://www.st.com/st-web-ui/static/active/en/resource/technical/document/user_manual/CD00158241.pdf
and the code athttp://www.st.com/web/en/catalog/tools/PF257917
Itried the Joystick Mouse demo. In the manual, it says �To select the STMicroelectronics evaluation board used to run the demo, uncomment the corresponding line in the platform_config.h file.�
I have a STM3210C eval, the ones on offer are:
STM3210B
STM3210E
I tried both, but I get �Driver � Fatal error: ST-Link Connection error Session Aboorted�, then
�Failed to load flash loader ��.FlashSTM32F10xxe.flash� (but the file does exist on my system), then
�A fatal error has occurred�
Is it because there is no demo for the c version of the eval board? That would be annoying! Can I get it running on the c version?
Thanks
#usb2013-04-25 12:22 AM
Ok, and clues about communicating over usb with any kind of PC app? This used to be easy with rs232!
Cheers, Ian2013-04-25 01:04 AM
I'm sure the USB access in such high-level environments like .NET, Java or QT is much simpler than on MCU level, with comprehensive and well-documented classes/objects.
A google search will surely bring up some fruitful links. But this is not the main focus of this forum, so it's less likely for you to find help here.2013-04-25 03:25 AM
Ok, getting there (see below)
But just a couple of problems:As below, I've modified the example to echo what is sent from the PC. To check reliability, I have the PC also echo, so the same message bounces forever, or should. But it all stops after 649. The message is 20 bytes, 01234567890123456789 At this time, I am still receiving messages at the stm, but send stops working (back to the PC).I think it might be something to do with APP_Rx_ptr_in, which is reset to 0 when it gets to APP_RX_DATA_SIZE, it is always a low value (about 40) when everything stops.Other problem: If I restart either end, it doesn't seem to work until I unplug and replug the USB cable.Anyone know enough about the sample program to know what is happening here?ThanksSolution so far: It is as easy as rs232 (almost), when you know how.From this library Clive mentioned earlier http://www.st.com/web/en/catalog/tools/PF257882Run the VCP (virtual com port) example.At that point, if you have a usb cable plugged in, it will appear in the PC device list in Ports(COM&LPT) as ''STMicroelectronics VirtualCom Port'', and in my case on COM3.You then just read / write to that from your PC app just like you used to with rs232. The top level code is in usbd_cdc_vcp.c. Note that the default line coding is 115200 baud, 1 stop bit, no parity, 8 bit, I set my com port to this but it probably doesn't make any difference as it's not actually going over rs232.If you put a breakpoint in VCP_DataRx it should trigger when you send something to STM. The project copies it out to a real rs232 port, put if you add a line ''VCP_DataTx(Buf, Len);'' you can get it to echo back to usb.You also have to change ''VCP_DataTx;'' as it has obviously been hacked to only work with rs232 receive, like this: int Count=0; while (Count<Len) { APP_Rx_Buffer[APP_Rx_ptr_in] = *(Buf+Count)+1; Count++; APP_Rx_ptr_in++; if(APP_Rx_ptr_in == APP_RX_DATA_SIZE) { APP_Rx_ptr_in = 0; } } return USBD_OK;2013-04-25 03:59 AM
Ok, just discovered it's some kind of timing issue - if I display what I receive in my PC app in a list box (which presumably takes an extra few ms) then the messaging continues forever.
But I can't rely on delays for reliable coms.Is there any explanation for this?2013-04-30 03:24 AM
I did resolve this and answer but for some reason my answer did not show. It was failing above when I was not reading the com port due to the buffers filling up! So it all works great and I hope this might be useful for others.