Start Learning STM32F4 MCU Programming in 3$

Overview

Do you want to start using high-performance MCUs (100 MHz+) for advanced applications having interfaces like SD Card, TFT Display, Ethernet, etc.?

There are many very low cost STM32F4 Board available which could be used to start learning. Check some options here.

Programmer & Development Board

For the basic setup you will need debugger/programmer & STM32F4 board.

I recommend STLINKV3 mini as in-circuit debugger & programmer(~10$) and a low cost STM32F401 Board(~3$).

STM32F401-Development-Board

Connections

STLink V3 Mini can be connected to STM32F4 development board using SWD Interface and you will need only three pins to interface i.e. SDIO, SCLK, GND.

You need to power STM32F4 development board separately as STLink V3 will not give 3.3V power output to power the board.

Start Learning STM32F4 MCU Programming in 3$ 1

In the above image, you can see STLINKV3 Mini Programmer connected to the development Board.

To check, if the programmer is connected properly and working fine or not, we can try to use STLink Utility Software and see if it connects. If everything is working ok, you will see something like as shown below.

The STLInk Utility Software window will looks like this:

Start Learning STM32F4 MCU Programming in 3$ 2

Once you connect, it will read the device configuration and read internal Flash Memory. You can see the image below:

Start Learning STM32F4 MCU Programming in 3$ 3

The development board has SPI memory on the bottom side, one user switch and one user LED, which could be used for initial programming and add-on boards can be connected as per the need on the headers using jumper wires.

Development Environment & Blinking LED Program for STM32F4

Let us a develop a basic program for blinking LED. On the development board, one LED is connected on the Port C, Pin 13 (PC13).

I have used STM32CubeIDE for the development Environment.

You can create a new project link shown in the video below:

One you have created the project. You can add following dummy delay function above main() function

void delay(unsigned long cycles)
{
	while(cycles) cycles--;
}

Also add the following to configure the PC13 GPIO pin as output

__HAL_RCC_GPIOC_CLK_ENABLE();  //Enable GPIO PORTB Clock
GPIO_InitTypeDef GPIO_InitStruct;

//Configure PC13 as output
GPIO_InitStruct.Pin = GPIO_PIN_13;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);

Once we have configured the Pin as output, we need write the code to toggle the LED ON and OFF with some dummy delay. You can use the code as given below:

Now, Compile the code and debug/run the code. You can will see LED Blinking.

  while (1)
  {

	  HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, GPIO_PIN_RESET); //PIN Low
	  delay(60000);delay(60000);delay(60000);delay(60000);delay(60000);

	  HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, GPIO_PIN_SET);  //PIN High
	  delay(60000);delay(60000);delay(60000);delay(60000);delay(60000);

  }

I hope the above tutorial helped you a give a basic about how to start with low cost stm32f4 development board.


You can read my other articles on embedded systems here.

If you need any help in your embedded product development, do let me know. I help embedded engineers and startups build reliable and successful products.

Happy Learning to you!

One comment

  1. I just saw your youtube videos and your blog recently. I like your initiative of promoting ARM MCUs. Can you please guide me on where to obtain the black pill in India. Also what are your views on the st-link V3? Is it any better than st-link v2?

Leave a Reply

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