SlideShare a Scribd company logo
1 of 19
Download to read offline
ARM LPC2148 Training
Class - 1
Topic : Introduction to Pin’s,
PORTS and Configuring ARM
4/23/2020 Electrical Product Development
Lab
1
Topics
• PIN configuration
• PORTS
• Configuring PIN’s
• Simple LED blinking program
4/23/2020 Electrical Product Development
Lab
2
PIN Configuration
4/23/2020 Electrical Product Development
Lab
3
Fig : 1 PIN Diagram of LPC2148
PIN Configuration (Cont..)
4/23/2020 Electrical Product Development
Lab
4
LPC2148
PORT 0 PORT 1
P0.0 to P0.15 , P0.16 to P0.31 P1.0 to P1.15 , P1.16 to P1.31
Fig : 2 Distribution of PORT’s and PIN’s
PORTx
PORT 0:
• P0.0 to P0.15 → Lower 16 bit Pins
• P0.17 to P0.31 → Higher 16 bit Pins
PORT 1:
• P1.0 to P1.15 → Lower 16 bit Pins
• P1.17 to P1.31 → Higher 16 bit Pins
PORT 0 – Lower 16 bit and higher 16 bit
are used as GPIO pins
PORT 1 – Only higher 16 bit pins are used
as GPIO pins.
4/23/2020 Electrical Product Development
Lab
5
PORTx (Cont..)
• Pins of P1.0 to P1.15 of lower 16 bit pins
are not available for the user.
• Also P0.24, P0.26 and P0.27 are not
available for user.
• Out of 64 pins only user can use 45 Pins
of LPC2148.
4/23/2020 Electrical Product Development
Lab
6
Configuring PIN’s
• To use the 45 pins we must configure the pins by
configuring the following registers.
• IOxPIN/IOPINx → IO pin Status register
• IODIRx → Direction register
• IOSETx → State set register
• IOCLRx → PIN Clear register
• All the registers are 32 bit registers each bit
controls the each pin of LPC2148.
4/23/2020 Electrical Product Development
Lab
7
Configuring PIN’s
IOPINx – IO Pin Status register
Px.31 Px.27 Px.23 Px.19 Px.15 Px.11 Px.7 Px.3 Px.0
0000 0000 0000 0000 0000 0000 0000 0000
This can be written in the Hexa Decimal format
0 x 0 0 0 0 0 0 0 0
0x stands for hexa decimal deceleration
• Reading the values of pins can be done by
IOPINx
Ex: IOPIN0 = 0x0000000F
4/23/2020 Electrical Product Development
Lab
8
Configuring PIN’s (Cont…)
IODIRx - Direction register
• Assigning 0 → will make pin as INPUT
• Assigning 1 → will make pin as OUTPUT
• By default the pin value will be set as ‘0’
• If we want to change the pin P0.0 to P0.3
as OUTPUT pins then declaration will be
Ex: 0 x 0 0 0 0 0 0 0 F
4/23/2020 Electrical Product Development
Lab
9
Configuring PIN’s (Cont…)
IOSETx - State set register
Ex : 0 x 0 0 0 0 0 0 0 F // Px.0 to Px.3 as High
IOCLRx - PIN Clear register
Ex : 0 x 0 0 0 0 0 0 0 F // Px.0 to Px.3 satus will be
cleared
4/23/2020 Electrical Product Development
Lab
10
Configuring PIN’s (Cont…)
S1 S0 O/P
0 0 GPIO
0 1 1st
1 0 2nd
1 1 3rd
4/23/2020 Electrical Product Development
Lab
11
PSB
GPIO
Ist Alternate Function
2nd Alternate Function
Reserve
Px.y
S1 S0
x – 0 or 1
y – 0 to 31
Fig : 3 General Block Diagram of single
Table : 1 Selector Input and PIN State
S1 and S0 values are configured by associated register of PSB
Configuring PIN’s (Cont…)
• PSB – Pin Select Block has the following
registers
• PINSEL0 –Controls the pins from P0.0 to P0.15
• PINSEL1 –Controls the pins from P0.16 to P0.31
• PINSEL2 –Controls the pins from P1.16 to P1.31
• Each of the registers are 32 bit wide then how it
controls the 16 bit pins
4/23/2020 Electrical Product Development
Lab
12
Configuring PIN’s (Cont…)
• Lets take the example of PINSEL0 32 bit register
which controls the pins from P0.0 to P0.15.
• Similarly the registers of PINSEL1 and PINSEL2
will be distributed to the remaining pins of
corresponding PORTs
4/23/2020 Electrical Product Development
Lab
13
00
P0.12
00
P0.11
00
P0.10
00
P0.9
00
P0.8
00
P0.7
00
P0.6
00
P0.5
00
P0.4
00
P0.3
00
P0.2
00
P0.1
00
P0.0
S1 – S0S1 – S0
Fig : 4 Distribution of 32 bit registers to PINs of PORT 0
Configuring PIN’s (Cont…)
4/23/2020 Electrical Product Development
Lab
14
Fig : 5 Datasheet shows the features of PORTO Pins
Configuring PIN’s (Cont…)
• Example for configuring P0.0 pin as a Tx Pin for
USART communication
• PINSEL0 = 0 x 0 0 0 0 0 0 0 1
P0.0 become as TxD0 by setting LSB values of P0.3
to P0.0 as 0001
4/23/2020 Electrical Product Development
Lab
15
PSB
GPIO
TxDo
PWM
Reserve
P0.0
S1 S0
Fig : 5 Features of P0.0 pin
Simple LED Blinking Program
• Blink the LED connected in PORT1
# include <lpc21xx.h> // Include header file
void delay(void);
int main(void)
{
PINSEL2 = 0x00000000; // Configure P1.16 as GPIO pin
IODIR1 = 0x00000000; // Configure P1.16 as OUTPT pin
while(1) {
IOSET1 = 0x00010000; // Turn ON LED at P1.16
delay(); // Wait for a while
IOCLR1 = 0x00010000; // Turn OFF LED at P1.16
delay(); // Wait for a while
}
}
4/23/2020 Electrical Product Development
Lab
16
Simple LED Blinking Program
void delay(void){
unsigned int j; // assign the variable j
for(j=0;j<1000000;j++) // Increment j till
} 1000000
4/23/2020 Electrical Product Development
Lab
17
Assignment
• Draw the circuit for the above program
• Write the program for blinking the LED from
P0.16 to P0.23.
4/23/2020 Electrical Product Development
Lab
18
Thank You
4/23/2020 Electrical Product Development
Lab
19

