In depth LED Blink with NXP LPC17xx


/*—————————————————————————-

MAIN function

*—————————————————————————-*/

int main (void)
{

if (SysTick_Config(SystemCoreClock / 1000)) /* Setup SysTick Timer for 1 msec interrupts */

{

while (1); /* Capture error */

}

LED_Config();

while(1)
       {

         LED_On ((1<<28)); /* Turn on the LED. */

         Delay (100); /* delay 100 msec */

         LED_Off ((1<<28)); /* Turn off the LED. */

         Delay (100); /* delay 100 msec */

       }

}

SysTick_Config()

In this, first we configure the systick timer, you should not give more than system core clock ticks. If you passmore than that, the LOAD_RELOAD register can’t hold that value, and you will get stuck into the while loopwhich is called Capture Error here.

Here, we pass 1000 number of ticks which is equal to 1 msec. The working of System Delay is as follows.

• The number of ticks will get store into the Match register.

• When the systick timer which is usually down count timer or Up count timer, the LOAD_RELOADregister will decrement and checks with Match register for every tick.

• If LOAD_RELOAD register value reaches to match register value then the system interrupt will generateand it calls the SysTick_Handler function.

LED_Config()

Now, just configure the LED pins by just making the led pins direction to output.

While loop

Then start the while loop. Inside, for every time LED glows and then Delay function gets called after that LEDwill glow off. And again it enters into the Delay function. After delay time, again the process starts.

One sincere request to all the readers, please comment down and correct us, this site is trying to help people to understand embedded technology, this is only possible with your comments and corrections. Please subscribe to the newsletter to get latest project/article updates right in your email inbox. Take few moments and like zembedded facebook page here, follow on tweeter, thanks!

 

Related posts:

About author

This article was written by admin

Admin has over twenty years experience in the electronics industry, largely dedicated to embedded software. A frequent presenter at conferences and seminars and author of numerous technical articles. Working presently as Development Manager in India. A firm Believer in Knowledge grows when it shared.

Comments

Comments (2)
  1. tarik says - Posted: March 16, 2013

    hello,
    what do you advise me,lpcxpresso board or arduino board to begin with embedded systems and are lpcxpresso an open source hard and soft, because i want to use them free

    thanks

  2. jalaja says - Posted: July 19, 2013

    Need more information on this……..

Leave your comment

Your email address will not be published. Required fields are marked *