Jump to content
M-atthias

Bit-Bang USB on MSP430G2452

Recommended Posts

 

I do it already with Attiny16 & V-USB, but i need more IOs for my own HID-Joystick. So i bought MSP430-Launchpad, and i want to try it with it. 

 

 

 

@@akdes

 

You can checkout the github package and start from there.

 

https://github.com/simpleavr/boot430

 

@@elpaso had contribute a hid430.c as an example build HID usage. I believe it's a mouse. All you need to do is to find and similar V-USB project (may it be joy-stick, keyboard, etc) and mesh them up. HIDs are similar enough and should be able to port easily.

 

If you still encounter problem. Please start a new thread and ask more specific questions (providing enough info for us to help you).

Share this post


Link to post
Share on other sites

Hi guys!

 

I am also new to this side of mcu programming...I started playing with the MSP430FE427A some months ago, mainly to learn how to manually solder SMD components, but then I read about its ESP module and I am trying to use it in a somewaht more complex project with energy measurements .

 

The thing is that currently I upload programs to the FE427A using the followng chain:

PC(Code Composer Studio) -> Launchpad -> FE427A

the problem is that this scheme sometimes work and sometimes doesnt.

 

I would like to know if its possible to use this bit banging technique to upload from PC to FE427A, excluding the Launchpad.

 

thanks in advance!

Share this post


Link to post
Share on other sites

Hi guys!

 

I am also new to this side of mcu programming...I started playing with the MSP430FE427A some months ago, mainly to learn how to manually solder SMD components, but then I read about its ESP module and I am trying to use it in a somewaht more complex project with energy measurements .

 

The thing is that currently I upload programs to the FE427A using the followng chain:

PC(Code Composer Studio) -> Launchpad -> FE427A

the problem is that this scheme sometimes work and sometimes doesnt.

 

I would like to know if its possible to use this bit banging technique to upload from PC to FE427A, excluding the Launchpad.

 

thanks in advance!

 

@@montesnublados

 

If your purpose is to establish a more reliable flash programming scheme, this project may not be the right choice. This project requires very specific timing routines done in assembly language and has only been tested in the 2xx series. Not sure it will work right on 4xx mcus. Without a reliable programming scheme, you will also have trouble building this.

 

The 4xx mcus has its own built in BSL that you can use. It will be more reliable to get it to work via a usb-serial cable.

 

Using a launchpad to program external chips are common and usually works well. If it fails sometime you can check if it caused by s/w or driver problems, etc. Instead of using CCS to do the flash you can dowload mspdebug which to me is a much straight forward way to flash and also easier to identify problems.

Share this post


Link to post
Share on other sites

Hi,

I've been playing with the MSP430 Launchpad for a few years now, and I'm looking for some help getting started with boot430.

I want to try to implement an HID keyboard so I can convert an old laptop keyboard into a USB one.  The setup already works using my Arduino Leonardo, but I would rather spin my own PCB and use SMD parts.  For that, I'm more comfortable with using the MSP430.  I'd probably split the key scanning and USB duties to separate MSP430g2553 chips, to ensure the software USB has enough free clock cycles to operate.

I've been using CCS to program it since I got my first Launchpad three years ago.  Is there any straightforward way to get boot430 working using CCS?

Thanks!

Share this post


Link to post
Share on other sites

I want to try to implement an HID keyboard so I can convert an old laptop keyboard into a USB one.  The setup already works using my Arduino Leonardo, but I would rather spin my own PCB and use SMD parts.  For that, I'm more comfortable with using the MSP430.  I'd probably split the key scanning and USB duties to separate MSP430g2553 chips, to ensure the software USB has enough free clock cycles to operate.

 

I've been using CCS to program it since I got my first Launchpad three years ago.  Is there any straightforward way to get boot430 working using CCS?

 

Thanks!

 

@@Felix24

 

It will be difficult to use boot430 on CCS, the assembler syntax between the two is very different and you will need to understand both well to switch boot430 back to CCS.

 

The original routine was provided by m-athias was done in a AS assembler, oPossum ported it for CCS assembler and I ported it to GAS, add the bootloader part to make it into boot430.

 

If you still want to use CCS, it would be better to use oPossum's code, which you can find by back-tracking this super long thread

