After decided to go with stm32, i started to took initial tutorials on how to get started with stm32. I found much information on getting started but non of it is well organized. So i decided to make series of tutorials on getting started with stm32 microcontrollers. In this whole series i will discuss all the protocols/functions stm32 microcontrolles offered. I will present a working example of easy protocol/interface/function with source code and circuit diagram.
Their are many IDE’s(Integrated development environments) that supports stm32 series and you can use any one of them to program your stm32 microcontroller. Some Ide’s are Coocox, keil, mBed, Attolic, microC for Arm. I decide to go with keil and stm32CubeMx. Keil gives you in depth knowledge of the microcontroller and its interface. If you don’t want to go in depths and want a piece of cake then go with MikroElectronica microC for Arm. Its very easy to work with microC ide, it has plenty of example and libraries you only need to call the functions and its all done. Stm32CubeMx is a microcontroller peripheral configurater. By using stm32cube you don’t need to write configuration code for your stm32 microcontroller. Its a visual platform where you can make the microcontroller pins input, output, enable pull-ups and pull-down can define the operating frequency of microcontroller visually and lot more. After the visual configuration you can generate code for the configuration you made. I prefer to work with stmCube because it is provided by officially STMicroelectronics and its good to work with the stuff provided by the owner.
Note: Stm32CubeMx is not an Ide its a configuration manager. You make your stm32 microcontroller configuration in it and then generate code for the configuration you done to be used with any other ide. You can directly generate the keil ide project with stmCubeMx by slecting the option from stmCubeMx to translate the configuration in to keil ide project.
Installing StmCubeMx and Keil MDK ARM
Installing the StmCubeMx is also straight froward. Download the StmCube from the link http://www.st.com/en/development-tools/stm32cubemx.html. You might be popped up to sign in. Sign in and you are their. Once StmCubeMx is installed you now have to install the packages for each stm32 series or for series that you want to work with. StmCubeMx and the stm32 series packages are two different things. Package for each stm32 series must be installed separately. Their is also an option in StmCubeMx software that installs the series packages. Its under the Help> Install New Libraries. Since we are getting started with stm32f103 so wee need to install the package for stm32f1 series. The diagram below explains well about the packages installation.
Blink led with stm32f103 keil and stmcubemx
- Input mode
- Analog mode
- Output mode
- Alternate function mode
- External interrupt/event lines
For our purpose we are going to use port-c pin#13 as output. Almost all the stm32 pins have internal pull up and pull down resistors. Since we are not using the gpio in input mode, so we are not using pull up and down resistors. Stm32 pins can work at different frequencies, we are going to operate the pin at low frequency. Stm32 pins can also be initialized as low or high after booting. I made pin#13 low.
Note: I am going to use the internal 8Mhz RC oscillator of the microcontroller. The upper board has an external 8Mhz crystal but i am not going to use it. In later tutorials we will use it.
Creating new project in StmCubeMx