Reply
Posts: 6,327
Registered: ‎02-15-2004

Re: USB CDC implementation for 'F32x

Yes, as you pointed out, the CDC spec (usbcdc11.pdf) lacks CTS signal handling.
This implementation of CTS is good just for MacOS X. /
It doesn't work for Windows and Linux.

Tsuneo
<a href="http://community.silabs.com/t5/Welcome-and-Announcements/Community-Ranking-System-and-Recognition-Program/m-p/140490#U140490"><font color="#000000"><font size="2">Super Star</font></font> </a> sbj
Posts: 15
Registered: ‎06-12-2007

Re: USB CDC implementation for 'F32x

I'm trying to get the implementation to work for F326. I'm using hyperterminal and can't seem to get the data to transfer to the board. Any ideas?
Posts: 6,327
Registered: ‎02-15-2004

Re: USB CDC implementation for 'F32x

Hi sbj,

I'm trying to get the implementation to work for F326.

Visit this topic, VCP on F326

Tsuneo
Posts: 21
Registered: ‎03-21-2006

Re: USB CDC implementation for 'F32x

Hello Tsuneo,

We have modified the CDC skeleton for a USB to UART conversion code.The code is working fine except for one problem.The UART to USB conversion works fine for any baud rate.
In case of USB to UART conversion,the changes made to the baud rate on the hyperterminal makes no difference in speed.The conversion happens only at 9600bps regardless of the baud rate set.

What could be wrong
Posts: 85
Registered: ‎09-04-2005

Re: USB CDC implementation for 'F32x

Just want to point out that this thread is continued on the following thread.

http://www.cygnal.org/ubb/Forum9/HTML/001336.html
Posts: 6,327
Registered: ‎02-15-2004

Re: USB CDC implementation for 'F32x

Updated to v1.5
- Rewrote most of the source code to fit to composite device
- Added ZLP to terminate the bulk IN transfer
- Fixed bug of FIFO_Read_generic()
- Revised the INF file to support Vista

The link is on the first post above.

Tsuneo
Posts: 4
Registered: ‎09-12-2008

Re: USB CDC implementation for 'F32x

Are there any tricks to making this work with Keil uVision 3?

I'm using an F340 eval board.
The program works great with the SiLabs IDE.

It will compile with uVision, but when I download and run it I get a USB Device Not Recognized message from Windows (XP Pro).

I assume there is something wrong with my project setup, but I don't know where to begin!

Thanks
Posts: 298
Registered: ‎04-19-2006

Re: USB CDC implementation for 'F32x

Some spottings in CDC v1.5:

1. In USB_Main.c, Usb_Suspend(): Missing Clock Detector must be disabled before disabling internal oscillator to avoid reset. Clock Multiplier should be disabled too: someone reported on forum that it need to be disabled to achieve current below 300uA.

2. Mistake in comment in USB_Standard_Requests.c, Set_Configuration(), line 709:
&& (Setup.wLength.i == 0) ) // and data length set to one
Should be:
&& (Setup.wLength.i == 0) ) // and data length set to zero

3. IS_POWER_OF_2() can be used to enable optimization in USB_CDC_UART.c.
Code:
In place of:
'
if ( TXRDIdx >= TXBUFSIZE ) // at the end of the buffer
TXRDIdx = 0; // go to the head of the buffer

// TXRDIdx &= (TXBUFSIZE - 1); // when TXBUFSIZE is just power of 2
// above two lines are simplied with this line
'

you can use:
'
#define IS_POWER_OF_2(x) ( ((x) & ((x)-1)) == 0 )

#if (IS_POWER_OF_2(TXBUFSIZE))
TXRDIdx &= (TXBUFSIZE - 1);
#else
if ( TXRDIdx >= TXBUFSIZE ) // at the end of the buffer
TXRDIdx = 0; // go to the head of the buffer
#endif
'



In summary: another excellent work of Tsuneo. I wish SiLabs will adapt much from this work to it's own examples, which are used as a base by much more people, leading to much more buggy devices out there in the wild.


[This message has been edited by Patryk (edited September 19, 2008).]
Posts: 6,327
Registered: ‎02-15-2004

Re: USB CDC implementation for 'F32x

Kaiser,

Check listing (.LST) and map (.M51) file on the output of these IDEs.
Compare the compiler and linker options on theses files.
These options are listed up in the command line at the top of the files.


Many thanks Patryk,

I'll update it following your advise.

Tsuneo
Posts: 4
Registered: ‎09-12-2008

Re: USB CDC implementation for 'F32x

I figured this out. If anyone else tries to make it work in uVision, the problem was with trying to run with a Large memory model.

It works out-of-the-box if you set it to use a small memory model. I also got it to work with a large memory model by forcing all of the variables declared in USB_ISR.c to be in idata (they might not ALL have to go there - I was trying to make it work without spending too much time on it)
Posts: 2
Registered: ‎02-13-2006

Re: USB CDC implementation for 'F32x