More Related Content

What's hot

What's hot (20)

Lect 2 ARM processor architecture
Lect 2 ARM processor architectureLect 2 ARM processor architecture
Lect 2 ARM processor architecture
 
I2C Protocol
I2C ProtocolI2C Protocol
I2C Protocol
 
I2C introduction
I2C introductionI2C introduction
I2C introduction
 
Introduction to 80386
Introduction to 80386Introduction to 80386
Introduction to 80386
 
RISC-V Introduction
RISC-V IntroductionRISC-V Introduction
RISC-V Introduction
 
Master synchronous serial port (mssp)
Master synchronous serial port (mssp)Master synchronous serial port (mssp)
Master synchronous serial port (mssp)
 
UART
UART UART
UART
 
8085 microprocessor ramesh gaonkar
8085 microprocessor   ramesh gaonkar8085 microprocessor   ramesh gaonkar
8085 microprocessor ramesh gaonkar
 
Unit III ARM Interface and ARM Programming
Unit III ARM Interface and ARM Programming Unit III ARM Interface and ARM Programming
Unit III ARM Interface and ARM Programming
 
Arm instruction set
Arm instruction setArm instruction set
Arm instruction set
 
SPI Bus Protocol
SPI Bus ProtocolSPI Bus Protocol
SPI Bus Protocol
 
Uart
UartUart
Uart
 
8051 microcontroller
8051 microcontroller 8051 microcontroller
8051 microcontroller
 
8051 Architecture and PIN Configuration.pdf
8051 Architecture and PIN Configuration.pdf8051 Architecture and PIN Configuration.pdf
8051 Architecture and PIN Configuration.pdf
 
8086
80868086
8086
 
