Line 37: Line 37:
  
 
So, here we will click ‘Yes’ as we will be coding with C.
 
So, here we will click ‘Yes’ as we will be coding with C.
 +
 +
 +
[[File:Keil 4.png|x480px|center]]
 +
  
 
5. In the ‘Project’ tab if you expand  ‘Target 1 -> Source Group 1’ you will see the ‘startup file’.
 
5. In the ‘Project’ tab if you expand  ‘Target 1 -> Source Group 1’ you will see the ‘startup file’.
Line 45: Line 49:
  
 
Don’t forget to include lpc17xx header file and the function ‘SystemInit()’.
 
Don’t forget to include lpc17xx header file and the function ‘SystemInit()’.
 +
 +
 +
[[File:Keil 5.png|x480px|center]]
 +
  
 
6. Save the file in the same directory where you created your project with the extension  .c
 
6. Save the file in the same directory where you created your project with the extension  .c
 
You can notice the colour and font changes in the file.
 
You can notice the colour and font changes in the file.
 +
 +
 +
[[File:Keil 6.png|x480px|center]]
 +
  
 
7. Now we need to add this file to the project.
 
7. Now we need to add this file to the project.
  
 
To do this, right click on ‘source Group 1’ and select the option ‘Add files to the Source Group 1’.
 
To do this, right click on ‘source Group 1’ and select the option ‘Add files to the Source Group 1’.
 +
 +
 +
[[File:Keil 7.png|x480px|center]]
 +
  
 
8. Add the .c file, say, LED_Blink.c  
 
8. Add the .c file, say, LED_Blink.c  
Line 60: Line 76:
  
 
No need to copy this file to your project folder. Simply add the file by above procedure.
 
No need to copy this file to your project folder. Simply add the file by above procedure.
 +
 +
 +
[[File:Keil 8.png|x480px|center]]
 +
  
 
9. You can see both files under ‘Source Group 1’.  
 
9. You can see both files under ‘Source Group 1’.  
Line 65: Line 85:
 
Now build the project by clicking ‘Build’ tool on toolbar.
 
Now build the project by clicking ‘Build’ tool on toolbar.
  
10. You can see the errors in ‘Build Output’ tab (down) , if any. Remove the errors and rebuild the project. After successful compilation following window will appear.
+
 
 +
[[File:Keil 9.png|x480px|center]]
 +
 
 +
 
 +
10. You can see the errors in ‘Build Output’ tab (down) , if any. Remove the errors and rebuild the project.  
 +
 
 +
After successful compilation following window will appear.
 +
 
 +
 
 +
[[File:Keil 10.png|x480px|center]]
 +
 
  
 
11. Keil doesn’t create image file until you specify the option.
 
11. Keil doesn’t create image file until you specify the option.
Line 74: Line 104:
  
 
   Under  ‘Target’ tab give crystal frequency in MHz
 
   Under  ‘Target’ tab give crystal frequency in MHz
 +
 +
 +
[[File:Keil 11.png|x480px|center]]
 +
 +
 
   In the ‘Output ’ tab check the option ‘Create Hex File’ and click OK.
 
   In the ‘Output ’ tab check the option ‘Create Hex File’ and click OK.
  
 
Rebuild the project.
 
Rebuild the project.
 +
 +
 +
[[File:Keil 12.png|x480px|center]]
 +
  
 
12. You can see that hex file is created.
 
12. You can see that hex file is created.
  
 
It will be in the your project folder.
 
It will be in the your project folder.
 +
 +
 +
[[File:Keil 13.png|x480px|center]]

Revision as of 16:45, 21 February 2015


Sample Project for LPC1768

Let’s start with a simple LED blinking program.

Launch the Keil application and follow the steps below :


1. Go to the ‘Project’ menu from menu bar, select ‘Close Project’ option if there is already an open project. This option will be available only if there is an open project.

Now select ‘New µVision Project’.


Keil 1.png


2. Select the folder where you want to create the project and give project name.

It’s better to create a new project in a new folder always.


Keil 2.png


3. To select the device as LPC1768 follow NXP -> LPC1768. You can see the device description in the right tab.


Keil 3.png


4. A window will pop up asking whether to add ‘Startup file’ to your project .

The ‘Startup file’ is required only when you want to go with C programming.

So, here we will click ‘Yes’ as we will be coding with C.


Keil 4.png


5. In the ‘Project’ tab if you expand ‘Target 1 -> Source Group 1’ you will see the ‘startup file’.

Click the ‘New’ tool located on toolbar.

A file with name ‘Text1’ will be created in editor. Write your code here.

Don’t forget to include lpc17xx header file and the function ‘SystemInit()’.


Keil 5.png


6. Save the file in the same directory where you created your project with the extension .c You can notice the colour and font changes in the file.


Keil 6.png


7. Now we need to add this file to the project.

To do this, right click on ‘source Group 1’ and select the option ‘Add files to the Source Group 1’.


Keil 7.png


8. Add the .c file, say, LED_Blink.c

Also you should add system_LPC17xx.c file to your project.

You can find this file at “C:\Keil\ARM\Startup\NXP\LPC17xx”.

No need to copy this file to your project folder. Simply add the file by above procedure.


Keil 8.png


9. You can see both files under ‘Source Group 1’.

Now build the project by clicking ‘Build’ tool on toolbar.


Keil 9.png


10. You can see the errors in ‘Build Output’ tab (down) , if any. Remove the errors and rebuild the project.

After successful compilation following window will appear.


Keil 10.png


11. Keil doesn’t create image file until you specify the option.

For this click ‘Target Option’ on toolbar.

In the window ‘Options for Target’

  Under  ‘Target’ tab give crystal frequency in MHz


Keil 11.png


  In the ‘Output ’ tab check the option ‘Create Hex File’ and click OK.

Rebuild the project.


Keil 12.png


12. You can see that hex file is created.

It will be in the your project folder.


Keil 13.png