Close
0%
0%

MSP430 Programmer using STM32

Use STM32 dev boad as a MSP430 programmer

Similar projects worth following
116 views
0 followers
MSP430 programmer on a STM32 development board

github


A programmer is a device used to program a microcontroller. Usually, it is just another microcontroller with a special program to communicate with a host (PC) and download a program to a device (MCU). However, most the time, programming a MCU requires a high voltage (> 5V) which would dissuade me from making my own because it would require some kind of level converter, but the MSP430 can be programmed entirely within 3.3V!
 

Once everything is working, the workflow using this custom programmer is only a tiny bit more involved than a real programmer. I still write and compile all my code in Code Composer Studio. Then, I run the python script, hit the reset button on the STM32, and that's it! I am willing to accept the 2 extra button presses in exchange for a free programmer.

Software:

I took the source code from slau320. I decided I only wanted to use the JTAG interface and not Spy-Bi-Wire (SBW), so I deleted all the code for SBW to get rid of the clutter. Then, I stepped through the program trying to see what was happening and cross-referencing the User's Guide. After I confirmed that the code worked, I wrote a routine which would receive a program from UART and program the device. Before writing the program, I made sure to validate the program and erase the correct flash sectors. Then, I wrote a python script that would run on the host (my PC) and send a program file over the UART to the STM32.

Hardware:

I used an STM32L432KC as a programmer because its what I had, and my goal was to program a MSP430G2231 because they are simple, cheap, and available in a PDIP package. In STM32CubeID, in the .ioc file I added some outputs for TMS, TCK, TDO, TEST, RESET, and an input for TDI. On the prototype board I connected all those signals to the correct pins on the DIP-14 socket and two more for +3V3 and GND. I decided to connect them with removable connectors so that I could potentially build a development board later.

Usage:

To tell Code Composer studio to output a hex file, you need to right click the project in the Project Explorer and then Preferences -> Build -> MSP430 Hex Utility -> Enable MSP430 Hex Utility. Next, go Output Format Options -> set Output Format to Intel hex (--intel, -i) from the dropdown. Then, run the python script with python3 msp430programmer.py <tty> 115200 <path-to-hex-file>. Restart the STM32 by pressing the physical restart button.

Expected output:

$ python3 msp430programmer.py /dev/ttyACM0 115200 '/hdd/CCSTUDIO/workspace_v12/white_noise/Release/white_noise.hex' 
[Host] Opening serial port /dev/ttyACM0 at 115200 baud rate
       starting...
[Host] Programmer is ready
[Host] Opening file /hdd/CCSTUDIO/workspace_v12/white_noise/Release/white_noise.hex
[Host] Writing file length 416 to programmer...
[Host] Writing file to programmer...
       Verifying .hex file...
       Connecting to target...
       Got JTAG ID: 0x0089
-vSuccessfully connected to target 0xf201
       Erasing target flash...
       Writing target flash...
       Successfully wrote target flash. Time elapsed 0:00.259
       Shutting down JTAG connection...
[Host] Exit

To find the tty on your device you can do

ls /dev/ | grep tty.usb

on MacOS or

sudo dmesg | grep tty

on Linux.

msp430programmer-main.zip

The whole repository zipped up

Zip Archive - 924.87 kB - 03/13/2024 at 00:39

Download

  • 1 × STM32L432KC The programmer
  • 1 × MSP430G2231 The device
  • 1 × A PC with STM32CubeIDE, Code Composer Studio, and Python For implementing the software

  • More Efficient Workflow

    Stefan Antoszko10/06/2024 at 01:33 0 comments

    October 5, 2024

    I finally added support for automatic wakeup of the programmer. Now, the programmer will forever wait for a wakeup message from the host and when it receives it, jump straight into the protocol. Before, I had to press the reset button each time I wanted to reprogram the board. Now, after plugging in the programmer, I only need to run the python script on my PC and it will wake up the programmer automatically! It doesn't seem like a big change but it saves one button press per compile/program, and if you have done any programming before, you know just how often you program and recompile and reprogram a board. By saving this one step in the build process, I hope it makes everything just a little bit smoother and save me more work in the long run!


    The board doesn't actually go into low power mode, it just waits idle. It could be desirable in the future to program the programmer to go into low power mode while it waits, but since the programmer is forever plugged into my PC, the benefit (saving a few mW) is not worth the effort to me right now.

View project log

  • 1
    Clone the git repo
    git clone https://github.com/antoszko/msp430programmer.git 
  • 2
    Create a new STM32L432KC project in STM32CubeIDE
  • 3
    Drag in all the files into the STM32 project and overwrite the old ones

View all 6 instructions

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates