Documente Academic
Documente Profesional
Documente Cultură
http://www.zembedded.com/in-depth-led-blink-with-...
Latest Technology
Latest Gadgets
AVR Projects
Sensors
C pit falls
About Us
HOME
CONTROLLERS
EMBEDDED C
EMBED TOOLS
EMBED INTERFACE
RTOS
LINUX
Search
Recent Post
This is going to be a very interesting tutorial for us, as being an embedded developer we all start training with LED Share blinking, or in other words Hello Word. In this tutorial we are going to discuss in depth LED blink with NXP LPC17xx controller. I assume that you are well aware of embedded C and knowledge of microcontrollers. #include LPC17xx.h This file is common for all 17xx series controllers. In this header file, interrupts, GPIO pins, protocols definitions and the memory mappings are done here. volatileuint32_t msTicks; volatile tells the compiler not to optimize anything that has to do with the volatile variable. The main and only reason is, when we are interfacing with hardware, and then we need to use volatile keyword. uint32_t is coming from the following line. typedef unsigned long uint32_t ; If you are coming from C, then you dont need any introduction about typedef. If not, typedef is a keyword in Cwhich is used to assign alias name for any existing data type. /* SysTick_Handler **/ void SysTick_Handler(void) { msTicks++; } 1. Here we have External Interrupts and Internal Interrupts(system interrupts). For the systeminterrupts, there are already a set of handler functions also defined in our libraries. Here, SysTick_Handler is the handler function for one of the internal interrupt. 2. So, the next question is when it will be called???? Well, when you configure the systick timer, then for every reload buffer overwritten, it causes aninterrupt, thenthe handler function SysTick_Handler will be called. 3. So, if you want to see from where these handlers are getting called by interrupts?? Then go and open your startup_LPC17xx.h header file. If you observe the vector table address mapping, thereyou will find the system interrupts and external interrupts.
/* System Delay **/ __INLINE static void Delay (uint32_t dlyTicks) { 8051 Microcontroller (3) Android Tutorials (3) Categories
1 de 4
17/10/13 02:26
http://www.zembedded.com/in-depth-led-blink-with-...
ARM Microcontrollers (16) AVR Microcontrollers (15) AVR Projects (3) C pit falls (1) Embed Interface (6) Embed Tools (7) Embedded C (16) Latest Gadgets (12) Latest Technology (46) Linux (3) PIC microcontrollers (2) RTOS (3) Scholars Tips (3) Sensors (1)
This function gives the required delay for us. For every 1 msec, the global variable msTicks will get increments inSysTick_Handler function, so, until the required time gets over, the control will be in while loop which is inDelay function. /* configure LED pins **/ __INLINE static void LED_Config(void) { LPC_GPIO1->FIODIR = 0xB0000000; /* LEDs PORT1 are Output */
Share
Here, LPC_GPIO1 is a macro. The declaration is in LPC17xx.h header file. This macro consists of address location which is base address to the port 1. So, by using this structure base address, we can access port direction register, set register, clear registers. All these structures are defined in the same LPC17xx.h header file. /* Switch on LEDs **/ __INLINE static void LED_On (uint32_t led) { LPC_GPIO1->FIOPIN |= (led); /* Turn On LED */ } As we discuss in the above paragraph, FIOPIN is a structure member which is used to read the output. led is the pin number which is connected to LED. Here, when you receive the pin number, due to ORing operation that pin gets high which results the LED makes glow. /* Switch off LEDs **/ __INLINE static void LED_Off (uint32_t led) { LPC_GPIO1->FIOPIN &= ~(led); /* Turn Off LED */ } As I said above, when the function receive the pin number, that particular pin become low, so the LED will go off. To go to next page click here
Recent Posts Intel Galileo : Compatible with Arduino software and shields OCTOBER 4, 2013 Thermocouple A temperature sensor
SEPTEMBER 29, 2013
Whats a Compiler and Compilation? JUNE 2, 2013 AVR LCD interfacing : LCD part I MAY 7, 2013 Arduino MEGA and LEONARDO Pin-Out Diagrams! APRIL 10, 2013 CORTEX -M3 : Registers in depth MARCH 20, 2013 Pointers In C FEBRUARY 28, 2013 COMPLEX STRUCTURE DEFINITIONS
FEBRUARY 21, 2013
Subscribe to Blog via Email Enter your email address to subscribe to this blog and receive notifications of new posts by email. Join 46 other subscribers
Related posts:
Next page
Tweet
Like
39
2 de 4
17/10/13 02:26
http://www.zembedded.com/in-depth-led-blink-with-...
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.
Related Posts
Intel Galileo : Compatible with Arduino software and shields - October 4, 2013 ARM : Example Setting PLL for LPC2148 - April 4, 2013 Cortex-M3: Operation Modes & Access Levels - March 22, 2013 CORTEX -M3 : Registers in depth - March 20, 2013 An intro to Cortex M3 by NXP - March 9, 2013
Share
Cortex M3 SysTick Explained Part II - February 26, 2013 Cortex M3 SysTick Explained Part-I - February 5, 2013 NXP offers emWin free with ARM Microcontrollers - February 3, 2013 ARM Memory Mapping - February 3, 2013 ARM Interfacing and initialization of SDRAM - December 26, 2012
Comments
tarik says - POSTED: MARCH 16, 2013
Comments (2)
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 Reply
Leave a Reply
3 de 4
17/10/13 02:26
http://www.zembedded.com/in-depth-led-blink-with-...
RECENT POST
Intel Galileo : Compatible with Arduino software and shields October 4, 2013 Thermocouple A temperature sensor September 29, 2013 Whats a Compiler and Compilation? June 2, 2013 AVR LCD interfacing : LCD part I May 7, 2013 Arduino MEGA and LEONARDO Pin-Out Diagrams! April 10, 2013 ARM : Example Setting PLL for LPC2148 April 4, 2013 Cortex-M3: Operation Modes & Access Levels March 22, 2013 CORTEX -M3 : Registers in depth March 20, 2013
RECENT COMMENTS
nethra on COMPLEX STRUCTURE DEFINITIONS jal on Thermocouple A temperature sensor nethra on Thermocouple A temperature sensor nethra on CORTEX -M3 : Registers in depth ankush on ARM : Example Setting PLL for LPC2148 ankush on ARM : Example Setting PLL for LPC2148
DISCLAIMERS AND NOTICES www.zembedded.com do not take any responsibility to the contents added in this site. we just search and collect data from popular article directories and use search engine to collect the best information for you. We really strict about copyright but however, if you feel that any of these contents are violating the copyright rules, please let us know. we will exclude it as soon as possible. Please contact us with your exact grievance/problem with respect to those third party links. We assure you that appropriate action will be taken immediately. Thanks Email: admin@zembedded.com
ZEMBEDDED Zembedded
Me gusta A 1015 personas les gusta Zembedded.
Share
Copyrightzembedded.com
Back to top
4 de 4
17/10/13 02:26