In this post I will be discussing how I got the stm32 discovery board working with the Keil IDE. This was my first time using an ARM processor, so I decided to go with a commercial grade IDE since they tend to be easier to use. As I switch over to GCC I will document that process as well.

For starters you need the STM32 discovery board
check it out at mouser
Also you will need the Keil IDE. You can download a free limited to 32kb program space version here

First off you need to create a new project and select the processor in the ST Micro section

It will then ask you if you want to Copy STM32 Start up Code to the Project Folder. Choose yes. I would then recommend you use the Keil STM32_init files. I found them in a example code. It can be found here
Once you have downloaded the files, unzip it. Copy over the following files to the same folder as the project file.
Now add STM32_Init.c to your project. Right click on the Source Group 1 and click add file to group. You can group them however you want, it doesn't change how any thing builds.

Also, to keep things clean we will create a Bin folder. So we make a new directory in the same folder as our project. Next, right click on the Target folder and click options for target.

Then click output and click Select Folder for Objects and go find our bin folder that we created.

Finally, create and add a file (lets call it main.c). In there, add a main function that will call the Init code and include the init file. You might also want to include the STM32 lib file.

#include <stm32f10x_lib.h>
#include "STM32_Init.h"

int main (void)

return 0;
Now we need to set up our debugging environment for the STM32 Discovery.  First we need to choose our debugger.  So right click on the project and click options for target and head to the debug tab.  Next, you don't want to be running a simulator so we will click the Use: radio button to the right half.  in the drop down we will choose the ST-Link Debugger.  Then you need to click setting and choose SWD.  finally I like to have run to main() check so that is stops at the main before running.

Next we need to define the flashing tool to upload your program to the STM32.  So head over to the Utilities tab and select the "Use Target Driver for Flash programming" radio button.  Then you can choose the ST-Link Debugger from the drop down.

Now you are all ready to debug.  In my next entry I will be making code to echo a terminal with The STM32 USART.

You can download the project form my Code Project article

No comments:

Post a Comment