en.radzio.dxp.pl

We are ready to writing application source code. Let us write in main.c file following lines :

#include "stm32f10x.h"

int main(void)
{
do{
}while(1);
}

 

Save the file and select comman "Build target" from "Project" menu. In the "Build output" window will be written following messages :

Build target 'Target 1'
assembling startup_stm32f10x_md_vl.s...
compiling main.c...
C:\Keil\ARM\INC\ST\STM32F10x\stm32f10x.h(80): error: #35: #error directive: "Please select first the target STM32F10x device used in your application (in stm32f10x.h file)"
Target not created

We must defined, which type of STM32 microcontroller are used. So, go to the procject tree and click right mouse button on "Target1" folder icon, and select "Options for Target..." command from context menu :

uVision

Next, go to "C/C++" tab and write in "Define" edit box "STM32F10X_MD_VL" string :

uVision

After this try build application again. Still errors occur in Bould output window :

Build target 'Target 1'
assembling startup_stm32f10x_md_vl.s...
compiling main.c...
C:\main.c(7): warning: #1-D: last line of file ends without a newline
linking...
a.axf: Error: L6218E: Undefined symbol SystemInit (referred from startup_stm32f10x_md_vl.o).
Target not created

In this case this is a linker error, that can't find symbol SystemInit. As we see, call for this symbol came from startup file and this is call for SystemInit function. We can go for a few ways : remove call for this function, write this function (may it be an empty function), and use function supplied by STMicro in thier device support for CMSIS library. We took last way, and use stm32f10x_system.c file. We need to download STM32 Std Periph library for STM32F10x devices. In archive with this library are folder "CMSIS", which we need to extract from the archive. We need olny the CMSIS folder. The STM32F10x_StdPeriph_Driver folder can be deleted ;-).

CMSIS

cmsis

cmsis

cmsis

Go to CMSIS\CM3\DeviceSupport\ST\STM32F10x subfolder, copy *.c and *.h files to folder with Your uVision project and add *.c files to the project tree.

cmsis

Now, try to build project. In "Build output window should be written following text :

Build target 'Target 1'
assembling startup_stm32f10x_md_vl.s...
compiling main.c...
compiling system_stm32f10x.c...
linking...
Program Size: Code=808 RO-data=320 RW-data=20 ZI-data=1636
"prj1.axf" - 0 Error(s), 0 Warning(s).

SUCCES! We have first compiled application for STM32!

 

 
(c) Radosław Kwiecień