Hello World LPC21xx / 32-bit Programming - ARM7
- Posted by admin
- on Jan, 28, 2013
- in ARM Microcontroller, ARM7, Electronics, General Know How, Hello World, Interfacing Tutorial
- Blog 2 Comments.
Lets begin with practical aspect of interfacing, programming with LPC21xx family. As every other Microcontroller Hello World program here too is, LED blink program, or GPIO program.This program also gives you an idea of assigning 32 bit values to registers. Most of us (at this stage, when you are learning about ARM7) are familiar to programming for 8 bit architecture, this is your opportunity to try your hands on 32 bit handelling, which looks a little odd initially, by time you will get used to it, so move on…

I will be following standard MCB2100 compatible hardware for most of the projects, will notify otherwise.
As shown in the schematic above 8 LEDs are connected to PORT1 pin number 16 to 23.
Here comes the C Receipe (available to download at the end of page, below is an image)
Step by Step explanation of the above receipe…
Line 1 : All register definitions, mapping to corresponding memory addresses are done in this header file, its a standard header source, it is added to the include path at the time of installing Keil MDK.
Line 3-12 : Its a 1 second delay function, used to generate processor delay using inbuilt Timer0 processing. As of now you can skip the actual working of this functional abstraction. I will explain the working of Timers and also of this functional abstraction in the timer section.
Line 16 : Instruction IODIR1 = 0x00FF0000 instructs the CPU that the current application will be using pin number 16 to 23 as generel purpose DIGITAL OUTPUT pin (IODIR => Input Output Direction Register).
Line 18 : Instruction IOSET1 = 0x00FF0000 instructs the CPU to write a Digital HIGH logic on pin number 16 to 23 of PORT1. (IOSET => Input Output Port SET Register).
Line 20 : Instruction IOCLR1 = 0x00FF0000 instructs the CPU to write a Digital LOW logic on pin number 16 to 23 of PORT1. (IOCLR => Input Output Port CLEAR Register).
Overall, above program blinks LEDs connected to PORT1 pin 16-23 at a rate defined by argument in function call delay_sec(integer argument).
Comments & Responses
Recent Posts
- Make In India - What it means to Indian Maker’s Community ?
- Breadboard Power Supplies - Read before you Buy One
- Product Review : Discover Wi-Fi extension board for stm32f4 discovery
- Product Review: OKI78SR-5/1.5 Switching Regulator from muRata Power Solutions
- Product Review - STM8S- Discovery by ST Microelectronics
- Know How : Using GSM Modem - Part 2/2
- Know How : Using GSM Modem - Part 1/2
- ST Microelectronics launches STM32 Nucleo Series
- SW18020P Vibration Switch Testing “Shake Switch”
- TCM8230MD Camera Breakout Board PCB, Can also mount AT45DB Series Flash Memory Chip
- IC Packages of Many Kinds - A comprehensive list
- Keil project setup for STM32F4 Discovery
- DIY - 12V 7.2Ah SMF Battery Charger Circuit
- Lonely Night Projects : DIY PMMC and Series Motor Model
- Toys from Trash with Arvind Gupta
- BodyCom Technology by Microchip for Embedded Security & Authentication
- Programmers for Atmel AVR Microcontrollers
- Nikola Tesla - The Greatest Inventor Ever Lived
- Crystal, Resonator and Oscillators, what’s the difference ?
- Pitfalls in STM32 Standard Peripheral Library & Possible Solutions
- Interrupt Driven UART Serial Communication for Atmel AVR
- DIY PICkit2
- What Thomas Edison expected job candidates to know !
- What does ‘AVR’ stands for ?
- Interfacing MCP4725, 12 bit DAC with AVR Microcontroller #avrPrayog
- Interfacing AT93C46 SPI EEPROM with avrPrayog
- How to recover the Unallocated space on Your SD card due to Raspberry Pi OS
- Driving an Alphanumeric LCD with avrPrayog
- Using Arduino/Freeduino as AVR ICSP Programmer
- DoCircuits : Turn your Web Browser into Prototyping Desk
Things You find here
- ADC Interfacing (1)
- Analog Design (4)
- Analog Designs (7)
- Arduino (9)
- ARM Microcontroller (12)
- ARM7 (6)
- Atmel AVR (8)
- Battery Chargers (2)
- Camera Interfacing (1)
- Display (1)
- EAGLE (3)
- EEPROM (2)
- Electrical Enginnering (6)
- Electronics (28)
- General Interest (15)
- General Know How (25)
- GSM Modem (2)
- Hello World (4)
- I2C (2)
- Interfacing Tutorial (15)
- Lonely Night Projects (4)
- LPC21xx (4)
- Make (4)
- mbed (1)
- Microchip (1)
- Microchip PIC (1)
- NXP (4)
- Open Source Ecology (2)
- Open Source Hardware (9)
- PCB Designing (2)
- Physical Computing (5)
- PIC Related (1)
- Power Supply (5)
- Product Review (2)
- Raspberry PI (1)
- Repair Tricks (2)
- SPI (2)
- ST Micro (8)
- STM32 (8)
- STM32F4 Doscovery (8)
- stm8 bit (1)
- Switch Mode Power supply (2)
- Technology (3)
- UART (3)
- Uncategorized (1)
Recently Said
- st1114g on How to recover the Unallocated space on Your SD card due to Raspberry Pi OS
- KpT, on How to recover the Unallocated space on Your SD card due to Raspberry Pi OS
- Neomanderx3 on I2C EEPROM Interfacing with STM32F4 Discovery
- Gábor on DIY PICkit2
- sapher on I2C EEPROM Interfacing with STM32F4 Discovery
- Tonino on DIY PICkit2
- nate on How to recover the Unallocated space on Your SD card due to Raspberry Pi OS
- mahd on TCM8230MD Camera Breakout Board PCB, Can also mount AT45DB Series Flash Memory Chip
- Andrew on How to recover the Unallocated space on Your SD card due to Raspberry Pi OS
- pavan on DIY - 12V 7.2Ah SMF Battery Charger Circuit




i did not understand the logic of IODIR1 = 0x00FF0000
what if i am using port 0 and pins 0 to 7???
i know AVR coding and in AVR i would write
DDRD=0xFF; //define as O/P port
PORTD=0×00; //initialize to 0
in AVR upper nibble n then lower nibble is written isnt the same in ARM?
m not able to understand in code…
plz help…
thank you in advance
(if my que is complicated then let me know will ask again)
in port1 we have 32 pins and count starts from zero from lsb.
so in IODIR1 = 0x00FF0000;
first zero(0) refers to nibble(4 bits)ie,P1.0 to P1.3, similarly for second third and forth.
now we have F (4bits) ie,P1.16 to P1.19.
and we have another F (4bits) ie,P1.20 to P1.23.
remaining are zero, anyway we dont need them.
i guess you got it, otherwise give me comments, so that i can explain you in another way.