This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Compiling a Project in Stellaris LM4f120H5QR

I wish to compile the following simple code in my low cost evaluation board i bought from TI

#include "inc/hw_types.h"
#include "inc/hw_memmap.h"
#include "driverlib/sysctl.h"
#include "driverlib/gpio.h"
int main(void)
{
int LED = 2;
SysCtlClockSet(SYSCTL_SYSDIV_4|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3);
while(1)
{
// Turn on the LED
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, LED);
// Delay for a bit
SysCtlDelay(2000000);
// Cycle through Red, Green and Blue LEDs
if (LED == 8) {LED = 2;} else {LED = LED*2;}
}
}


In the lab workbook (opens in a new window), on page 45 and 46 the lab explains how to let the CCS 'see' where my #included libraries are. I undestand this part and I successfully finished this lab.

But this is not what I want to do.
I want to have all wanted headers/libraries *inside* my project folder. So I included

gpio.h
sysctl.h
hw_memmap.h
hw_types.h

in the project folder it self and tried to debug the project. It didnt debug. said some other header files were missing. Then I started copying the header file that it said missing in the error window to the project folder but it was going on and on and on i didnt want to do it any longer..

I wish ti simply keep the wanted files to poject to compile in the project folder it self.
And not do the steps on the workbook page numbers 45,46 . I.E. not going into include options and ARM Linker to give references to headers and libraries.


My second question is,

What is the differene between the two references we provide from ARM Linker and Include options? (page 45,46) What is the difference of a library and a header. What Am I doing here. If it costs a long explanation would you tell me how i can figure it out.

  • Well maybe you want to do this...

    But this is not what I want to do.
    I want to have all wanted headers/libraries *inside* my project folder. So I included...

    But, it's bad practice.

    You have no reason -- ever -- to change those libraries unless you discover a bug and need to patch it. If you do not ever need to change them you should leave them in a common library of things that you do not touch -- ever...

    Put your hands in your packets, don't touch your keyboard, put your feet up on your desk and think about this for a while. Do not touch your keyboard until the urge passes to do what you believe is a good idea...

    A good engineer has scuff marks on the back of their shoe heels. That is because they take time to think before they act... They spend enough time with their feet up on their desks to think through such seemingly innocent desires and then are able to make a decision to not do some pointless things. Sometimes these pauses lead to great insight as well.

    The above was not lecture -- just some good advice.

    You can spend your career being given tasks -- or you can spend your career designing new things and managing projects -- take your pick. Both are worthwhile endeavors. We need both types of people.

    Now, having said the above, there are times to put things "closer" to your project.

    There are third party libraries -- which I sometimes modify to make task specific. I often move the UART or LCD display routines inside my project group folder. That is because I may make modifications which I do not wish to intrude upon any new projects.

    More than likely you are trying to make your project portable. That is another issue. You can do that by making all references to libraries by using the root of the project etc. Have another look at the examples. Also look at some of the One Day courses where they discuss portability.

    In the meantime -- leave well enough alone and spend some time thinking about the above...

    Feet up -- on the desk -- now! (rotflmao).

    Now on a cheerier note, Merry Christmas from Canada. Be careful, Santa Claus his checking his list. If you keep doing what you are doing there will be no new slide rule for Christmas. ;-)

  • A great answer. 

    I have sent you a personal message with my best greetings. Please check.

    Merry Christmas for you. 

  • And a very nice personal message it was! :-)

    A good engineer must also be willing to make mistakes -- when there is little risk. That is how you learn.

    You have the potential to be one of the truly great engineers...

    PS: A few years ago my daughter got her MSc in engineering -- if she did it -- you can too! She is now recognized as one of the best in her field.

    PPS: Sometimes taking risks is not appropriate -- when there is danger -- please students -- do not misinterpret my comments to mean that great risks are always appropriate. It is learning how to balance risk vs reward that distinguishes science from engineering. We must build things that work -- and work reliably.

  • I am truly honored. I will one day become one. I have no doubt and I will help others. I think thats the best part of it. :-) 

    I wont forget one thing. I have made a lot of mistakes until today, but I regret none. I  always make sure not to forget this statement, When life gives you lemons make lemonade!

    I will happily make mistakes. It was sometimes hard to face the consequences at the moment but later.. it gets better. And sometimes happier that I went in that path.. And I would have done same mistakes if i were to live again. I've also realized life is short. its hard to achieve extraordinary, without taking proper risks. :-) 

    A big shout out to my best friend, the most creative Electronics Undergraduate Ive ever seen,  Hafees Saleem , who jurst failed the second year of university for the second time! and is not at all worried about it!  His dream is to send the Sri Lankas first home made satellite to the Space. 

    A true engineer learns what the heart feels and designs what the heart desires for. In his case a satellite :-)

    I think I have time. Still 23. So I will eventually be better at this. But I want it to be soon. So I wont give up working hard on it!

    I thank you so much for having stated your previous reply. 

    it is indeed the greatest encouragement and means a lot to me.

    God bless you.

     

  • The drawback to keeping libraries separate from projects comes when you want to archive your projects.  In order for someone else (or even you at some later date) to take your project and rebuild it, they must have a snapshot of everything that was used the build the project.