• No results found

Assignment 09. Problem statement : Write a Embedded C program to switch-on/switch-off LED.

N/A
N/A
Protected

Academic year: 2021

Share "Assignment 09. Problem statement : Write a Embedded C program to switch-on/switch-off LED."

Copied!
11
0
0

Loading.... (view fulltext now)

Full text

(1)

Assignment 09

Problem statement : Write a Embedded C program to switch-on/Switch-off LED. Learning Objective:

-> To study embedded programming concepts -> To study LCD control functions

-> How output is provided to different port Description:

Let us assume that LED is connected at pin RD0. RD0 is a pin0 of port D. When RD0 is high LED become ON and when RD0 is low LED become OFF.This program toggle the LED connected at PORT D0. Code: #include<lpc2138.h> void delay(long); int main(void) { IO0DIR=0x007F8000; while(1) { IO0SET =0x00550000; IO0CLR = 0x002A8000; delay(70000); IO0CLR =0x00550000; IO0SET = 0x002A8000; delay(70000); } return 0; } void delay(long i) { while(i--); }

# Steps For Creating A Demo Project in Eclipse

This is the screen you will see in front of you when you double click the Eclipse icon on desktop.

(2)

First of all select the working perspective for providing the compilation environment to your project.

Click on “ window ” >> “Open Perspective” >> C/C++

Step2 : Select the Project Type

Now select the project type whether you want to compile it as a standard make C or managed make C project.

(3)

And select the “Standard Make C Project” in the C drop down option and click next

(4)

Just type the name you want to give to your project but make sure the right path of the workspace being displayed and there is no other project having same name exists in that

particular workspace. Otherwise it will prompt an error message and will not crate the project. If you want to change the workspace, just uncheck the “Use default location” and type the right path manually.

Then click “Next”

Then after, open the make builder window and check for the highlighted comments in displayed in yellow box. And click “Finish”

Step3 : Adding / Importing Supporting files

Soon after you finish up with the previous step , the following screen window will be exposed. Make sure it displays the name of your project as shown below.

Before we start the actual compilation we will have to add / import some basic source files. Although they are specific to the respective projects but must be included (with little up gradations) to each new project, so as to specify memory initialization and MAKE ( sequential compilation arrangements ) commands .

(5)

Thus for that we will use the “Import” feature of CDT ( C Development Tools ). Now first highlight the project like shown below , and then..

Again open up the “File” drop-down list . Where, you will find the “Import” command (not shown in this picture). Select that feature and you will find the screen displayed as below. Here we will import the files from the general environment.

(6)

Now open the drop down menu for “General” >> Select “File System” >> click “Next”

Then in the Import window click “Browse” to give the appropriate path where the demo project folder is located. As we had earlier added the demo project folder, we have to select the same path “C:\GCCFD\Demo_Projects\demo_lpc2138_blink_flash ”

(7)

Now when the demo project folder is selected, you can get a view of all files present in that folder. Among those, select the minimum required (or the basic) files which can be stated as follows:

1. Assembler Source File : crt.s

Which contains the startup function (called in ld-script), Reset Handler function, and necessary interrupt vector functions ( if included) in a project.

2. Linker script file : $Project name$.cmd

This contains, the memory mapping specific initialization instructions. 3. Make file : makefile.mak

This contains the sequential compilation process instructions to be executed after every “Build” command.

4. C source code file : main.c

This contains the basic source code file of the project. It’s not always that we’ve to import this file from another location. But because here we’re creating a demo project so we’ll have to take the file as it is. Otherwise when we create our different projects, this file will obviously be edited each time for the respective C source codes. Here the name

(8)

“main” is just a symbolic representation of our main C code. You can give any name as you want.

5. Respective Header File : lpcxxx.h

Here we will just include the necessary header file specific to our target processor. We must import this file from appropriate location.

Check the boxes in front of the files to be selected >> make sure the right name of your project is displayed in the “Into Folder “ text box “ >> click “Finish”.

Step4 : The Compilation Process

Here we are in the actual compilation environment having all the files needed for the assembling, building and compilation process.

(9)

But before going into further steps, first make sure that all files you have selected earlier are included in the “C/C++ window” as shown marked.

With those considerations, we begin the compilation process. Note that, each time you build or compile your code you should have to follow these process steps.

Soon while you see the clean window,

select (check) the check box in front of the project name >> click on “OK”

Note: Here you can also have an option to automatically start the build just after cleaning the project environment.

(10)
(11)

As the “Build All” command is executed the gcc compiler will run in background taking reference of the compilation

commands specified in make file. The stepwise execution and the end result can be visible in the console window located at the bottom of the screen (as shown in the picture).

Now here notice that, after the build (/ compile) some more files have been created in the C/C++ projects window. These are some of the output files which are required by the debugger to come into act. The files are

main.bin : (required for the openocd utility to program the processor core)

main.out : (required for the symbolic reference to be taken by GNUARM debugger) main.hex : (required for flash utility software to program the processor core)

References

Related documents

Start &gt; Control Panel &gt; Programs &gt; Uninstall a program &gt; select Bosch Recording Station and click Uninstall... Click Finish to restart

To back up your Favorites, go to Start &gt; Computer &gt; C drive &gt; Users &gt; double-click the folder which is named after your NUSNET UserID &gt; look for the Favorites folder

◆ Auto-antifreeze: To prevent the pipes and pumps from being frozen, the unit will defrost automatically when it meets the condition as follows: the ambient temperature is

Adjust text complexity for reading or listening comprehension level of student. Use systematic instruction to teach question answering and related

ASD: Autism Spectrum Disorder; TD: Typically developing; SC: Social cognition; GB: Golden Beauty; OAJ of GB: Objective aesthetic judgement; OAJP of GB: Objective aesthetic judgement

Right click on the Message Child Classes virtual folder and select New&gt;&gt;Class 4.. Change the name

file check box (Buyout: Interface &gt; Export Commitments &gt; Options) or Purchasing’s Auto Import after Sending check box (Purchasing: File &gt; Data Folder Settings &gt;

Solution: AVEVA’s Asset Life Cycle Information Management solution; AVEVA’s Control of Work solution; AVEVA Enterprise Asset Management™.. Asset Visualisation