Connecting a programmer/debugger to my custom STM32 PCBs

When I make custom STM32 PCBs (such as my RF-mote or my ESC), I use an SWD connector for programming and debugging the microcontroller. The connector is a 6-pin micro-jst connector with 2mm pitch, which easily can be found by searching on ebay. An STM32 discovery board with stlinkv2 works perfectly for programming and debugging, and can be connected as shown here (click on the picture to get a larger version where the wire colors can be seen):

DiscoveryBoards_text

Notice that I have removed two jumpers on the discovery board to disconnect the SWD from the microcontroller. The pins in the jst connector are ordered in the same way as on the discovery board, but the outermost (green) cable is connected to 3V or VDD.

There are also some small and inexpensive stlinkv2 programmers available on ebay (just search for stlink v2), such as this one which I have soldered a micro-jst cable to:

EbayStlink_small

Update:

I had some problems with too long JST cables. If uploading the program does not work for you, try shortening the JST cable.

STM32F4 Discovery USB host and MP3 player

I have not written any new post for a while, so here is one more project for the stm32f4 discovery. I prepared this post a long time ago, but for some reason I never posted it, so here goes:

STM32F4_MP3

Based on one of the examples provided by ST, I have written a program for the STM32F4 Discovery board that plays MP3 files from an USB memory stick. You can download it here.

If you use a usb-host cable such as this one you can connect an USB memory stick (with fat32 file system) with mp3-files to the micro-usb port of the stm32f4 discovery. The files should then be played one by one. The user button can be used to skip to the next file.

If you follow this tutorial you should be able to build and upload the provided files right away.

The main.c-file has many comments, so hopefully you can figure out how it works. Using a USB-memorystick for logging is quite easy with this program as a basis. Only the two usb-pins, 5V and gnd are required to connect it to any stm32 with USB support, so hw-wise it’s even easier than using an SD-card.