Blinking an External LED Using STM32CubeIDE on STM32 Black Pill
by tanushree4587be23 in Circuits > Microcontrollers
260 Views, 1 Favorites, 0 Comments
Blinking an External LED Using STM32CubeIDE on STM32 Black Pill
This is an instructable for using STM32 Black Pill which uses STM32F401CCU6 micro-controller for controlling an external LED using ST's native IDE, STM32CubeIDE. LED blinking is often the basic of embedded systems development. It serves as a fundamental exercise for beginners to understand the basics of microcontroller programming. In this blog post, we'll delve into the process of LED blinking on the STM32 BlackPill development board using CubeIDE, a powerful Integrated Development Environment (IDE) provided by STMicroelectronics. The STM32 BlackPill is a popular development board featuring an STM32 microcontroller from STMicroelectronics. It offers an affordable and versatile platform for embedded systems development, equipped with various peripherals and GPIO pins for interfacing with external components. Getting Started with CubeIDE. CubeIDE is an Eclipse-based IDE developed by STMicroelectronics specifically for STM32 microcontrollers. It provides a comprehensive set of tools for code development, debugging, and project management. To get started, download and install CubeIDE from the official STMicroelectronics website. Once installed, launch CubeIDE and create a new STM32 project targeting the STM32 microcontroller on the BlackPill board.
Supplies
Hardware:
- STM32 Black Pill board
- Jumper wires
- LED
- USB-C
- Breadboard (optional)
Software:
- STM32CubeIDE
- STM32CubeProgrammer
Create Project on STM32CubeIDE
- Create new project on STM32CubeIDE by following the steps on the attachment.
- Select the appropriate name for the task and press "Finish."
Select Appropriate Board
- Select the appropriate MCU from the MCU selector, you can also use the search menu like I did.
- STM32 Black Pill uses either STM32F401CC or STM32F401CE micro-controller. Check the chip on your board to find out.
Select Pinout and Configure Clock
- Check any GPIO pin in the pinout view. Refer the attachment of STM32 Black Pill pinout.
- I have chosen Port B, pin number 10 [PB10].
- I used the default clock for this task.
- Press Ctrl + S or Alt + K to generate code.
Write Code
- Open "main.c" file.
- Go to line 95, in "while(1)" write the code to send a HIGH [digital 1] output, then add a delay and send a LOW [digital 0] output to the LED.
- Your code should look something like in the attachment.
- You can also use toggle function.
- Finally, press the debug button from the menu bar or use F11 shortcut key.
Interfacing of External LED
- As I chose PB10 for GPIO, I'll connect the positive terminal of the LED to it.
- And connect negative terminal of the LED to GND. You can check the pinout of ground from attachment shown above.
Setup STM32CubeProgrammer
- Choose USB as the connection method.
- Enter boot-loader mode by the steps in the attachment. Refresh until it shows up and press "Connect."
Your STM32 board should show up in the device manager under Universal Serial Bus devices if done correctly.
- Press on "Open file" and choose the .elf file from STM32 project directory.
- Press download.
- Go to the download icon from the menu in the left and press browse. Again select the .elf file.
- Once done, check the options as shown in the attachment.
- Finally, press on "Start automatic mode."
- Once a message saying "Please disconnect device n:1 and connect the next..." shows up reconnect your STM32 board.