In this tutorial, I will explain how to make a new project for STM32F103C8 using Keil uVision IDE. STM32F103C8 is a 32-bit microcontroller produced by ST Microelectronincs Company. It use ARM Cortex-M3 CPU Core. The clock speed is up to 72MHz. It has 64Kbytes of flash memory and 20Kbytes of SRAM.
The development board for this microcontroller is quite small. It came with DIP 40 pin that fits on breadboard. It has 2 × 12-bit ADCs, 7 × timers, Up to 9 communication interface (3 × USART, 2 × I2C, 2 × SPI, 1 × CAN, 1 × USB), External Interupt, DMA.
To flash this microcontroller, you need downloader. I am using ST-LINK V2 downloader for flashing this microcontroller.
To start a new project in Keil uVision, you need the Software Packs (libraries) for this microcontroller. You can download the Software Packs for this microcontroller from Keil official website. You can install this by clicking Pack Installer icon on toolbar.
On the Pack Installer dialog you can select menu File → Import, and then select the Software Pack file.
Select menu Project → New uVision Project, give name for that project, and then this dialog will be show:
In this dialog, choose the STM32F103 microcontroller from Software Packs. After click OK button, then this dialog will be show:
In this dialog, you can select which peripheral library you want to use. After that, click the Resolve button.
From the project window, you can rename the Target 1 and Source Group 1 folder to STM32F103C8 and Source respectively. Right click on Source 1 folder then click Add New Item to Group menu. Select the .c file and give name for that file (for example main.c). This is the window for main.c file. You can write your code here.
After finish write your code, you can build the project by click Build icon from toolbar or press F7 key. Your Built Output should contain zero error.
The next step is to upload your code to the microcontroller. To do that, you need to configure the downloader settings by click Options for Target icon. On the Debug tab, select ST-Link Debugger and click Settings button. Set the properties on Cortex-M Target Driver Setup dialog like this:
After the settings for downloader has been configures properly, you can start flash the microcontroller, by press Download icon from toolbar. You can also debug the program from menu Debug → Start/Stop Debug Session.
For STM32 tutorial with HAL library, you can click here.
Excellent Startup guide. when I found it, I felt I had a Gem right in my hand! by the way,
ReplyDeletein the last image, "Cortex-M Target Driver Setup, Flash Download tab" in bottom of a screen it's better to Set the size of Default STM model to 0x00010000 instead of 0x00020000. the default one is for 128KBs STM model. STM32F103C8T6 is 64 KBytes. it doesn't matter if our program is under 64K though !
Thanx for blog :) keep it up
Thank you! Great tutorial and comment!
ReplyDeleteone more thing: as far as I now, we have to set the Xtal to 8.0 instead of 12.0MHz (Options for Target 'STM32F103C8' -> Target -> Xtal (MHz) )
ReplyDeleteThank you for tthis
ReplyDelete