Getting started with keil uVision : write your first program




In the last tutorial we have seen how to download and install keil uVision. In this tutorial I will explain you how to do the required configuration on a project in keil in order to make it compatible with your microcontroller. After that I will explain how to get started with keil and create your first project in keil in detail.




Introduction to keil uVision

As we have discussed in previous tutorial that keil uVision is an IDE used to build and load codes on TIVA C series microcontroller. In the previous tutorial we learned how to download and install the latest version of keil uVision and now we are at a position to learn how to write our first program in keil which can be loaded on TIVA C series microcontroller. We will do the relevant settings in a simple program to make it compatible with the microcontroller under consideration so that we can burn (load) it on the board. Lets’ get started with keil (installed in previous tutorial).

Getting started with keil uVision 

  • Once you get done with the downloading and installation part of keil it will appear in you search bar. Open the search bar in your computer and type keil and click on keil uVision5 as shown in the figure below.Getting started with keil uVision : write your first program

Figure 1: keil

  • Once you click on this icon keil will start loading to show you the main window. It will take some time to open the page,Getting started with keil uVision : write your first program

Figure 2: Opening




  • After the IDE is loaded completely a getting started window will appear as shown in the figure below,Getting started with keil uVision : write your first program

Figure 3: Getting started

  • This is where all your currently open projects will appear and your main code and all the codes you run will appear in the greyed window. To work on a program or a debugging environment we first have to create a project where will save our main and startup files. If will give you a brief and concise overview of the startup files in the upcoming tutorials, you don’t have to be worried about them at this point of your understandings. Lets’ now move to creating a new project portion. On the main page as shown in the figure above, a bar is shown with file edit and view etc. options in it. From that bar, select Project and then select New uVision Project as shown in the figure below,Getting started with keil uVision : write your first program

Figure 4: Creating new project

  • When you click on the New uVision Project a window will appear as shown in the figure below,Getting started with keil uVision : write your first program

Figure 5: Naming window

  • This window will ask you where you want to save the project, select the designated folder and also name you project according to the working it is going to perform in future. I will use this project in the upcoming tutorial for the purpose of blinking of built in LEDs present n the F port of TIVA board. Hence, I named the project as blink (In accordance with the task it is going to perform). After naming the project click Ok. After saving the name another window asking you to select the device with which you want to integrate this code. This is where we select the name and type of our board. Refer to the figure below,Getting started with keil uVision : write your first program

Figure 6: Selecting device

  • In this window two boards are present one is ARM and the other is Texas Instruments as is obvious from the above figure. TIVA C boards are manufactured by Texas Instruments hence the board we will select at this stage is Texas Instruments. When we extend this block all the downloaded board of Texas Instruments will appear as shown in the figure below,Getting started with keil uVision : write your first program

Figure 7: Texas instrumentals

  • As we know that TIVA c series is the only option available so we extend that too, as shown in the figure below,Getting started with keil uVision : write your first program

Figure 8: TIVA C series

  • At present only two classes of TIVA C series is installed, we can install more according to our need from pack installer as we have discussed in previous tutorials, but at present we need TM4C123x Series because our microcontroller (TM4C123G) lies within this class. Extend TM4C123x Series to select the board of our choice from the series as shown in the figure below,Getting started with keil uVision : write your first program

Figure 9: TM4C123x series

  • The microcontrollers present under this series are shown in the above figure. One thing to be noted down here is that the type of the microcontroller we are using is TM4C123GXL but in this series you couldn’t find any board named like this. The alternative name for this board is TM4C123GH6PM this is same as TM4C123GXL but with a different name only in the IDE. Remember this name of save it somewhere for future use, where we will be creating projects very often. See the figure below for the alternative nameGetting started with keil uVision : write your first program

Figure 10:TM4C123GH6PM

  • After you select the name of the microcontroller simply click ok. The window will then ask you to choose the runtime environment of your choice. As I have mentioned previously that the startup files need to be included in every code so this is portion where we will choose the inclusion of startup files. The window for managing runtime environment is shown in the figure below,Getting started with keil uVision : write your first program

Figure 11: Managing runtime environment

  • This window will select all the files which needs to be included in your programming environment. For example, if you want to include graphics in your program you have to select it from here first. At this point we only needs to include two files one is the core file which is present under the category of CMSIS and the other is startup file which is present under the category of Devices. Click on the plus sign present with the CMSIS category from the option given select CORE and mark the checkbox in front of CORE and do the same with the devices option. Extend the plus sign and mark the checkbox of startup as shown in the figure below,Getting started with keil uVision : write your first program

Figure 12: CORE and Startup

  • We will discuss comprehensively about this startup file in the upcoming tutorials. After selecting the files click on Ok and the project will be created. The created project will appear on the project explorer at the left side of the main page. Right click on target 1 and select Manage Project items as shown in the figure below,Getting started with keil uVision : write your first program

Figure 13: Project items

  • A window that manages the items of the project will appear as shown in the figure below,Getting started with keil uVision : write your first program

Figure 14: Project items window

  • This is where you can rename all the folder and files of your project according to your need i.e. here I will name the target 1 as TM4C123G and Source Group 1 as Src because this is where all the source files of your code will reside as shown in the figure below,Getting started with keil uVision : write your first program

Figure 15: Renaming

  • In the Src folder named previously we will include our main file (.c file) in which we will write our C language code to be executed on the board. On the Src folder click right and select Add new items to Group “Src” as shown in the figure below,Getting started with keil uVision : write your first program

Figure 16: Adding new items

  • Clicking on this adding item block a window will appear asking you to select the extension of your file and to write the name of your file as shown in the figure below. Select the C file (.c) option and in the name bar write the nae with which you want to save the file i.e. I named my file as main.c here. Don’t forget to type the extension of the file (.c in our case) along with the name of the file as shown in the figure belowGetting started with keil uVision : write your first program

Figure 17: Creating .c file

  • After you click add on this window, a main.c file will appear under the folder of Src. When you click on the main.c file it will open in the grey environment as shown in the figure below,Getting started with keil uVision : write your first program

Figure 18: Main.c environment

  • The only thing left in the configuration of the project to make it compatible with TM4C123G board is its flash configuration. As the name represent flash is the configuration of the port from where TIVA board will be connected to your computer. Without the configuration of flash your will not be able to burn you code on the TIVA board. It will give you a flash error. In order to avoid this ambiguity lest configure some of the flash configuration needed to communicate with TIVA board. From the top bar select Flash and then select Configure flash tools as shown in the figure below,Getting started with keil uVision : write your first program

Figure 19: Flash configuration tools

  • This will open a window showing a number of tools related to flash that can be configured according to the type of our microcontroller and our need. Refer to the figure below, for flash configuration tools window,Getting started with keil uVision : write your first program

Figure 20: Options for target

  • You have nothing to change here because most of the default properties of the flash are compatible with TIVA C series boards, On the top bar a number of options are present. From these items select the Debug options as we are concerned with debugging configuration of flash. The debug configuration of the options is shown in the figure below,Getting started with keil uVision : write your first program

Figure 21: Debugging options

  • From this block we only have to change the simulator settings as shown in the figure below. Check the Use block present on the top right corner of the block and from the dropdown select Stellaris ICDI and then click ok. These are all the configurations needed to run a program on TM4C123G board.Getting started with keil uVision : write your first program

Figure 22: Debug configuration

  • Your IDE is now ready to write a code to be built on TIVA board. We will write a code that will blink built in LEDs present on TIVA board in our next tutorial.




Add Comment