I2C Protocol
I2C ProtocolI2C Protocol
I2C Protocol
 
Microcontroller 8051
Microcontroller 8051Microcontroller 8051
Microcontroller 8051
 
Pic microcontroller architecture
Pic microcontroller architecturePic microcontroller architecture
Pic microcontroller architecture
 
PIC 16F877A by PARTHIBAN. S.
PIC 16F877A   by PARTHIBAN. S.PIC 16F877A   by PARTHIBAN. S.
PIC 16F877A by PARTHIBAN. S.
 
PIC Microcontrollers
PIC MicrocontrollersPIC Microcontrollers
PIC Microcontrollers
 

Similar to Introduction to ARM LPC2148

Embedded system (Chapter 3) io_port_programming
Embedded system (Chapter 3) io_port_programmingEmbedded system (Chapter 3) io_port_programming
Embedded system (Chapter 3) io_port_programming
Ikhwan_Fakrudin
 
EMBEDDED SYSTEMS 5
EMBEDDED SYSTEMS 5EMBEDDED SYSTEMS 5
EMBEDDED SYSTEMS 5
PRADEEP
 
digitalvoltmeterusing805112b2-170214173216 (1).pdf
digitalvoltmeterusing805112b2-170214173216 (1).pdfdigitalvoltmeterusing805112b2-170214173216 (1).pdf
digitalvoltmeterusing805112b2-170214173216 (1).pdf
satyamsinha37
 
Microcontroller 8051
Microcontroller 8051Microcontroller 8051
Microcontroller 8051
Rashmi
 
Programming the Digital I/O Interface of a PIC microcontroller
Programming the Digital I/O Interface of a PIC microcontrollerProgramming the Digital I/O Interface of a PIC microcontroller
Programming the Digital I/O Interface of a PIC microcontroller
Corrado Santoro
 
PIC Presentation_final updated.pptx
PIC Presentation_final updated.pptxPIC Presentation_final updated.pptx
PIC Presentation_final updated.pptx
ShabanamTamboli1
 
Introduction to pic
Introduction to picIntroduction to pic
Introduction to pic
PRADEEP
 
Microcontroller 8051
Microcontroller 8051Microcontroller 8051
Microcontroller 8051
Moeez Shem
 

Similar to Introduction to ARM LPC2148 (20)

Embedded system (Chapter 3) io_port_programming
Embedded system (Chapter 3) io_port_programmingEmbedded system (Chapter 3) io_port_programming
Embedded system (Chapter 3) io_port_programming
 
EMBEDDED SYSTEMS 5
EMBEDDED SYSTEMS 5EMBEDDED SYSTEMS 5
EMBEDDED SYSTEMS 5
 
DIGITAL VOLTMETER USING 8051 MICROCONTROLLER
DIGITAL VOLTMETER USING 8051 MICROCONTROLLERDIGITAL VOLTMETER USING 8051 MICROCONTROLLER
DIGITAL VOLTMETER USING 8051 MICROCONTROLLER
 
digitalvoltmeterusing805112b2-170214173216 (1).pdf
digitalvoltmeterusing805112b2-170214173216 (1).pdfdigitalvoltmeterusing805112b2-170214173216 (1).pdf
digitalvoltmeterusing805112b2-170214173216 (1).pdf
 
Chapter5 dek3133
Chapter5 dek3133Chapter5 dek3133
Chapter5 dek3133
 
Microcontroller 8051
Microcontroller 8051Microcontroller 8051
Microcontroller 8051
 
Analog To Digital Conversion (ADC) Programming in LPC2148
Analog To Digital Conversion (ADC) Programming in LPC2148Analog To Digital Conversion (ADC) Programming in LPC2148
Analog To Digital Conversion (ADC) Programming in LPC2148
 
Programming the Digital I/O Interface of a PIC microcontroller
Programming the Digital I/O Interface of a PIC microcontrollerProgramming the Digital I/O Interface of a PIC microcontroller
Programming the Digital I/O Interface of a PIC microcontroller
 
janakiraman egsp collage I msc 4 unit
janakiraman egsp collage  I msc 4 unitjanakiraman egsp collage  I msc 4 unit
janakiraman egsp collage I msc 4 unit
 
