LPC1768: Keil Project For Bin File
Contents
[hide]Objective
In this tutorial we will see how to setup a keil project to generate .hex file for LPC1768
Keil Setup Steps
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> | |
void delay_ms(unsigned int ms) | |
{ | |
unsigned int i,j; | |
for(i=0;i<ms;i++) | |
for(j=0;j<20000;j++); | |
} | |
/* start the main program */ | |
int main() | |
{ | |
SystemInit(); //Clock and PLL configuration | |
LPC_PINCON->PINSEL4 = 0x000000; //Configure the PORT2 Pins as GPIO; | |
LPC_GPIO2->FIODIR = 0xffffffff; //Configure the PORT2 pins as OUTPUT; | |
while(1) | |
{ | |
LPC_GPIO2->FIOSET = 0xffffffff; // Make all the Port pins as high | |
delay_ms(100); | |
LPC_GPIO2->FIOCLR = 0xffffffff; // Make all the Port pins as low | |
delay_ms(100); | |
} | |
} |
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 no errors. The .hex file is still not generated.
Setup Bin File Generation
Step13: Click on Target Options to select the option for generating .bin file.
Step14: Set IROM1 start address as 0x2000. Bootloader will be stored from 0x0000-0x2000 so application starts from 0x2000
Step15: Write the command to generate the .bin file from .axf file
Step16: Now enable the linker option to use the IROM1 address from target settings
Step17: .Bin file is generated after a rebuild.
Step18: Check the project folder for the generated .Bin<ER_ROM1> file.
Uploading the Hex file
After generating the .hex file check the tutoial LPC1768 Tutorials for uploading the .hex file using flash magic.
Downloads
Download the complete project folder from the below link:
https://codeload.github.com/ExploreEmbedded/Explore-Cortex-M3-LPC1768-Stick-DVB-14001/zip/master
Have a opinion, suggestion , question or feedback about the article let it out here!

LPC1768: Led Blinking
This is first example on LPC1768 where we start with blinking the LEDs. In this tutorial, we are going to discuss how to configure the LPC1768 ports as GPIO and then send a low/high signal...

LPC1768: Switch and LED
This is second tutorial on LPC1768 where we are going to read the switches and turn ON/OFF the LEDs accordingly. LPC1768 has its GPIOs divided into five ports PORT0 - PORT4, although many of them...

LPC1768: Lcd 4bit
In this tutorial we are going to see how to interface a 2x16 LCD with LPC1768 in 4-bit mode. As per the name the 2x16 has 2 lines with 16 chars on each lines. It supports all the ascii chars and is...

LPC1768: Lcd 8bit
In this tutorial we are going to see how to interface a 2x16 LCD with LPC1768 in 8-bit mode. As per the name the 2x16 has 2 lines with 16 chars on each lines. It supports all the ascii chars and is...