External Led Blink Using STM32F401CE
by devraj4520 in Circuits > Electronics
55 Views, 0 Favorites, 0 Comments
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
Creating New File in STM32cubeIDE
Open STM32cubeIDE>> file>> New>> STM32 project
Select Board and Name of Project
After opening new project select the board STM32F401CE
and After Selecting board name your project.
Pinout Configration
In pinout configration, choose pin PC14 by Clicking it, select its mode as GPIO_OUTPUT.
Clock Configration
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
In while loop write code provided,
Here is the Explanation of code:
- 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.
- HAL_Delay(1000); - This line causes the program to wait for 1000 milliseconds, or 1 second. During this time, the LED remains lit.
- 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.
- 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
After writing code, Debug using Hammer option as shown in figure and your coding file is saved as name given in console.
Connecting STM32F401CE
Open STM32cubeProgrammer change ST-LINK to USB and click Connect, while our stm32 board is connected with Your PC by USB
Uploding Code
Goto Erasing and Programming option>>browse your file path.
choose option as shown in the picture. Click Start automatic mode.
Finish
Your Led will Start blinking .
Follow for more content