Getting to Blinky with CX-10

10 Jun

As with all embedded systems, getting to blinky is the first thing you want. Please refer to the previous post on preparing the hardware to have a programmable setup with the flash memory of the processor cleared.


Most of the examples found on the internet rely on the default STM32 libraries. For this project, I am going to use libopencm3, which is an open-source version. To download libopencm3 and examples, download the following git repository:

git clone

 The example we want to use (and modify a little) is in this directory:


 Modification of miniblink code

The default blinky code will not work on the CX-10, since the LED is at a different pin. But even more important, the CX-10 [blue pcb] has an onboard voltage regulator which needs to be enabled by the processor itself, otherwise the processor will shutdown! This feature is useful later because thereby you can switch off power if the battery voltage level drops below a certain value. Change the miniblink.c file to the following:

/* License removed for clarity */
#include <libopencm3/stm32/rcc.h>
#include <libopencm3/stm32/gpio.h>

/* Blue LEDs connected at PB2 */
#define PIN_LED GPIO2

/* Linear Dropout Regulator connected at PA5 */
#define PIN_LDO GPIO5

static void gpio_setup(void)
    /* Enable GPIOA and GPIOB clock. */

    /* Configure pins as output. */

    /* Set LDO pin HIGH to enable the voltage regulator which supplies power to the processor */
    gpio_set(GPIOA, GPIO5);

int main(void)
    int i;


    /* Blink the LED (PC8) on the board. */
    while (1) {
        /* Using API function gpio_toggle(): */
        gpio_toggle(PORT_LED, PIN_LED);    /* LED on/off */
        for (i = 0; i < 1000000; i++) {    /* Wait a bit. */

    return 0;

Now, open the terminal and navigate to this directory. Connect the Discovery Board with the CX-10 connected to the SWD header. Make sure to apply external power as explained in the previous post. You also need to download and install stlink first. Upload with the following command:

make miniblink.stlink-flash

Now, the blue LEDs should be blinking. If you remove the external power and use battery power, it should also be blinking.


Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.