Software Keil uVisio on IDE • uVision ID (Integrated Develop DE pment Envirronment) allows develoopers to crea ate embedde applicatio ed ons using the Keil development toools. • It integra ates a projec manager (to create a ct and maintain projects), make utilit , ty (for assemmbling, com mpiling, and linking emb bedded applications), s source code editor, de ebugger and simulator into one env d vironment. Flash Mag gic • programming A tool for p g flash based microcontrolllers Keil uVision IDE
Keil Softw ware Develop pment Cycle The project developme ent cycle is similar to any o other softwar re developme ent project. 1. Create a project, select the target device from m the Device D Database, and d configure th he tools settings n C 2. Create source files in pplication wit3. Build ap th Project Ma anager 4. Debug and correct e errors in sourc ce files, verify y and optimiz ze application n 5. Downlo oad code to Flash ROM or SRAM and te est the linked application es Procedure 1. Create Directo ory Create a worki ing directory, , such as C:SITE Program UV Project, t to save all you ur work. Th his directory will include the following f files: *.uvpr roj – the main to manage alll files associated with curr n project file t rent project *.c – C C code; an inp put to the uVision IDE prog gram *.hex – – contains ma achine code; an output fro om uVision ID DE program th hat is downlo oaded to the microprocessor board 2. Create New Prroject 1. Launch Keil uVision IDE by clicking on the icon on n your desktop or by select ting it from th he Start Menuu.
2. To create a new project file, click on Project from the menu bar and select New uVision Project. Under the Create New Project window, give your project a name and save it in the folder you created. 3. Select the device type by expanding NXP (founded by Philips) and choosing LPC2148. Notice that the description section lays out the details of the LPC2148 microcontroller, including the on‐chip peripherals and memory options. Click OK. (This step is very important since uVision customizes the tool settings, peripherals, and dialogs for that particular device.)
**You may invoke this screen through the menu Project ‐> Select Device for Target … Menu in order to change the device type. 4. A dialog box will appear asking if you want to include a startup code for this device. Click YES. (All embedded programs require some kind of microcontroller initialization or startup code. The startup code specifies the starting configuration of your hardware. All Keil tools include chip‐specific startup code for most of the devices listed in the Device Database.) 5. Once you have created a new project successfully, the Project Window shows the targets, groups, and files of your project. By default, the target name is set to Target 1, while the group’s name is Source Group 1.
3. Create Source Files Source files are … 1. To create a new source code, use the button on the File Toolbar or click on File in the menu bar and select New. This action opens an empty Editor Window to enter your source code. 2. Type in your C language code. (Note: See C Programming) 3. Save the new source file using the button on the File Toolbar or click on File in the menu bar and select Save. 4. Add Source Files 1. In the Project Window (on the left), expand the Target 1 folder. Right click on the Source Group 1 folder, then choose Add Files to Group ‘Source Group 1’ … .
2. Select the source file (.c file) you just created and saved. Click Add and then Close.
5. Compiling The compiler allows you to write in the C language and compile code to run on the LPC2148 microcontroller. 1. First, you need to set the option to create a HEX file by clicking on Project from the menu bar and selecting Options for Target ‘Target 1’… . 2. On the Output Tab, check the option to Create HEX File. Click OK.
3. Click on Project from the menu bar and select Build Target or Rebuild all target files. A Build Output window will show the source code getting compiled into a HEX file. 4. In the Build Output Window, a message of 0 Errors and 0 warnings signifies that your program compiled successfully. (Warnings do not prevent the program from running correctly. However, you should consider solving them to eliminate unwanted effects).
6. Downloading Program to Microcontroller We need to download the machine code (HEX file) into the physical memory locations of the microcontroller. Setting Options 1. Select Flash from the menu bar and click on Configure Flash Tools… . On the Utilities tab, choose Use External Tool for Flash Programming. In the command line, select FlashMagic.exe.
2. In the Arguments line, modify the COM port number so that it corresponds to the port number assigned by the Windows Device Manager. To find the COM port number, follow these steps: 1. Click on Start in the lower left corner of your PC screen. Then, click on Control Panel. 2. Go to Hardware and Sound. Under Devices and Printers, select Device Manager. A dialog box will pop up. Click OK. 3. In the Device Manager Window, expand Ports (COM & LPT) to see the port number of the USB connection that is connected from the microcontroller to the PC.
4. On the Target tab, check Use MicroLIB. Downloading Program The program will be downloaded to the micontroller using FlashMagic. FlashMagic is a utility to download the HEX file to the LPC2148 processor.
1. Click on Flash from the menu bar and select Download. Wait till the downloading process is finished. 2. In FlashMagic, select LPC2148 as the device, the correct COM port number, Baud Rate of 9600, None (ISP) for Interface and 12MHz for Oscillator. Then, check Erase blocks used by Hex File.
3. Select the HEX file that was just created by clicking Browse. Then, click Start. 4. The program will be downloaded to the on‐chip FLASH memory when Finished is displayed in the status box at the bottom of the window.