Jump to content
M-atthias

Bit-Bang USB on MSP430G2452

Recommended Posts

43oh Community USB board development in progress.

 

Dear Geeks and Wizards !

 

I happily invite you to share my joy ! Today, the first MSP430G2452 bit-banged the welcome ceremony of USB successfully. Crystal is 18 MHz.

 

Feel free to contact me via m-atthias@users.sf.net to get in touch with development.


Matthias Koch

--> Experimental Mecrimus-B 0.1 is out on mecrisp.sourceforge.net
 

Share this post


Link to post
Share on other sites

more info please..

 

is this a v-usb like low speed implementation?

 

how do u use a 18mhz crystal on a g2452? do u feed an 18mhz external clock?

 

what's the footprint like? 2k / 4k?

 

thanks in advance.

Share this post


Link to post
Share on other sites

Dear Geeks and Wizards !

 

I happily invite you to share my joy ! Today, the first MSP430G2452 bit-banged the welcome ceremony of USB successfully. Crystal is 18 MHz.

 

Feel free to contact me via m-atthias@users.sf.net to get in touch with development.

 

Matthias Koch

 

--> Experimental Mecrimus-B 0.1 is out on mecrisp.sourceforge.net

 

That is very good news. It would be nice if you could give us some more info.

Share this post


Link to post
Share on other sites

The file is under the download tab of his sourceforge page, named mecrimus-b-0.1.tar.gz.

 

It's an extension of his Forth on msp430 project.

 

All in Assembly, but the commenting is extensive. Only thing is that the majority of the comments are in (taking a logical guess) German. File is encoded in utf-8, so if you open it in something else (Western encoding) some of the letters don't show up right (mainly accented ones). Not sure if any of the code gets messed up, but the comments do so check that.

 

P2.0 to led anode, p2.1 to same led cathode, for a Sync/Activity Light

Seems that p2.2 is d-, tied to p2.5 as a controllable pullup for the usb connect/disconnect action?

p2.3 for d+.

 

From reading what I can (don't sprechen sie deutsch, and assembly is a pita), this is providing a usb 1.1 low-speed, unknown usb class? The usb descriptors don't seem to make sense.

 

Device_Descriptor:
.byte 18,   012h, 001h, 010h, 001h, 0FFh, 0FFh, 0FFh, 008h, 012h, 034h, 056h, 078h, 042h, 043h, 001h, 002h, 000h, 001h
Array Length, Descriptor Length (18), Descriptor Type (1, Device Descriptor), Usb Spec 0110 (USB 1.1), Class 0xFF (Vendor Specific), SubClass 0xFF, Protocol 0xFF, Max Endpoint Packet Size 8 (Bytes), VID 3412 [maybe 1234] (fake), PID 7856 [maybe 5678] (fake), Device Release Number 4342?, Manufacturer String Index 01, Product String Index 02, Serial Number Index 00, Possible configurations 1
 
Configuration_Descriptor_neun: (nine)
.byte  9,      9,    2,  9+9,    0,    1,    1,    0, 080h,   50
Array Length, Descriptor Length (9), Descriptor Type (2, Configuration), Total Length of Data Returned 9+9+0 (18 Bytes), Number of Interfaces 1, Configuration Value (1), Configuration String Index 0, Attribute Bitmap (0x80, 0b10000000, Bit D7 set, meaning USB 1.0 Bus Powered), Max Power in 2ma units (100ma)
Configuration_Descriptor_achtzehn: (eighteen, first nine identical to above)
.byte 18,      9,    2,  9+9,    0,    1,    1,    0, 080h,   50,    9,    4,    0,    0,    0, 0FFh, 0FFh, 0FFh,    0
 
But I don't see a interface or endpoint descriptor, and an interface descriptor would be needed with that Class code of 0xFF (vendor Specific). Possibly a usb-serial setup, but it's not identifying as a CDC device. The Protokollschleife.asm file has more stuff being done, but the german is heavy there.
 
TLDR; seems legit.

Share this post


Link to post
Share on other sites

if you don't want to wait for matthias to answer your questions, you can post the code lines your courious about and i'll translate the comments for you ;)

Share this post


Link to post
Share on other sites

Good morning !

This has been directly from my bench, but I wanted to share this immediately with you before going to sleep. Of course, the next days I will provide a translation and more documentation, as most of you are not speaking German.

- Yes, this is similar to the efforts of V-USB for AVR, but in a very early stage. I am in contact with Christian Starkjohann who wrote V-USB, and he helped me with valuable comments. Thank you !

- For now, Mecrimus-B implements a "vendor specific" do-nothing low speed USB 1.1 device, which essentially only connects and gives back its descriptors, which are quite small. But as this is a test for receiver, transmitter, checksum generation and protocol handling, I am very happy with that yet.

- I feed in clock with an external 18 MHz crystal oscillator; I choosed this so that I can hook up an oscilloscope probe without detuning.

- Memory footprint is 2,5kb now, as there are debug message routines included and an halt-disconnect-and-dump-packet point for unknown requests. USB alone should fit in 2kb code.

Connections are:

(P1.0 LED Anode for Bit-Banged RS232 sinal for outputting debug messages)

P2.0 Sync-LED Anode
P2.1 Sync-LED Cathode (unimportant, only soldered it in this way to be able to measure brightness later)

P2.2 D- over about 50 Ohms (two 100 Ohms resistors in parallel in my case)
P2.3 D+ over about 50 Ohms

P2.5 Resistor 1.5kOhms to D- as switchable connect/disconnect simulator

XIN feeded with digital external 18 MHz clock. Note that the XO runs with same voltage as MSP430, altough rated for 5V, it works.

D- has to be on a pin that for clock cycle reasons is accessible with the constant generator (the lower four pins) and D+ only has to be on the same port as D-.

Included is a picture of the current hardware setup, you will see:
post-25024-0-89182700-1354441605_thumb.jpg
-The test platform with msp430g2452 and external XO, connected with usb and spy-bi-wire
-Two 1N4148 diodes as voltage droppers for roughly 3.6V Vcc
-Optical coupled Lego-based-rs232 ;-)
-Screw terminals for whole Port 1 and power
-My own variant of a spy-bi-wire adapter

Tested with Linux 2.6.26-2-686 and UHCI Host Controller.

Questions are welcome !

Matthias Koch
 

Share this post


Link to post
Share on other sites

lsusb -v gives:

 

Bus 003 Device 002: ID 3412:7856
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass          255 Vendor Specific Class
  bDeviceSubClass       255 Vendor Specific Subclass
  bDeviceProtocol       255 Vendor Specific Protocol
  bMaxPacketSize0         8
  idVendor           0x3412
  idProduct          0x7856
  bcdDevice           43.42
  iManufacturer           1 Matthias Koch
  iProduct                2 Mecrimus-B
  iSerial                 0
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           18
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass    255 Vendor Specific Subclass
      bInterfaceProtocol    255 Vendor Specific Protocol
      iInterface              0
Device Status:     0x0000
  (Bus Powered)
 

Share this post


Link to post
Share on other sites

 

 

This has been directly from my bench, but I wanted to share this immediately with you before going to sleep. Of course, the next days I will provide a translation and more documentation, as most of you are not speaking German.

 

 

 

thanks for the quick reply. if i am to achieve something like u did, i would be as eager to announce it.

 

such implementation would boost the popularity of the msp430 especially if it can run on dip package value series. thanks for your work.

 

my next question is, will it be possible to use internal clock or the low speed 32khz crystal for timing? that will allow for a more compact deployment. i.e. something like the v-usb attiny85 setup.

 

 

Share this post


Link to post
Share on other sites

For short: Perhaps.

With an 32768 Hz crystal we could determine the internal DCO frequency with good accuracy. So altough we can precisely determine current clock and do adjustments, it is questionable if its step sizes will be small enough for direct use as accurate clock in USB. One more problem left is temperature stability - the DCO is specified to drift with temperature, but USB devices may be in operation for hours next to the stream of warm air from ventilation.

V-USB calibrates the internal DCO with the 1kHz frame clock, just as we would do with our 32768 Hz crystal in place; but then keeps track with a software phase locked loop which can cope with about +- 1%. Perhaps a dive deeper into the usbdrvasm165.inc of V-USB and some more correspondence with Christian Starkjohann could give an idea on how to implement that.

For now, my next steps are: Add comments for English speaking developers and implement some demo functionality. Perhaps a HID keyboard ? After that, I concentrate to perform the same with 15 MHz, which looks possible. This is within spec for MSP430 DIP parts, and a simple 15MHz crystal could be connected to XIN and XOUT.

If I have wishes free:

Now: I wish for testers and testing !

For spring 2013: I wish for someone with experience with V-USB and the mspgcc compiler who would like to merge my assembly efforts with the stable and proven C protocol handling code base and interface of V-USB.

Matthias
 

Share this post


Link to post
Share on other sites

 

For now, my next steps are: Add comments for English speaking developers and implement some demo functionality. Perhaps a HID keyboard ? After that, I concentrate to perform the same with 15 MHz, which looks possible. This is within spec for MSP430 DIP parts, and a simple 15MHz crystal could be connected to XIN and XOUT.

 

If I have wishes free:

 

Now: I wish for testers and testing !

 

For spring 2013: I wish for someone with experience with V-USB and the mspgcc compiler who would like to merge my assembly efforts with the stable and proven C protocol handling code base and interface of V-USB.

 

Matthias

 

 

if u are to make available some english comments, i am interested in studying the code and may be contribute. not sure if i am skillful enough but i can be a tester.

 

i don't have o-scope and such but i worked w/ v-usb before so i am familiar w/ the high level mechanisms at least.

 

 

Share this post


Link to post
Share on other sites

Mecrimus-B 0.2 is out.

English translations are included.
This time, it emulates an HID mouse that moves your pointer to the right.
Tested on Linux 2.6.26-2-686 with UHCI Host Controller.

lsusb -v:

Bus 003 Device 005: ID 3412:7856
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0         8
  idVendor           0x3412
  idProduct          0x7856
  bcdDevice           43.42
  iManufacturer           1 Matthias Koch
  iProduct                2 Mecrimus-B
  iSerial                 0
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           34
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      1 Boot Interface Subclass
      bInterfaceProtocol      2 Mouse
      iInterface              0
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.10
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      52
         Report Descriptors:
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0004  1x 4 bytes
        bInterval              10
Device Status:     0x0000
  (Bus Powered)
 

Share this post


Link to post
Share on other sites

Oh  man, usb HID (mainly joystick/gamepad) and usb-cdc would be the best things to work on honestly. Those two would have the most use of a v-usb like project.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×