stm32cubemx - realmoriss/stm32_smart GitHub Wiki
Creating a project with STM32CubeMX for the STM32_Smart board
1. Creating a new project
Create a new project by choosing the STM32F103C8 microcontroller from the list.
2. Configuring the board
2.1. Basic settings
First we have to configure the project options. Select the Project->Settings...
options from the menu bar. The settings dialog will appear. Choose a name for the project (stm32_smart_default
in our example) and choose a location for the project. Set the Toolchain/IDE
option to SW4STM32
which will allow the tool to generate the correct project files.
2.2. External clock sources
The next step is to enable external (high and low speed) clock sources. To do open the RCC option from the list on the left and choose Crystal/Ceramic Resonator
from both dropdown list.
2.3. Changing the processor frequency
After we enabled these external clock sources we can increase the processor's frequency. Change to the Clock Configuration tab and type the desired frequency (72 MHz maximum) in the HCLK input field and press enter. A question will appear asking to reconfigure the clock sources, which it will automatically do for us if we click on the OK button.
2.4. Enabling the on-board LED
We can enable the on-board LED which is connected to the PC13
pin by changing it to GPIO_Output
. To do this switch back to the Pinout tab and click on the PC13-TAMPER-RTC
pin (which is physical pin 2) and choose GPIO_Output
from the dropdown list.
After the pin is enabled, we need to configure it to be pulled up by default (the LED will be off when the pin is pulled high). Switch to the Configuration tab and click on the GPIO button.
A popup will appear where we can configure the GPIO pins. Select the PC13 pin from the list and change the GPIO output level
option to High
and the Maximum output speed
option to High
. We can assign a label to the pin which in our case will be called out_led
.
2.5. Enabling FreeRTOS (recommended, but optional)
If you would like to use FreeRTOS in your project you can enable it on the Pinout tab. Select the FREERTOS option from the left and check the Enabled checkmark.
The next step is to set the HAL timebase source to use one of the internal timers. Open the SYS
option on the left. Change the Timebase source
option to TIM1
.
3. Generating the source code
To generate the source code and the project files select the Project->Generate code
option from the menu bar. A message will appear if the code generation was successfull. We can click on the Open Project
button which will open the project inside the SW4STM32 IDE.