LED PATTERN Making Using STM32F401CE
by devraj4520 in Circuits > Electronics
90 Views, 0 Favorites, 0 Comments
LED PATTERN Making Using STM32F401CE
Today We are going to create a 3-led blinking pattern using stm32f401ce with HAL programming in STM32cubeIDE.
Supplies
Material Required:
- STM32F401CE
- USB-C-TYPE CABLE
- LED
- BREADBOARD
- M-M JUMPER
Create New File
To open new file :
File>>new>>STM32 Project.
After opening file, Choose your Board ,we are using STM32F401CE Board.
NEXT>> name your file.
PIN Configuration & Clock Configuration
Goto to System core>> GPIO>> Choose PC13, PC14, PC15 to GPIO_OUTPUT.
For Clock Configration:
System Core >> RCC >> HCS>> Crystal/ceramic Clock.
And refer To provided image for setting clock.
CODING
After configuring STM32 save yor file by CTRL+S,
and coding file will open. Write code as given in text file or write code as you want to make pattern of LED's.
Code explanation:
it’s controlling the state of three pins (13, 14, 15) on port C. The HAL_GPIO_WritePin function is used to set the state of a specific pin to either HIGH (1) or LOW (0). The HAL_Delay function is used to introduce a delay, in this case, 400 milliseconds.
The code is cycling through different combinations of states for the three pins, with a delay after each change. This could be used, for example, to control LEDs connected to these pins, making them blink in a specific pattern. The pattern here is a binary count from 0 (all pins LOW) to 7 (all pins HIGH), with each step lasting 400 milliseconds.
Downloads
DEBUG
After writing code Debug by clicking Hammer icon , Deguged file is created with Your project name and with .elf extension
Uploding Code
Open STM32cubeProgrammer and connect your STM board (For detail refer to previous Blogs) ,
Open erasing and Programming option and enter your saved file path or browse it.
select option as shown in picture, Now click start automatic mode.
YOUR LED BLINKING PATTERN IS CREATED. :)