Difference between revisions of "LPC1768: Keil Project For Hex File"
Line 1: | Line 1: | ||
=Objective= | =Objective= | ||
In this tutorial we will see how to setup a keil project to generate .hex file for LPC1768<br><br> | In this tutorial we will see how to setup a keil project to generate .hex file for LPC1768<br><br> | ||
− | |||
− | Open the Keil software and select the New Microvision project from Project Menu as shown below.<br> | + | |
+ | [[File:00_Lpc7168_Keil.png]]<br><br> | ||
+ | |||
+ | <b>Step1:</b> Open the Keil software and select the New Microvision project from Project Menu as shown below.<br> | ||
[[File:Lpc1768_Keil_01.png]]<br><br> | [[File:Lpc1768_Keil_01.png]]<br><br> | ||
− | Browse to your project folder and provide the project name and click on save.<br> | + | <b>Step2:</b> Browse to your project folder and provide the project name and click on save.<br> |
[[File:Lpc1768_Keil_02.png]]<br><br> | [[File:Lpc1768_Keil_02.png]]<br><br> | ||
− | Once the project is saved a new pop up “Select Device for Target” opens, Select the controller(NXP:LPC1768) and click on OK.<br> | + | <b>Step3:</b> Once the project is saved a new pop up “Select Device for Target” opens, Select the controller(NXP:LPC1768) and click on OK.<br> |
[[File:Lpc1768_Keil_03.png]]<br><br> | [[File:Lpc1768_Keil_03.png]]<br><br> | ||
− | Select the controller(NXP:LPC1768) and click on OK.<br> | + | <b>Step4:</b> Select the controller(NXP:LPC1768) and click on OK.<br> |
− | [[File:Lpc1768_Keil_04.png]] | + | [[File:Lpc1768_Keil_04.png]]<br><br> |
− | As LPC1768 needs the startup code, click on <b>Yes</b> option to include the <b>LPC17xx Startup</b> file. <br><br> | + | <b>Step5:</b> As LPC1768 needs the startup code, click on <b>Yes</b> option to include the <b>LPC17xx Startup</b> file. <br><br> |
− | [[File:Lpc1768_Keil_05.png]] | + | [[File:Lpc1768_Keil_05.png]]<br><br> |
− | Create a new file to write the program.<br> | + | <b>Step6:</b> Create a new file to write the program.<br> |
− | [[File:Lpc1768_Keil_06.png]] | + | [[File:Lpc1768_Keil_06.png]]<br><br> |
− | Type the code or Copy paste the below code snippet.<br> | + | <b>Step7:</b> Type the code or Copy paste the below code snippet.<br> |
[[File:Lpc1768_Keil_07.png]] | [[File:Lpc1768_Keil_07.png]] | ||
<html> | <html> | ||
Line 28: | Line 30: | ||
</html> | </html> | ||
− | After typing the code save the file as <b>main.c</b>.<br> | + | <b>Step8:</b> After typing the code save the file as <b>main.c</b>.<br> |
− | [[File:Lpc1768_Keil_08.png]] | + | [[File:Lpc1768_Keil_08.png]]<br><br> |
− | + | ||
− | + | ||
− | + | ||
− | Add the | + | <b>Step9:</b> Add the recently saved file to the project<br><br>. |
− | [[File: | + | [[File:Lpc1768_Keil_09.png]]<br><br> |
− | + | <b>Step10:</b> Add the main.c along with system_LPC17xx.c.<br> | |
− | [[File: | + | [[File:Lpc1768_Keil_10.png]]<br><br> |
− | + | <b>Step11:</b> Build the project and fix the compiler errors/warnings if any.<br> | |
− | [[File: | + | [[File:Lpc1768_Keil_11.png]]<br><br> |
− | + | <b>Step12:</b> Code is compiled with nor errors. The <b>.hex</b> file is still not generated.<br> | |
− | [[File: | + | [[File:Lpc1768_Keil_12.png]]<br><br> |
− | + | <b>Step13:</b> Click on <b>Target Options</b> to select the option for generating .hex file.<br> | |
− | [[File: | + | [[File:Lpc1768_Keil_13.png]]<br><br> |
− | + | <b>Step14:</b> Set IROM1 start address as 0x0000.<br> | |
− | [[File: | + | [[File:Lpc1768_Keil_14.png]]<br><br> |
+ | <b>Step15:</b> Enable the option to generate the .hex file<br><br> | ||
+ | [[File:Lpc1768_Keil_15.png]]<br><br> | ||
− | .Hex file is generated after a rebuild. | + | <b>Step16:</b> .Hex file is generated after a rebuild.<br> |
− | [[File:Lpc1768_Keil_16.png]] | + | [[File:Lpc1768_Keil_16.png]]<br><br> |
− | Check the project folder for the generated .hex file.<br> | + | <b>Step17:</b> Check the project folder for the generated .hex file.<br> |
− | [[File:Lpc1768_Keil_17.png]] | + | [[File:Lpc1768_Keil_17.png]]<br> |
− | + | <br><br> |
Revision as of 00:33, 26 March 2016
Objective
In this tutorial we will see how to setup a keil project to generate .hex file for LPC1768
Step1: Open the Keil software and select the New Microvision project from Project Menu as shown below.
Step2: Browse to your project folder and provide the project name and click on save.
Step3: Once the project is saved a new pop up “Select Device for Target” opens, Select the controller(NXP:LPC1768) and click on OK.
Step4: Select the controller(NXP:LPC1768) and click on OK.
Step5: As LPC1768 needs the startup code, click on Yes option to include the LPC17xx Startup file.
Step6: Create a new file to write the program.
Step7: Type the code or Copy paste the below code snippet.
#include "LPC17xx.h" | |
#include "rtc.h" | |
#include "lcd.h" | |
int main() | |
{ | |
rtc_t rtc; | |
SystemInit(); | |
/*Connect RS, RW, EN and data bus to PORT0.4 to PORT0.7*/ | |
LCD_SetUp(P2_0,P2_1,P2_2,P_NC,P_NC,P_NC,P_NC,P1_24,P1_25,P1_26,P1_27); | |
LCD_Init(2,16); | |
RTC_Init(); | |
rtc.hour = 10; // 10:40:20 am | |
rtc.min = 40; | |
rtc.sec = 0; | |
rtc.date = 1; //1st Jan 2016 | |
rtc.month = 1; | |
rtc.year = 16; | |
rtc.weekDay = 5; // Friday: 5th day of week considering monday as first day. | |
/*##### Set the time and Date only once. Once the Time and Date is set, comment these lines | |
and reflash the code. Else the time will be set every time the controller is reset*/ | |
RTC_SetDateTime(&rtc); // 10:40:20 am, 1st Jan 2016 | |
/* Display the Time and Date continuously */ | |
while(1) | |
{ | |
RTC_GetDateTime(&rtc); | |
LCD_GoToLine(0); | |
LCD_Printf("time:%2d:%2d:%2d \nDate:%2d/%2d/%2d",(uint16_t)rtc.hour,(uint16_t)rtc.min,(uint16_t)rtc.sec,(uint16_t)rtc.date,(uint16_t)rtc.month,(uint16_t)rtc.year); | |
} | |
} |
Step8: After typing the code save the file as main.c.
Step9: Add the recently saved file to the project
.
Step10: Add the main.c along with system_LPC17xx.c.
Step11: Build the project and fix the compiler errors/warnings if any.
Step12: Code is compiled with nor errors. The .hex file is still not generated.
Step13: Click on Target Options to select the option for generating .hex file.
Step14: Set IROM1 start address as 0x0000.
Step15: Enable the option to generate the .hex file
Step16: .Hex file is generated after a rebuild.
Step17: Check the project folder for the generated .hex file.