Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Le1 2

Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

KEIL IDE ABSTRACT

This is an introduction to the KEIL development tool


for STM32F407. This document is brief tutorial of

DEVELOPMENT how to use KEIL and has some simple example


programs

TOOL FOR
STM32
Introduction
Keil IDE Development Tool for STM32

How to use Kiel IDE for STM 32 ?

1. Go the /Keil/uv3 folder and click on Keil IDE opens automatically.


2. Open a new Project by selecting New Project from the Project Menu

Figure 1: New Project Window

3. Give your project a name for example demo2 and press Save. (We suggest that you use a
separate folder for each project. You can simply use the icon Create New Folder in this dialog
to get a new empty folder. Then select this folder and enter the name for the new project.)
Kiel IDE will then display the following window as shown in Figure 2
Figure 2: Window to select CPU

4. When you create a new project µVision asks you to select a CPU for your project. The Select
Device dialog box shows the µVision device database. Select STM#2F407iGHx and press OK. This
selection sets necessary tool options for the device and simplifies in this way the tool
configuration.
Keil will then ask you

Figure 3: Keil Hardware Tools


5. Press OK.
6. You will now get a Keil Window shown in Figure 4

Figure 4

7. Now you have to set options for tools. Click on on the toolbar. The window shown in
Figure 5 will appear

Figure 5
8. Set the IROM to 0x80000000. You need not change anything else.
9. Go to Linker option. Thee also set the address to 0x8000000 and then select Memory
Layout from Target as shown in Figure 6
Figure 6

10. Go to the ‘Debug’ tab of the tools option window. Select ‘Use Simulator’ option.

Figure 6: Simulator option for Debug


11. Now press ‘OK’ so that all your options are saved.
12. To create a new ALP. Go to ‘File’ Tab and click on ‘New’. A new text file will be created as
shown in Figure 6

Figure 7: New File Editor window


13. Go to ‘File’ tab and use the ‘Save As’ option and save the file as ‘name.s’ You can use any
name for the file the extension will be ‘.s’. Now all the editor options including different
colours for labels, variables, etc.. will be available.Figure 7 shows an example program that
executes x = (a+b)-c

Figure 8: An example program


14. To add a file to the source group right click on Source Group the options shown in Figure 9
will appear

Figure 10: Add Files

Figure 9: Addition of File to Source Group


15. Go to options ‘Add Files to Group ‘Source Group1’. A pop-up window will appear select your
assembly file ‘Name.asm’ and click on the ‘Add’ button. To close the pop-up window click on
the ‘Close’ Button. Now if you examine the left side of your Kiel Window you will find that
your file has been added to ‘Source Group1’ as shown in Figure 10

Figure 10: File added to Source Group


16. Now to assemble your file click on . Your file will be assembled and if there is any error
it will be indicated in the output window at the bottom of your screen. Refer to Figure 11. The
error along with line number in which the error has occurred (in this case ‘7’) will be indicated.

Figure 11: Error Indicated in output Window.

17. The debugger can then be started by clicking on . The debugger supports both single
step and break points. There are a number of debugging windows.⇒ Code – Memory – CPU
Registers – Symbols. This is shown in Figure12

Figure 12: Debug Window


Buttons on the Debug window:

→ Takes the control back to the editor window.

→ Resets the system resources [CPU, Internal sub-units of the micro-controller


variables, and the development board]

→ Is used for single-stepping step over

→ Is used to step over procedures such as delays etc.

→ Is used for complete execution of the program

→ Is used for halting the execution of the program.

There are other buttons available as well, as you move the cursor over the buttons, the
purpose of each button will be displayed.
The debugger is user-friendly GUI and is easy to handle. To set a breakpoint in the program,
the cursor just needs to be moved to the instruction at which the breakpoint is to be set and click on
to set the breakpoint.

Figure 13: Setting Break Points

Indicates where the instruction to which the Program Counter is pointing to.

Indicates the instruction at which there is a breakpoint.


To clear the breakpoint all you have to do is move the cursor to the instruction at which the breakpoint
is set and click on .

The Register Window


The Register window shows the contents of all the registers of 8051 CPU. It shows the content
of the 8051 registers at run time. The contents of the registers can be changed by going to the register
and then clicking on its value.

Figure 14: Register Window


Note:
• Labels are not followed by “:”
• Assembler directives such as AREA, END, ENTRY etc. should not be written in the first column
• Directive AREA – is used to define a memory area
• Format is AREA NAME, TYPE (CODE/DATA), Characteristic (READONLY/READWRITE) - usual
directive ORG is not used here
• START – defines start of execution
• STOP – end of main execution area
• END – end of assembly
• Source data usually specified in ROM or you have to write source data into RAM area every
time you run the program
• Destination data usually defined in RAM – as you need Read/ Write Capacity
• DCD – Define Constant double word – equivalent to DD Directive
• ROM starts at 0X80000000 (00 00 00 00H)
• RAM starts at 0X20000000 (40 00 00 00H)

You might also like