NUCLEO-L031K6 and ST-LINK SWD. What on earth did I do?

ST has a nice family of ultralow power microcontrollers (or MCU for short) that can be used in applications with energy harvesting power supplies. My objective was to use one of these MCUs to test the capabilities of an energy harvester based on Peltier cells to power an application to acquire signals from a sensor. I chose an STM32L031K6 MCU because I could easily find a unit with a LQFP32 (low profile quad flat package) easy to solder on a bare breadboard such as:

easily found on ebay. And, most importantly, I had a development board based on the same MCUs available from ST, NUCLEO-L031K6. I could test my program on the NUCLEO board and then flash it in the stand alone chip to know how much power consumption did I have. The power consumption can be estimated in the NUCLEO board but the process is awkward and probably not reliable since there are LED everywhere and currents are drained in unexpected ways.

My problem was how to flash that stand alone STM32L031K6 MCU. I knew from the Arduino side that it is possible to program an MCU via a serial connection with Arduino UNO but it was difficult to find information about how to do it with STM32 products. The main reason is because most people use ST-LINK and do not need anything else. Well, I didn’t have an ST-LINK programming device (also found in ebay) and I wanted to accept the challenge of finding another way with the tools I had. The answer to a question I posted on the mbed discussion forum gave me some clues as how to proceed. There seemed to be an alternative to the serial port and it was to use the SWD (serial wire debugging) port with an external flash device. The ST-LINK uses the SWD to flash the target processor on a nucleo or discovery board and I could use the ST-LINK of any nucleo to flash an off-the-shelf processor as Wim kindly told me. I had a nucleo board! and… I also had a discovery board! mine was a discovery kit with STM32L476VG MCU, so I decided to give it a try.

Continue reading NUCLEO-L031K6 and ST-LINK SWD. What on earth did I do?