External Led Blink Using STM32F401CE

by devraj4520 in Circuits > Electronics

45 Views, 0 Favorites, 0 Comments

External Led Blink Using STM32F401CE

WhatsApp Image 2024-04-09 at 17.54.02_39c684cb.jpg

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

Supplies

F F wire.jpeg
STM32F401CE.jpeg
usb-c-type-cable.jpg
Screenshot 2024-04-09 180806.png

The Material required For this project is:

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

Creating New File in STM32cubeIDE

Screenshot 2024-03-17 101441.png

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

Select Board and Name of Project

Screenshot 2024-03-17 101613.png
Screenshot 2024-03-17 101646.png

After opening new project select the board STM32F401CE

and After Selecting board name your project.

Pinout Configration

Screenshot 2024-04-09 182225.png
Screenshot 2024-04-09 182240.png

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

Clock Configration

Screenshot 2024-04-09 183253.png
Screenshot 2024-04-09 182319.png

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

In clock configration set clock as shown in figure.

Opening Code File

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

New coding file will open.

Programming for Blinking of LED

Screenshot 2024-04-09 182707.png

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.


Downloads

Debuging

Screenshot 2024-03-17 110848.png
Screenshot 2024-04-09 185009.png

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

Connecting STM32F401CE

Screenshot 2024-03-15 112822.png

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

Uploding Code

Screenshot 2024-03-15 112755.png
Screenshot 2024-03-15 112810.png

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

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

Finish

FWX50YFLUQYR1H4.jpg

Your Led will Start blinking .






Follow for more content