Merhaba STM32

First open the CubeMX:

image-20201009155948276

Then click sstart my project from MCU:

image-20201009160028043

Choose the corresponding model from the list or frome the saved list (favorite):

Then setup the peripherals:

image-20201009160130149

Setup system through serial wire.

then setup the crystal high speed clock :

image-20201009160218424

image-20201009160238019

Configure clock to 72Mhz or other value.

image-20201009160318472

image-20201009160336003

Setup USUART1 and enable global interrupt.

image-20201009160416370

Setup BLUE LED on pin 15.

Give the project name, tool chain select STM32 Cube IDE.

image-20201009160508539

Then Generate Code.

Open the project using CLION.

image-20201009160605541

Click copy to project and use.

image-20201009160627652

For ST-Link V2-A Version we need to change the .cfg file like this :

# This is an STM32F4 discovery board with a single STM32F407VGT6 chip.
# http://www.st.com/internet/evalboard/product/252419.jsp

;source [find interface/stlink-v2.cfg]
source [find interface/stlink-v2-1.cfg]

transport select hla_swd

# increase working area to 64KB
set WORKAREASIZE 0x10000

source [find target/stm32f4x.cfg]

reset_config srst_only

image-20201009160745427

Build Programm successful.

image-20201009160808734

Upload the program.

This may not successful the first time, if so, we need to press the reset button on the stm32 and press the run button on the clion at the same time.

Code :

HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, 1);
HAL_Delay(1000);
HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, 0);
HAL_Delay(1000);

Result ;

ezgif.com-gif-maker

Blinky Again with some new

image-20201018090706830

/* USER CODE BEGIN WHILE */
while (1) {
    HAL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin);
    HAL_Delay(1000);
    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */