STM - 32 Bare Metal Programing - Inroduction -1 (LED - Blinking)

        In this blog post, we're embarking on an exciting journey as we dive headfirst into the world of bare metal programming. In the upcoming tutorial, we'll be taking a unique approach. Unlike many tutorials that rely on drivers or libraries, including HAL drivers, we're going to build everything from the ground up. By doing so, we'll gain a deeper insight into the architecture of the MCU. This hands-on experience will allow us to comprehend every intricate detail, from the individual moving parts to the overall workflow.

        Our canvas for this creative endeavor is none other than the renowned "Blue Pill Board," featuring the STM32 F103C8/STM32F103C6 microcontroller. If you're new to this fascinating realm, fret not; To begin, fire up your STM32 CUBE-IDE. As you launch the IDE, you'll be prompted to select a workspace. Be sure to designate a suitable folder where we can save and nurture our coding masterpiece. 

To create a new project select File->New->STM32 Project.


       you'll notice a window that looks exactly like the one shown below. Within this window, locate the "Part Number" dialog box and enter your specific part number. As you do this, the system will automatically filter and display your MCU. Once you spot your MCU in the list, simply select it and click "Next" to proceed with your project setup.



        A new window will appear, prompting you to assign a name to your project. For our demonstration, I've chosen the name "1_BM_LED_Blink," where "BM" signifies "Bare Metal." Next, in the "Targeted Project Type" option, opt for "empty." We're making this choice because we're committed to crafting every aspect of our project from the ground up, right down to address mapping and beyond. And then click finish. 

 



       Upon completing these steps, your project will be generated, as illustrated in the image below. Now, let's dive into the coding process. Start by expanding the "source (src)" folder within the Project Explorer window. Inside, locate the "main.c" file. Upon opening it, you'll find a template program already in place. However, since we won't be needing it, feel free to delete everything within the file. After doing so, your code will resemble what's depicted in the image below.



        
        As evident in the image above, the Blue Pill board boasts an array of pins and ports. Specifically, it is equipped with three distinct ports: Port A, Port B, and Port C. In the scope of this tutorial, we will narrow our focus to the task of LED blinking. Taking a closer look at the pinout image above, you'll notice that the LED is connected to PC13, signifying Port C, pin number 13.

         Before we dive deeper into the project, there are two essential documents you need to download. These documents will serve as invaluable resources throughout our journey. Make sure to obtain the STM32F103Cx Datasheet and Reference Manual, as they contain crucial information for everything we are about to explore. 

        In our upcoming tutorial, our focus will shift towards understanding how to interact with Port C. As we've identified, the LED is linked to Port C, specifically on pin 13. In our next lesson, we'll delve into the methods and techniques required to access Port C and configure it to control the LED.

        That concludes today's tutorial. If you have any questions or need further clarification, please don't hesitate to leave your queries in the comments section below. I'll be more than happy to assist you. Wishing you a wonderful day ahead!                

 

        

  





Comments