It first appears here. But be sure to scroll down and find the updates. This is bare bone mouse emulation and you could easily change it into keyboard handling.

 

The other avenue is to install cgywin + mspgcc toolchain, assuming your are on windows and don't want to install linux. You can google how to get this done. The boot430 repository already contains a working keyboard / mouse demo contributed by elpaso, project as in this thread.

 

Regarding keyboard scanning, not sure having 2 mcus helps as this introduce additional communication between them. Keyboards (buttons) are really slow input devices and one 2553 should handle it find.

Share this post


Link to post
Share on other sites

Thanks for the reply.  I'm trying to find information on how to use cygwin and mspgcc, but I'm stuck.  The information I've found is very fragmented and short on details.  So far, the best I've found is your post from last November (http://forum.43oh.com/topic/4641-help-installing-mspgcc-20120406-p201209311zip/?p=41789)  Other than that, I've googled and basically come with nothing.

I have absolutely zero experience with cygwin, gcc, and mspgcc.  That being said, I figured out how to install Cygwin and also add more packages (gcc-core).  I also downloaded and unzipped mspgcc (mspgcc-20120406-p20120911.zip), but now I'm stuck.

In your post, you said to unzip it in c:\ and then tell it to compile whatever code is being worked on.

I assume this is the example of what I should type into the cygwin terminal:

/cygdrive/c/mspgcc-20120406-p20120502/bin/msp430-gcc -Os -Wall -ffunction-sections -fdata-sections -fno-inline-small-functions -Wl,-Map=blink.map,--cref -Wl,--relax -Wl,--gc-sections -I/cygdrive/c/mspgcc-20120406-p20120502/bin/../msp430/include -mmcu=msp430g2452 -lm -o blink.elf blink.c

Where do I have to put my main.c ("blink.c" in the example) in order for the compiler to read it properly?  Should it be in the same folder as msp430-gcc.exe?  I tried that and it didn't work (main.c not found), but I don't know if I did the right thing.

That's about as far ahead as I can ask right now.  Yes, I really am this much of a noob when it comes to open-source compilers.  I hope to eventually figure this out and create step-by-step instructions for boot430 written from a noob's point of view.

Thanks for any help!

Share this post


Link to post
Share on other sites

@@Felix24

 

My post on mspgcc is kind of old but it looks like it will work for you. I would usually put my projects under a "projects" folder (mine is called ez430) under my cygwin home directory. Under which I have separate folders for individual project, like /home/chrisc/ez430/blink, or /home/chrisc/ez430/boot430 (download from github and unzip under your project directory.

 

cygwin is a (mostly) command line environment, you would open up a cygwin terminal shell (by clicking on the cygwin icon), which would place you in your home directory, say /home/felix or something. You could do a "mkdir projects" to create a project directory, a "cd projects" to move there, another "mkdir blink", "cd blink" to create and get to the target working directory. Now you should just place your blink.c inside this /home/felix/projects/blink.c.

 

To compile you can do

 

/cygdrive/c/mspgcc-20120406-p20120502/bin/msp430-gcc -Os -Wall -ffunction-sections -fdata-sections -fno-inline-small-functions -Wl,-Map=blink.map,--cref -Wl,--relax -Wl,--gc-sections -I /cygdrive/c/mspgcc-20120406-p20120502/bin/../msp430/include -mmcu=msp430g2553 -o blink.elf blink.c
 
The path "/cygdrive/c/msp..." where "cygdrive" is the way cygwin maps your windows "C" drive to it's file system.
You could path place the mspgcc bin directory into your $PATH environment variable to save some typing in the future. You can do that by editing your /home/felix/.profile (hidden file) and add something like a "export PATH=$PATH:/cygdrive/c/mspgcc-20120406-p20120502/bin" line at the end.
 
If you can compile successfully, you will also need a flasher, say mspdebug to download your firmware to the launchpad. So you need to have it downloaded and placed somewhere.
 
If you still fails to compile, or if you encounter other problems, post the error message here and we can figure it out.
 
If things go well, you will clone boot430 and put it under your project directory, change directory and work there ~/projects/boot430. And do "make -f Makefile.hid", this will build the hid example instead of the boot430 example. But the makefile assume you had your mspgcc/bin setup in your $PATH environment variable.

Share this post


Link to post
Share on other sites

Thank you for your excellent, clear instructions.  I was able to compile successfully, and now I have to figure out how to upload it to the Launchpad.  I followed this site (http://gnutoolchains.com/mspdebug/tutorial/) down to step 12, and after typing in

mspdebug rf2500 "prog main.elf" gdb

I get an error: "unknown command: rf2500 (try "help")"

What am I missing?

Share this post


Link to post
Share on other sites

@@Felix24

 

Did you mean "unknown driver: xxxx (Try --help for a list.)"?

 

Can you try 'mspdebug rf2500 "prog main.elf"', i.e. w/o gdb at the end?

 

The command looks OK and that what I use, except I don't have gdb. rf2500 is the driver for the G2 Launchpad.

 

If it still fails, please capture the whole error (cut and paste on a post). Also do a "mspdebug --version", You may do a "mspdebug --help" and see the list of supported driver for your mspdebug version.

Share this post


Link to post
Share on other sites

Success! But something else broke.

I ommitted the gdb on the end of the command, and the program uploaded successfully, however now CCS can't upload programs.

On another site (http://mspdebug.sourceforge.net/faq.html#launchpad_windows), it was briefly mentioned "Make sure you don't have the TI USB drivers installed."  There was no mention of what I should do if the TI drivers ARE installed, since I've been using CCS for programming.

I hope the issue is fixable, as I'd like to be able to program and debug in CCS as well as mspdebug, on the same computer.

I am using mspdebug-0.19-windows, and CCS 6.0.1.00040.

Share this post


Link to post
Share on other sites

 

I hope the issue is fixable, as I'd like to be able to program and debug in CCS as well as mspdebug, on the same computer.

 

I am using mspdebug-0.19-windows, and CCS 6.0.1.00040.

 

You should be able to use both. I had both CCS6 and mspdebug-0.20 and they both works. You might want to unplug / plug your LP when you switches. May be different drivers claiming interfaces need to be released.

Share this post


Link to post
Share on other sites

Well, it works now.  I made sure both CCS and the command prompts for mspgcc and mspdebug were closed, then I opened CCS and tried again.  No problem this time.

 

Thanks for your help!

 

Now, on to playing with the HID stuff...

Share this post


Link to post
Share on other sites

I am able to compile the code for the mouse HID example by running "make -f Makefile.hid".  I am able to upload the hid430.elf file just fine. However, when I constructed the circuit and plug it into the computer, Windows says, "USB Device Not Recognized".

I feel like I'm forgetting something.

I've tried:
1. swapping the D+ and D- pins, just in case I made a mistake.
2. changing resistor values for D+ and D-.  Originally I had 100 parallel with 220 resulting in a theoretical 68.75ohms, and then I changed it to 100 ohms, then 47 ohms.
3. moving the 1.5k pullup from D+ to D- and back (see below).
3. adding a 32.768kHz crystal and enabling it in the makefile.
4. trying it on both the g2452 and the g2553.
5. measuring supply voltage, steady at 3.3v, regulated using 73ohms and a 3.3v Zener diode.
6. examining current draw by the microcontroller to make sure it's getting proper power.  With the RST pullup resistor in place, the current draw is about 4.78mA, without it the current is about 0.1mA.
7. checking the USB cable I'm using.  It is fine.
8. unplugging and plugging it back in multiple times.

In the schematic in hid430.c, the 1.5k pullup is shown to be attached to P1.0 and D+, but in the boot430 readme, it is attached to P1.1 and D-.  Which is correct?  Or are they different for the two programs?

When I compile, this is the output:

$ make -f Makefile.hid
msp430-gcc -Os -Wall -mmcu=msp430g2553 -ffunction-sections -fdata-sections -fno-inline-small-functions -Wl,-Map=bbusb.map,--cref -Wl,--relax  -c hid430.c
hid430.c:130:6: warning: return type of 'main' is not 'int' [-Wmain]
msp430-gcc -Os -Wall -mmcu=msp430g2553 -ffunction-sections -fdata-sections -fno-inline-small-functions -Wl,-Map=bbusb.map,--cref -Wl,--relax  -o hid430.elf hid430.o bbusb_packet.o bbusb_protocol_hid.o bbusb_receive.o bbusb_transmit.o

When I run mspdebug, this is the output:
 

MSPDebug version 0.19 - debugging tool for MSP430 MCUs
Copyright (C) 2009-2012 Daniel Beer <dlbeer@gmail.com>
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Trying to open interface 1 on \\.\libusb0-0001--0x0451-0xf432
Initializing FET...
FET protocol version is 30394216
Configured for Spy-Bi-Wire
Set Vcc: 3000 mV
Device ID: 0x2553
Device: MSP430G2553
Code memory starts at 0xc000
Number of breakpoints: 2
Erasing...
Programming...
Writing 1858 bytes to c000 [section: .text]...
Writing  190 bytes to c742 [section: .rodata]...
Writing    6 bytes to c800 [section: .data]...
Writing   32 bytes to ffe0 [section: .vectors]...
Done, 2086 bytes written

I feel like I'm so close but I'm forgetting one small, important thing.

 

 

Share this post


Link to post
Share on other sites

@@Felix24

 

I've tried:
1. swapping the D+ and D- pins, just in case I made a mistake.
2. changing resistor values for D+ and D-.  Originally I had 100 parallel with 220 resulting in a theoretical 68.75ohms, and then I changed it to 100 ohms, then 47 ohms.
3. moving the 1.5k pullup from D+ to D- and back (see below).
3. adding a 32.768kHz crystal and enabling it in the makefile.
4. trying it on both the g2452 and the g2553.
5. measuring supply voltage, steady at 3.3v, regulated using 73ohms and a 3.3v Zener diode.
6. examining current draw by the microcontroller to make sure it's getting proper power.  With the RST pullup resistor in place, the current draw is about 4.78mA, without it the current is about 0.1mA.
7. checking the USB cable I'm using.  It is fine.
8. unplugging and plugging it back in multiple times.

In the schematic in hid430.c, the 1.5k pullup is shown to be attached to P1.0 and D+, but in the boot430 readme, it is attached to P1.1 and D-.  Which is correct?  Or are they different for the two programs?
 

 

The pullup should be w/ P1.1 (D-), this will signal the host that it is a low-speed device. Elpaso's ascii schematic is incorrect I think, checking the hhusb.h header file confirms the 1.5K should be tied to P1.1 (D-).

 

3. Trying not to use the clock crystal might help. Myself and Elpaso did not use one. The crystal was only used quite early in the development and I had never used it after changing the code to get timing from the usb host. So not sure if it still works properly (although it should). Taking it out can eliminate one source of problem.

 

5. Although you see 3.3V, as in V-USB, you can also try 3.6V zener, or try on a different PC. Different PC / notebooks uses different host chipsets and they tolerate clients differently. Trying it on a Linux box will give you more detail error messages via dmesg. When I did this, 90% of the problem is hardware related. Especially so if you are breadboarding. You can search v-usb hardware problems / tricks on the web and get some hints, the hardware is identical / interchangeable. My experience is that a LDO works better than a zener setup (at least on breadboard).

 

7. If possible try cut your cable shorter can help.

 

8. It may help if you can see where it fails, can use winshark wireshark to peek at the messages. Will take time though.

 

* May be try boot430 firmware and see if the "sync led" blinks or not. It will at least give you indication on whether the timing code got locked-up or not. But be sure to add current limiting resistor to the "sync led".

 

/EDIT should be wireshark

Share this post


Link to post
Share on other sites

I moved the pullup to the proper pin, left the power supply as-is, and left out the clock crystal.

I read about adjusting the delay to allow the clocks to stabilize.  I reduced the delay in line 169 in hid430.c from 1000000 to 100000 cycles, and my laptop (the original computer) started recognizing and installing it.  I changed it further to 10000 cycles, and now my desktop recognizes it too, but only if I plug it in at the back and not the external USB hub.  So now it works well enough to start programming.

The circuit is currently on a breadboard.  I'm mystified as to how reducing the delay allows it to work better for me, especially when using a breadboard.  Maybe the delay was just too long, making the computer think it was dead.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...