Introduction: External Led Blink Using STM32F401CE

Tody we are using STM32F401CE to Blink an LED , using STM32cubeIDE and HAL programming.

Supplies

The Material required For this project is:

  • STM32F401CE
  • C-type Cable
  • F-F Jumper Wires
  • LED 3v

Step 1: Creating New File in STM32cubeIDE

Open STM32cubeIDE>> file>> New>> STM32 project

Step 2: Select Board and Name of Project

After opening new project select the board STM32F401CE

and After Selecting board name your project.

Step 3: Pinout Configration

In pinout configration, choose pin PC14 by Clicking it, select its mode as GPIO_OUTPUT.

Step 4: Clock Configration

In system Core >> RCC >> high speed clock(HSE)>>Crystal/ceramic resonator.

In clock configration set clock as shown in figure.

Step 5: Opening Code File

After setting Pinout and configuring clock, save your project by pressing CTRL+S,

New coding file will open.

Step 6: Programming for Blinking of LED

In while loop write code provided,

Here is the Explanation of code:

  1. HAL_GPIO_WritePin(GPIOC,GPIO_PIN_14,1); - This line sets the state of the pin 14 (which is connected to the LED) on GPIO port C to HIGH (1). When the pin is set to HIGH, it provides voltage to the LED, causing it to light up.
  2. HAL_Delay(1000); - This line causes the program to wait for 1000 milliseconds, or 1 second. During this time, the LED remains lit.
  3. HAL_GPIO_WritePin(GPIOC,GPIO_PIN_14,0); - This line sets the state of the pin 14 on GPIO port C to LOW (0). When the pin is set to LOW, it cuts off the voltage to the LED, causing it to turn off.
  4. HAL_Delay(1000); - This line causes the program to wait for another 1000 milliseconds, or 1 second. During this time, the LED remains off.


Step 7: Debuging

After writing code, Debug using Hammer option as shown in figure and your coding file is saved as name given in console.

Step 8: Connecting STM32F401CE

Open STM32cubeProgrammer change ST-LINK to USB and click Connect, while our stm32 board is connected with Your PC by USB

Step 9: Uploding Code

Goto Erasing and Programming option>>browse your file path.

choose option as shown in the picture. Click Start automatic mode.

Step 10: Finish

Your Led will Start blinking .






Follow for more content