Jump to content

  • Log In with Google      Sign In   
  • Create Account

Photo

Bit-Bang USB on MSP430G2452


  • Please log in to reply
271 replies to this topic

#1 M-atthias

M-atthias

    Level 1

  • Members
  • 58 posts

Posted 01 December 2012 - 10:51 PM

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
 


  • ike and jrychter like this

#2 simpleavr

simpleavr

    Level 3

  • Members
  • 721 posts
  • Locationtoronto

Posted 02 December 2012 - 12:46 AM

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.


www.simpleavr.com :: breadboard good, use breadboard

#3 bluehash

bluehash

    Site Admin

  • Administrators
  • 5,523 posts

Posted 02 December 2012 - 02:01 AM

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.


Stellarisiti - Join the new Tiva-C/Stellaris ARM Forums discussing Tiva-C(Stellaris) Microcontrollers.

C2kCentral - C2000 News, Projects and Forums
43oh - MSP430 Discussion, News, Projects and Hacks
MachineGrid - Robots, Hacks and Technology!


#4 JWoodrell

JWoodrell

    Level 3

  • Members
  • 445 posts

Posted 02 December 2012 - 03:37 AM

congratulations, but we wanna see pictures and details :smile:  Its always fus to see how someone else gets things to cooperate


Visit my Blog to see all my current projects
Joseph's Electronics Blog

#5 cde

cde

    Enigmatic Decadence

  • Members
  • 897 posts

Posted 02 December 2012 - 07:28 AM

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.


#6 jpnorair

jpnorair

    Level 3

  • Members
  • 656 posts
  • LocationSan Francisco

Posted 02 December 2012 - 09:22 AM

I've wondered if a timer + DMA could be used to improve somewhat the performance of a bit-banged low-speed USB.


jpnorair: GitHub | Wikipedia | Wiki | Blog | Haytag

#7 Philipp

Philipp

    Level 1

  • Members
  • 102 posts
  • LocationGermany

Posted 02 December 2012 - 09:36 AM

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 ;)



#8 M-atthias

M-atthias

    Level 1

  • Members
  • 58 posts

Posted 02 December 2012 - 09:48 AM

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:
Attached File  Hardware.jpg   197.74KB   247 downloads
-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
 


  • bluehash, simpleavr, cde and 3 others like this

#9 M-atthias

M-atthias

    Level 1

  • Members
  • 58 posts

Posted 02 December 2012 - 10:17 AM

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)
 



#10 bluehash

bluehash

    Site Admin

  • Administrators
  • 5,523 posts

Posted 02 December 2012 - 01:35 PM

Thanks for  the update Matthias. I can understand your excitement when you got this running. Keep the updates coming. 


Stellarisiti - Join the new Tiva-C/Stellaris ARM Forums discussing Tiva-C(Stellaris) Microcontrollers.

C2kCentral - C2000 News, Projects and Forums
43oh - MSP430 Discussion, News, Projects and Hacks
MachineGrid - Robots, Hacks and Technology!


#11 simpleavr

simpleavr

    Level 3

  • Members
  • 721 posts
  • Locationtoronto

Posted 02 December 2012 - 03:17 PM



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.

 

 


www.simpleavr.com :: breadboard good, use breadboard

#12 M-atthias

M-atthias

    Level 1

  • Members
  • 58 posts

Posted 02 December 2012 - 05:11 PM

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
 



#13 simpleavr

simpleavr

    Level 3

  • Members
  • 721 posts
  • Locationtoronto

Posted 02 December 2012 - 07:19 PM


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.

 

 


  • M-atthias likes this
www.simpleavr.com :: breadboard good, use breadboard

#14 M-atthias

M-atthias

    Level 1

  • Members
  • 58 posts

Posted 03 December 2012 - 01:58 AM

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)
 


  • bluehash, jsolarski, simpleavr and 3 others like this

#15 cde

cde

    Enigmatic Decadence

  • Members
  • 897 posts

Posted 03 December 2012 - 02:04 PM

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.



#16 M-atthias

M-atthias

    Level 1

  • Members
  • 58 posts

Posted 03 December 2012 - 02:56 PM

With some more testing, including with a Windows 7 host, I detected a race condition.

This is fixed now. Mecrimus-B 0.2.1 is out.

Matthias
 


  • bluehash likes this

#17 jsolarski

jsolarski

    Level 3

  • Members
  • 526 posts
  • LocationChicago IL

Posted 04 December 2012 - 05:38 AM

Down loaded the most recent one. Will test tomorrow on my LFS linux (3.5.x kernel)



#18 larsie

larsie

    Level 2

  • Members
  • 272 posts

Posted 04 December 2012 - 10:01 AM

Very cool and important project! Looking forward to hear the continued work. 



#19 CsCrazy

CsCrazy

    Member

  • Members
  • PipPip
  • 15 posts
  • LocationFinland

Posted 04 December 2012 - 10:15 AM

I would like to see an C implementation of this. Also if it is possible to modify the code for this to operate with 16 MHz crystal it would be great too, because I think 16M is more common frequency than 18M. 

 

Anyways, great job!



#20 jrychter

jrychter

    Member

  • Members
  • PipPip
  • 29 posts

Posted 05 December 2012 - 08:31 PM

This project is spectacularly important. I could really use an inexpensive USB interface in many MSP430 projects, where an FT232RL is simply out of the question because of the price! Most of the time I only really need a simple UART.

 

Congratulations on your first successes, and I'm hoping to see more soon.


--J.

http://jan.rychter.com/enblog/ - my mostly-electronics-related blog

@jrychter on Twitter

 





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users