Monday, October 6, 2014

MSP340 Launchpad Fet

In order to do In System Programming (ISP) you usually need a Flash Emulator Tool (FET). For the Texas instruments MSP340 family you can buy the one that TI sells for their MCUs:

Official TI MSP340 FET
That costs about 100$ and it isn't too much if you program MCUs for a living. It can work with supplies from 1.8V to 3.6V and do program/debug using JTAG or Spy-By-Wire (2 Wire) interfaces.

For the hacker that buys their own tools there are cheaper solutions. You can find several references on Internet about people that have used the MSP430 Launchpad to do ISP programming. This Launchpad board is designed to program MSP430 MCUs of the "G" value line in dip packages using an included 20 pin socket. As all the signals needed to do Spy-By-Wire are available so you can use this board to program MCUs located in another board as long as you route the needed signals: TDIO, TCK and the reference GND to the proper pins of the MCU to program.

This article explains a FET implementation using the TI Launchpad. As this board provides also a serial TX/RX communication using the PC USB connection. It will also be implemented in the FET.

Features


  • Two Wire Spy-By-Wire for the MSP430 family
  • Serial TX and RX communication at 3.6V level

Limitations and Disclaimer


The FET will inherit all the limitations related to the use of the TI Launchpad as a FET device.
  • Can only use Spy-By-Wire, no full JTAG is available
  • It can only work with and provide 3.6V
The second limitation could be important. As the Launchpad works at a fixed 3.6V supply, the provided Vcc and the signaling is at 3.6V. As long as the board you communicate with is at about 3.6V all will be ok. 
As 3.6V is the maximum operating voltage in the MSP430 you cannot connect the FET to a board that operates the MCU at a greater voltage. In the case of connecting to a board that uses a lower voltage, let's say 2.5V, you could power the board without using the FET, but the signaling from the FET to the board will be at 3.6V and that could be above the Absolute Maximum Ratings from the MCU. Adding level shifters is out of the goals of this project so I recommend using this FET only when the board is powered between 3.3V and 3.6V in order to guarantee that the Maximum Ratings are not exceeded.

If the connected board should work at less than 3.3V I recommend to power it at 3.6V from the FET during the programming and debugging and powering it at it's own lower voltage when it is disconnected from the FET.

Off course this document is only a documentation of something I have done for myself and there are no provided guarantees that it will suit your own needs or that it won't blow-up your home. Yoy have been warned.


Launchpad Signals and project schematic

The signals needed to program a MSP430 chip and provide Serial communication are mainly at the J3 connector that links the emulator upper side of the board with the target MCU lower side. As we won't use the lower part, we will take out all the five jumpers in J3.

Launchpad connectors used

The signals used will be:

  • SBWTDIO: Two wire data / nRESET
  • SBWTCK: Two wire clock
  • VCC: 3.6V supply generated from the USB line using a regulator
  • RXD: Serial from MCU to the PC
  • TXD: Serial from the PC to the MCU
We will also need a common GND node. This one is not available at J3, so we will take it from pin 20 at J2.

The connector J1 is not needed, but as the Launchpad has no mounting holes, it will be used to provide physical support.


Project Schematic

The above schematic shows all the needed connections. In the Launchpad we will use J2 and J3 to provide the needed signals. Those signals will be routed to a 2x4 male connector that will be used to do ISP on the target MCU. I have removed one pin in the connector (marked with X) to be able to develop cables that can only be connected in the right way and not in the 180 degree rotation position.
A LED to check that the Launchpad is operating and a push button to force a RESET on the target MCU complete the schematic.


Construction

To build the project I have selected a box that is just over the Launchad board size.

Project Box
All the connections will be done on a perf board. In order to mount it on the box four M3 thread 10mm spacers are fitted inside the box.

Box with fittex M3 spacers
The board is cut to the box size and it has been milled to leave space to the thread posts that are in each corner of the box. Four holes match the four spacers in the box.

Perf Board
As I have commented, the Launchpad board has no mounting holes, so I will put it over the perf board upsidedown. That means that the connections on the board will be mirrored respect to the Launchpad ones as seen from above.

