Kevin Meyer

USB serial stack on JB16

Discussion created by Kevin Meyer on Nov 13, 2008
Latest reply on Dec 3, 2008 by Kevin Meyer
Hello all,
I've have just spent about a week trying to get a CDC / ACM USB stack working on a JB16.

Before you point out the slow maximum data transfer rate, I need to interface with existing software that communicates a short packet every few seconds at 9600 baud, so the JB16 ought to be fast enough.

At this moment, when I plug the device into either my Linux machine or my Windows machine, it is recognized as a serial port. It appears as an ACM device in Linux (/dev/ttyACM1) and as a COM port under Windows.

This just tells me that I have set up the descriptors, and have basic setup transfer working.

I do seem to be able to set line speed, etc, but I have not been able to 100% confirm this. As you can imagine, breakpoints interrupt the USB timing, so I have to use bit-toggling, which I monitor on an oscilloscope.

Unfortunately I can not send/receive data to the device. Under Linux I get " /dev/ttyACM1: Input/output error" when I try and read or write from the port, and the windows app just hangs. This also happens when I try and send a break under Windows.

I am attaching the output from "lsusb -v" (under Linux) and USBView (under Windows). I have just noticed that there is some suspicious information from USBView... I am also attaching my USB descriptors definitions. I left out the Call Management descriptor, as my Linux box complains that no call management is supported when I include it.

My questions are:
1) Does the JB16 support bulk end points on EP2? The ACM documentation says that the data endpoints have to be bulk, and Windows bluescreens on me if I set them to interrupt.

2) How do I ensure that the data class interface on EP2 is enabled to generate USB interrupts when data arrives? Is it as simple as writing 0xFF to UIR2, then setting UIR0_RXD2IE ? In short, why can't I read/write data to the device (serial port)?

3) The CDC documentation is very confusing to me. Can anyone simplify the process of packet flow for me? In particular, to which endpoint does data get sent when I change the baud rate, etc? I am assuming that this does not always happen during setup (i.e. USR0_SETUP is or can be false).

4) I seem to be getting a spurious interrupt on EP0 TX, but I can't tell if I am not servicing a required request, or not. I just send an empty packet in response. I thought EP0 TX interrupts on happen when I am sending data, but my program logic says that no data is waiting to be sent. Any suggestions?

5) I am assuming that when I want to send a notification to the OS that something has changed, I just prepare the data to be sent via EP1 (my notification end point), and enable the EP1 TX interrupt. Is this correct?

I am happy to release this project Open Source once I get it working.

Ultimately I wish to replace all JB16 specific register writes with generic #defines so that the code can be adapated to other devices. But first I would really like to get this working.

Outcomes