Dee2034 chapter 6 register
Dee2034 chapter 6 registerDee2034 chapter 6 register
Dee2034 chapter 6 register
 
PIC Presentation_final updated.pptx
PIC Presentation_final updated.pptxPIC Presentation_final updated.pptx
PIC Presentation_final updated.pptx
 
Tactile sensor working and its types
Tactile sensor working and its typesTactile sensor working and its types
Tactile sensor working and its types
 
IC 4017 Pin Configuration and Its Application
IC 4017 Pin Configuration and Its ApplicationIC 4017 Pin Configuration and Its Application
IC 4017 Pin Configuration and Its Application
 
janakiraman I msc 4 unit
janakiraman I msc 4 unitjanakiraman I msc 4 unit
janakiraman I msc 4 unit
 
14941634.ppt
14941634.ppt14941634.ppt
14941634.ppt
 
Microcontroller 8051
Microcontroller 8051Microcontroller 8051
Microcontroller 8051
 
Introduction to pic
Introduction to picIntroduction to pic
Introduction to pic
 
2. ALU and MIPS Arcitecture introduction.pdf
2. ALU and MIPS Arcitecture introduction.pdf2. ALU and MIPS Arcitecture introduction.pdf
2. ALU and MIPS Arcitecture introduction.pdf
 
8051 book
8051 book8051 book
8051 book
 
Microcontroller 8051
Microcontroller 8051Microcontroller 8051
Microcontroller 8051
 

Recently uploaded

Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
AnaAcapella
 
Call Girls in Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in  Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in  Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Recently uploaded (20)

How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17
 
Philosophy of china and it's charactistics
Philosophy of china and it's charactisticsPhilosophy of china and it's charactistics
Philosophy of china and it's charactistics
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Call Girls in Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in  Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in  Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 