Hi,I use 'USB_CDC_skeleton_15.zip' on F320 test.I found short TX RX,when PC send data,PC only receive one time. I use 9600bps.Where have error?

------------------
Öæ»·¿Æ¼¼ÊµÑéÊÒ
http://www.zhlab.cn

[This message has been edited by l456789 (edited December 29, 2008).]
Öæ»·¿Æ¼¼ÊµÑéÊÒ http://www.zhlab.cn
Posts: 1
Registered: ‎02-02-2009

Re: USB CDC implementation for 'F32x

Hi all,

I am a newby on USB and hope you can point me in the right direction.
I try to create a wireless com port. For this I need a virtual com port on the pc and a usb-connected microcontroller that gets both the data and settings from this port. I tried this with an pic 18f4550 and the microchip cdc demo. This works okay - I get the data and messages when the baudrate changes, or DTR (and hope BREAK). But is does not work for the RTS signal. Just like described above.

Searching for option, I come across two: use a HID driver or write your own cdc driver. Both have rather much impact (I have to start on windows driver developemnt / and I was wondering if there is cdc driver out there that does what usbser.sys is supposed to do and could be configured to work with my setup.
And about this setup: there is an .inf file and a associated .cat that needed to be installed. As far as I understand, it links my app to the usbser driver.

Any help will be appreciated!

Joep
Posts: 472
Registered: ‎11-17-2003

Re: USB CDC implementation for 'F32x

l456789,

We cannot find a problem without seeing the code. Most people here in the forum don't speak or read chinese. Please link to your code, not the website.

jsuijs,

A CDC uses usbser.sys, which is built into Windows. All you need is an INF file. For Vista 64 you need to have it certified with a cat file. If you need control along with a serial port, take a look at the thread

USB Composite Device

I had to fix a few things (as shown in the thread), but otherwise it works great!

-Erik


[This message has been edited by egawtry (edited February 05, 2009).]
-Erik
Posts: 1
Registered: ‎03-17-2009

Re: USB CDC implementation for 'F32x

Can anyone please clarify how the device is expected to deal with unsupported parameters in SetLineCoding request? Should it return STALL?
Posts: 2
Registered: ‎03-31-2009

Re: USB CDC implementation for 'F32x

Hi... Great work on the demo, but I can't get it to run. I get the first character typed to echo in RealTerm on Com 4 just as expected, but then no more. I am running the '320 dev board and Win XP with Keil compiler. Suggestions anyone?
John
Posts: 472
Registered: ‎11-17-2003

Re: USB CDC implementation for 'F32x

1. Did you convert all the init functions to 320 from 34x?

2. Make sure that you have the mod for the SetLineCoding() bug as described in this thread.

3. Hook up the debugger and see where everything stops.

-Erik
-Erik
Posts: 2
Registered: ‎03-31-2009

Re: USB CDC implementation for 'F32x

I've checked through the code to make sure the '320 options are there. Characters come in, get read from the incoming ring buffer, and placed in the outgoing ring buffer, but never make it back to the PC. Everything keeps running, just doesn't transmit anything. I get an interrupt (IN2_FIFO_empty) on the first character output, and then no more.

[This message has been edited by JJcal (edited April 01, 2009).]
John
Posts: 472
Registered: ‎11-17-2003

Re: USB CDC implementation for 'F32x

Hmmm, I am more familiar with the CDC Composite code, could you try that? (It does the same thing but also provides an HID connection.) If that doesn't work, then I can really help. Otherwise, we (you, me and everyone else reading this) can try to debug things here.

You could try posting what you are using for your main() while loop.

-Erik
-Erik
Posts: 34
Registered: ‎01-17-2005

Re: USB CDC implementation for 'F32x

Hi,

We seem to be running into a problem where when we get an STSTL interrupt, there is also a packet in EP0 FIFO (OPRDY = 1).

The return statement in if (ControlReg & rbSTSTL) means this packet is ignored by the firmware, and eventually Windows sends a USB reset after a 5 second timeout.

This is happening in maybe 1% of cases, and is probably aided by the fact that our USB interrupts are off for a few ms.

I have removed the return to fix this, but this creates a new problem: sometimes after the STSTL, OPRDY is set, but all bytes in the SETUP packet you read out are the same.

To resolve this, we check for 8 identical bytes after reading the SETUP packet, and discard it if so.
Posts: 18
Registered: ‎06-21-2004

Re: USB CDC implementation for 'F32x

Typo in code found:

if ( endpoint == EP3_IN )
IN2_FIFO_empty = TRUE;

should be

if ( endpoint == EP3_IN )
IN3_FIFO_empty = TRUE;
Posts: 65
Registered: ‎03-16-2005

Re: USB CDC implementation for 'F32x

Thanks lakata ... and of course Tsuneo!
Posts: 65
Registered: ‎03-16-2005

Re: USB CDC implementation for 'F32x

BTW, I haven't gotten to the bottom of it yet, but the CDC_Skeleton_15 does not appear to work correctly under Win2k. It enumerates OK and a COM port is created. But data transfer only works from host to device.
Posts: 472
Registered: ‎11-17-2003

Re: USB CDC implementation for 'F32x

That is because CDC was not implemented propertly by MS until XPSP3.

-Erik
-Erik
Posts: 65
Registered: ‎03-16-2005

Re: USB CDC implementation for 'F32x

Thanks Erik. I tested it on a Mac Mini running OS-X 10.4 and Ubuntu Linux v7.1 and it works great so far. XP as well, of course. I just have to figure out what direction I want to go with the serial number string... (it's discussed here: http://www.lvr.com/usb_virtual_com_port.htm )
Posts: 472
Registered: ‎11-17-2003

Re: USB CDC implementation for 'F32x

I dynamically build the serial number off of the factory serial number that we set in the device. The code is simple, just a unicode string (every other byte a 0 with double zero at the end).
-Erik
Posts: 44
Registered: ‎12-03-2009

Re: USB CDC implementation for 'F32x

Hi!
Can i hope, that it will go working on XP SP3 ? Like reported here - COM3 recognized ok, but no function. Both directions dead. I does the correction described near above, so that may be not that problem.

Or - can enyone post me a realy working HID or other similar firm to make USB to RS232 bridge with WinXP SP3 built in drivers? Inf ok, but no new drivers needed pls. With C8051F32x pls!

Thx,
Feri
Posts: 472
Registered: ‎11-17-2003

Re: USB CDC implementation for 'F32x

I use the CDC on XP SP3, Vista, Win7, MacOS/X, and Linux. Works great on all of them.
-Erik
Posts: 9
Registered: ‎05-28-2002

Re: USB CDC implementation for 'F32x

Can this be made to work in large memory model ?
I am unable to use this in a larger piece of firmware - getting data space overflows

Thanks
Daraius
Posts: 2,027
Registered: ‎07-14-2007

Re: USB CDC implementation for 'F32x

Hi Daraius,

Quote:
Can this be made to work in large memory model ?

Even it can be done, I suggest to stay at small memory model by default and push the variables to XDATA only where it's needed. Using memory models other than small by default will result in bigger and slower code.

Regards,

Scotty
Posts: 19
Registered: ‎05-04-2016

Re: USB CDC implementation for 'F32x

Hello Tsuneo,

I realize that this thread was started over a decade ago and the last update to it is about 4 years old. Unfortunately, the link to the zip file at the beginning of the thread is no longer valid.

 

Tsuneo, is there any chance that you still have this project zip somewhere in your files?  If so, can you upload it somewhere and post a link to it?  Or possibly send it to me directly?

 

This would be greatly appreciated, I happen to have a need for this EXACT thing-- a customer that currently has a Windows front end that communicates over a Virtual Com Port to a CP210x, and this customer wishes to use an f320 to accomplish the same thing for another customer of theirs.  I could use USB HID in the f320, but this causes them a bit of trouble in their Windows app, they would prefer to continue using a VCP.

 

If I am able to do this for them in short order, then their customer would be quick to market with a new fairly high volume device using the f320.  Which means more money for SILabs, a great solution for their customer, and an easy port for me, it would be a  win-win-win!

 

Thanks, klim

Posts: 3,100
Registered: ‎02-07-2002

Re: USB CDC implementation for 'F32x

Since Tsuneo AFAIK neither is nor ever was a SiLabs employee, I fail to see the win for him.

Posts: 19
Registered: ‎05-04-2016

Re: USB CDC implementation for 'F32x

@vanmierlo,  I have seen so many of Tsuneo's posts over the years that I assumed he was a SiLabs/Cygnal employee. As for the 'win' for him, one could argue that because Tsuneo has been such an active member of these forums for so long, if he is not a paid employee, then clearly he must have a personal interest in lending his expertise to those in need. I have seen many of your posts over the years vanmierlo, are you an employee or do you find satisfaction in helping people out with your knowledge?

 

After receiving no initial response to my first post on this thread, I proceeded with working on an alternate solution for my situation (USB HID).  For anyone else that stumbles across this thread, I eventually managed to find a zip of what I believe is the source code at the link below.  I was able to compile (I recall I had to add the c8051f320.h file to the build) and I was able to download to my f320 dev board.  However, I was not able to get the f320 on the dev kit PCB to respond properly (enumerate with WIndows) when I connected it to USB. Because I was pretty far down the path to using USB HID, I didn't look further into what might need to be modified in this CDC code to make it work. If somebody else in the future is able to run this CDC firmware successfully then please post the solution here for the benefit of the community.   Best- klim

 

Link:

http://davr.org/dserial/USB_CDC.html

Posts: 8,134
Registered: ‎08-13-2003

Re: USB CDC implementation for 'F32x

are you an employee

with the rating of the poster it clearly states employee for those who are

erik
Highlighted
Posts: 19
Registered: ‎05-04-2016

Re: USB CDC implementation for 'F32x

"with the rating of the poster it clearly states employee for those who are"

 

Well now I/we now know this, thanks for that piece of info.