Board Distribution

I have used three connectors, one female 2x5 to match J3 and two females 2x7 that connect to J1 and J2. I know that J1 and J2 are 1x10 male, but I had those 2x7 connector lying arround and as I only need to connect one pin at J2 that's ok for this project.
The LED  will be connected to the board with a pair of wires. To make things cleaner I have added a 2 pin male connector in the board to connect it.

The following figure shows the populated perf board with all components. The LED  that will connect to the two pin male connector is also shown .

Populated perf board

To make the necessary connection I have used WMS (Wire Mess Routing). As the connections are easy this is ok for this project.

Wire mess under the board
The board is mounted inside the box and it is secured with four M3 screws.
To connect the Launchpad board all five J3 jumpers and the DIP MCU must be removed.

Launchpad Board without MCU or J3 jumpers
The Launchpad board is mounted upsidedown over the perf board and the LED is fitted in a 5mm hole and connected to the board.


Four holes are made on the box. One for the Launchpad USB connector,



two for the ISP connector and the LED,



and the last one for the RESET button. This one is missaligned, I know.


Four feet bumps, one on each corner complete the box and makes it stable over a table.


To end the build I have added a picture over the box with the ISP connector pinout.



 Echo Blink Test Program

To test the FET we need a program to load in a MCU using ISP. The developed program blinks a LED so we can see that the program has been corretly transfered to the MCU.
The program also provides an echo functionality using the serial port. Each character received from RX is converted to uppercase (if it was between 'a' and 'z') and then it is echoed to TX. That way we can also test the serial communication using the same program.

I have three toolchains to work with the MSP340 familly:

The last one, Energia, is interesting because it provides an Arduino like IDE for the MSP430 familly. If you don't know Energia and like Arduino, chek it out. One important difference with Arduino is that Arduino boards are programmed using a bootloader, so you need a resident program in the MCU. Energia, uses Spy-By-Wire, not serial, to do the programming so it doesn't need a bootloader. This makes easy to program any compatible MSP430 chip you have bought.

Energia, in the same way that the Arduino IDE don't provide hardware debug functionalities. As the FET can be used to do hardware debugging on the target MCU, using Energia is not the most featured solution, but sure it is the easier to get working. So, I developed the Echo Blink program as an Energia sketch.

The Echo Blink sketch is provided in this link. But you can also see it here:



The program just blinks a led on P1.0 (pin 2 on MSP430G2553) changing its state each 200ms. During the 200ms wait between changes, the RX line (FET TX) is tested for incoming chars each millisecond and the characters are changed to uppercase if they were in lowercase and echoed to TX (FET RX). If no character is echoed during each 200ms wait, a '.' char is sent to TX. That way TX can be tested alone.

Simple ISP schematic

You can program a system outside of the Launchpad board using the FET. At a minimum, it needs to have the needed connections between the FET and the MCU: GND, TCK and TDIO. The Reset line that is shared with TDIO must not be connected directly to Vdd. A 47k resistor to Vdd and a 1nF or 2.2nF to ground works ok. You can also add a reset button if needed in this line.
The following figure shows a simple system to be ISP programmed.

Basic ISP system based on MSP430G2553
Aside from the described ISP and RESET connections there is a 100nF decoupling cap. The serial TX and RX are also included but they are not needed to programming.

System Test

To test the system I have connected it to and a PC and a MSP430 G 2553 and loaded the Echo Blink program.

System running, only tested programming on this test
I have also connected the system to a 28 pin TSSOP MCU, using a SMD to DIL adaptation board, and it also works ok.

Test of a MSP430 G 2553 in TSSOP 28 package

All in all I'm quite satisfied with this build. It eases programming a MSP430 MCU using a launchpad board.

Echo Link Program Running



Addition at 7/10/2014: It seems that someone has made the same upsidedown FET configuration before. It don't surprise me. You can find it at this link. (It's in Hungarian)

Update at 30/11/2014: Now the EchoBlink.ino sketch is embedded in the blog using Gist

2 comments: