USB serial stack on JB16

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

USB serial stack on JB16

1,729 Views
markslFS
Contributor I
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.
Labels (1)
0 Kudos
3 Replies

350 Views
MrBean
Contributor I
> 1) Does the JB16 support bulk end points on EP2?
 
No. Bulk endpoints only apply to full speed usb. JB16 is only low speed.
0 Kudos

350 Views
markslFS
Contributor I

Thanks to everyone for their help.

It seems that while the low speed standard does not support bulk endpoints, one can still define an endpoint to be bulk on a low-speed device.

Since my first post, I have now been able to send and receive data under Windows (Windows 2000), but not Linux (Ubuntu Dapper). Perhaps Linux is being more true to the standard. I also receive announcements like SetLineEncoding, SetBreak, etc.

Anyway - I have to stop working on this project - it has taken too much time. I am attaching my abstract call model project. Perhaps someone who knows a little more about the ACM can have a look at it and point out the obvious problem that I am missing - I feel convinced that I am mis-handling some packets that arrive on EP0.

The project has two targets, a keyboard HID from elsewhere on this site, and the virtual com port CDC ACM project. If anyone makes any improvements, please could they post the updates here. I have also used parts from the USBDM and drawn inspiration from some other CDC ACM projects (Microchip and CMX).

The project is somewhat device independent - but it will take some work to reconfigure the register read/writes that access the USB peripheral on the JB16, to make it work with other devices.

The numerous DEBUG*_PULSE, etc, are my toggling bits lines that I monitor on an oscilloscope to confirm program flow.

To conclude, it mostly works under Win2K. It mounts as a /dev/ttyACM under Linux, but I can't write to it.

 

usb_hal_v_00_20081118_1143.zip

Message Edited by t.dowe on 2009-10-27 12:01 PM
0 Kudos

350 Views
markslFS
Contributor I
I just wanted to let you all know that after leaving this project alone for a bit, I have now made sufficient progress to be able to justify calling the project a success! (Despite the protocol violations of specifying that endpoint 2 use bulk transfer on a low-speed device).

If anyone is interested, let me know, and I'll post the current project here.

It still won't work under Linux, presumably because of the above mentioned protocol violations.

To summarise: Under Windows 2000 (and presumably XP), the project uses Windows' own usbser.sys to provide a virtual COM port. It is implemented on a JB16. A very basic .inf file is needed to complete the installation.

Next up, to consider converting this code to work on the JM32/JM60 high-speed device.
0 Kudos