Introduction to ARM LPC2148

  • 1. ARM LPC2148 Training Class - 1 Topic : Introduction to Pin’s, PORTS and Configuring ARM 4/23/2020 Electrical Product Development Lab 1
  • 2. Topics • PIN configuration • PORTS • Configuring PIN’s • Simple LED blinking program 4/23/2020 Electrical Product Development Lab 2
  • 3. PIN Configuration 4/23/2020 Electrical Product Development Lab 3 Fig : 1 PIN Diagram of LPC2148
  • 4. PIN Configuration (Cont..) 4/23/2020 Electrical Product Development Lab 4 LPC2148 PORT 0 PORT 1 P0.0 to P0.15 , P0.16 to P0.31 P1.0 to P1.15 , P1.16 to P1.31 Fig : 2 Distribution of PORT’s and PIN’s
  • 5. PORTx PORT 0: • P0.0 to P0.15 → Lower 16 bit Pins • P0.17 to P0.31 → Higher 16 bit Pins PORT 1: • P1.0 to P1.15 → Lower 16 bit Pins • P1.17 to P1.31 → Higher 16 bit Pins PORT 0 – Lower 16 bit and higher 16 bit are used as GPIO pins PORT 1 – Only higher 16 bit pins are used as GPIO pins. 4/23/2020 Electrical Product Development Lab 5
  • 6. PORTx (Cont..) • Pins of P1.0 to P1.15 of lower 16 bit pins are not available for the user. • Also P0.24, P0.26 and P0.27 are not available for user. • Out of 64 pins only user can use 45 Pins of LPC2148. 4/23/2020 Electrical Product Development Lab 6
  • 7. Configuring PIN’s • To use the 45 pins we must configure the pins by configuring the following registers. • IOxPIN/IOPINx → IO pin Status register • IODIRx → Direction register • IOSETx → State set register • IOCLRx → PIN Clear register • All the registers are 32 bit registers each bit controls the each pin of LPC2148. 4/23/2020 Electrical Product Development Lab 7
  • 8. Configuring PIN’s IOPINx – IO Pin Status register Px.31 Px.27 Px.23 Px.19 Px.15 Px.11 Px.7 Px.3 Px.0 0000 0000 0000 0000 0000 0000 0000 0000 This can be written in the Hexa Decimal format 0 x 0 0 0 0 0 0 0 0 0x stands for hexa decimal deceleration • Reading the values of pins can be done by IOPINx Ex: IOPIN0 = 0x0000000F 4/23/2020 Electrical Product Development Lab 8
  • 9. Configuring PIN’s (Cont…) IODIRx - Direction register • Assigning 0 → will make pin as INPUT • Assigning 1 → will make pin as OUTPUT • By default the pin value will be set as ‘0’ • If we want to change the pin P0.0 to P0.3 as OUTPUT pins then declaration will be Ex: 0 x 0 0 0 0 0 0 0 F 4/23/2020 Electrical Product Development Lab 9
  • 10. Configuring PIN’s (Cont…) IOSETx - State set register Ex : 0 x 0 0 0 0 0 0 0 F // Px.0 to Px.3 as High IOCLRx - PIN Clear register Ex : 0 x 0 0 0 0 0 0 0 F // Px.0 to Px.3 satus will be cleared 4/23/2020 Electrical Product Development Lab 10
  • 11. Configuring PIN’s (Cont…) S1 S0 O/P 0 0 GPIO 0 1 1st 1 0 2nd 1 1 3rd 4/23/2020 Electrical Product Development Lab 11 PSB GPIO Ist Alternate Function 2nd Alternate Function Reserve Px.y S1 S0 x – 0 or 1 y – 0 to 31 Fig : 3 General Block Diagram of single Table : 1 Selector Input and PIN State S1 and S0 values are configured by associated register of PSB
  • 12. Configuring PIN’s (Cont…) • PSB – Pin Select Block has the following registers • PINSEL0 –Controls the pins from P0.0 to P0.15 • PINSEL1 –Controls the pins from P0.16 to P0.31 • PINSEL2 –Controls the pins from P1.16 to P1.31 • Each of the registers are 32 bit wide then how it controls the 16 bit pins 4/23/2020 Electrical Product Development Lab 12
  • 13. Configuring PIN’s (Cont…) • Lets take the example of PINSEL0 32 bit register which controls the pins from P0.0 to P0.15. • Similarly the registers of PINSEL1 and PINSEL2 will be distributed to the remaining pins of corresponding PORTs 4/23/2020 Electrical Product Development Lab 13 00 P0.12 00 P0.11 00 P0.10 00 P0.9 00 P0.8 00 P0.7 00 P0.6 00 P0.5 00 P0.4 00 P0.3 00 P0.2 00 P0.1 00 P0.0 S1 – S0S1 – S0 Fig : 4 Distribution of 32 bit registers to PINs of PORT 0
  • 14. Configuring PIN’s (Cont…) 4/23/2020 Electrical Product Development Lab 14 Fig : 5 Datasheet shows the features of PORTO Pins
  • 15. Configuring PIN’s (Cont…) • Example for configuring P0.0 pin as a Tx Pin for USART communication • PINSEL0 = 0 x 0 0 0 0 0 0 0 1 P0.0 become as TxD0 by setting LSB values of P0.3 to P0.0 as 0001 4/23/2020 Electrical Product Development Lab 15 PSB GPIO TxDo PWM Reserve P0.0 S1 S0 Fig : 5 Features of P0.0 pin
  • 16. Simple LED Blinking Program • Blink the LED connected in PORT1 # include <lpc21xx.h> // Include header file void delay(void); int main(void) { PINSEL2 = 0x00000000; // Configure P1.16 as GPIO pin IODIR1 = 0x00000000; // Configure P1.16 as OUTPT pin while(1) { IOSET1 = 0x00010000; // Turn ON LED at P1.16 delay(); // Wait for a while IOCLR1 = 0x00010000; // Turn OFF LED at P1.16 delay(); // Wait for a while } } 4/23/2020 Electrical Product Development Lab 16
  • 17. Simple LED Blinking Program void delay(void){ unsigned int j; // assign the variable j for(j=0;j<1000000;j++) // Increment j till } 1000000 4/23/2020 Electrical Product Development Lab 17
  • 18. Assignment • Draw the circuit for the above program • Write the program for blinking the LED from P0.16 to P0.23. 4/23/2020 Electrical Product Development Lab 18
  • 19. Thank You 4/23/2020 Electrical Product Development Lab 19