SlideShare a Scribd company logo
How to use peripherals on
MCB1700
MTE241 – Fall2014
Peripherals
• GPIO
• ADC/DAC
• Ethernet
• USB
6/23/2016 MTE241 – Fall2014 2(UM10360, 2014)
Power Control Block
Power is a major concern in ARM-based chips
• By powering down the unused peripherals, considerable
power is saved
Peripheral power control register is referenced from
CMISIS as LPC_SC->PCONP
• LPC_SC is a general system-control register block
• PCONP refers to Power CONtrol for Peripherals
µVision provides the peripherals power through system_17xx.c
6/23/2016 MTE241 – Fall2014 3
Pin Connect Block
Most chip pins can perform up to four different functions
• You must specify what function you want each pin to be used for
Programming a set of registers known as the Pin Connect
Block
• From CMSIS as a struct called LPC_PINCON, with fields called
PINSEL1, PINSEL2, PINMODE1, PINMODE2 and so on.
6/23/2016 MTE241 – Fall2014 4
(UM10360, 2014)
(UM10360, 2014)
Interrupt Service Routine
• Almost all Peripherals can generate interrupts.
• The conditions on generating interrupts are different for each peripherals.
• Interrupt Service Routines in CMIS is just a function with the interrupt source
appended by _IRQHandler
• E.g. ADC_IRQHandler
• CMIS provides APIs for enabling/disabling, prioritizing, and Pending ISRs:
• Interrupts can be fired by writing interrupt number in NVIC->STIR
• But, they are cleared depending on the peripherals caused.
void NVIC_EnableIRQ( IRQn_Type IRQn )
void NVIC_DisableIRQ( IRQn_Type IRQn )
void NVIC_SetPriority( IRQn_Type IRQn, int32_t priority )
uint32_t NVIC_GetPriority( IRQn_Type IRQn )
6/23/2016 MTE241 – Fall2014 5
The chip directly communicates with its environment through pins in
GPIO mode
• The pin can be set for input or output directions
• In case of MCB1700:
• 8 LEDs are connected as output pins
• Joystick and INT0 button are connected as input pins
General-Purpose I/O
6/23/2016 MTE241 – Fall2014 6
Steps to Configure GPIO
Enable the power
Set Pins and their modes
• Selecting the GPIO LPC_PINCON->PINSEL[0-4]
• Input/output direction LPC_GPIO[0-2]->FIODIR
Set appropriate interrupts if needed
• Raising/falling edge LPC_GPIOINT->IO2IntEnF
• Registering NVIC_EnableIRQ( EINT3_IRQn )
• Clearing interrupt LPC_GPIOINT->IO2IntClr
Manipulating the pins
• Set an output pin FIOSET
• Read an input pin FIOPIN
• Clear an output pin FIOCLR
6/23/2016 MTE241 – Fall2014 7
Example 1: Turning On/Off a LED
1) Enable power
LPC_SC->PCONP |= (1 << 15);
2) LED connected to p1.28 is in GPIO mode
LPC_PINCON->PINSEL3 &= ~(3 << 25);
3) LED connected to p1.28 is an output pin
LPC_GPIO1->FIODIR |= (1 << 28);
4) Turning on the LED
LPC_GPIO1->FIOSET |= (1 << 28);
5) Turning off the LED
LPC_GPIO1->FIOCLR |= (1 << 28);
6/23/2016 MTE241 – Fall2014 8
(UM10360, 2014)
Example 2: Intercepting push-button click
1) Enable power
2) Push-button connected to p2.10 is in GPIO mode
LPC_PINCON->PINSEL4 &= ~( 3 << 20 );
3) P2.10 is an input pin
LPC_GPIO2->FIODIR &= ~( 1 << 10 );
4) P2.10 reads the falling edges to generate an interrupt
LPC_GPIOINT->IO2IntEnF |= ( 1 << 10 );
5) IRQ is enabled in NVIC.
NVIC_EnableIRQ( EINT3_IRQn );
6) Clear interrupt condition when it has been fired
LPC_GPIOINT->IO2IntClr |= (1 << 10);
6/23/2016 MTE241 – Fall2014 9
Clocks
• Clock in LPC178 is very flexible to generate different
frequencies at the same time
• Clock source is selected through Clock Source Select
register LPC_SC->CLKSRCSEL:
• Internal 4 MHz RC oscillator (this is the default)
• 12 MHz external oscillator
• 32 kHz real-time clock oscillator
• The input clock is directly fed into PLL to increase
the clock frequency and clock divider to decrease
the clock
• The clock can be divided further for peripheral
clockSetup the PLL and frequency devisors is complex
and involves many registers
• µVision provides a straightforward interface to set the
clock through system_17xx.c
6/23/2016 MTE241 – Fall2014 10
(UM10360, 2014)
Configuring the clock
• Select the Main oscillator
• The main oscillator generates 12 MHz clock,
OSCRANGE has to cover it.
• Select PLL0 to accelerate the clock
• The output frequency of PLL is 2 × M × F ÷ N
• F is input frequency
• 6 ≤ M ≤ 512
• 1 ≤ N ≤ 32
• E.g., 400 MHz = 2 × 100 × 12 ÷ 6
• Pick a proper clock divider for 100 MHz ARM
• CCLKSEL = 4
• Now the clock are ready for peripherals in
100 MHz, 50 MHz, 25 MHz and 12.5 MHz
6/23/2016 MTE241 – Fall2014 11
Analogue to Digital Convertor
• A 12-bit analog to digital converter
• 8 converting channels through 8-input analog mux
• A potentiometer connected to analog input 2
• Three registers are particularly to be configured
• The analog/digital control register LPC_ADC->ADCR
• The analog/digital global data register LPC_ADC->ADGDR
• The analog/digital interrupt enable register LPC_ADC->ADINTEN
6/23/2016 MTE241 – Fall2014 12
ADC configuration steps
• Set Power using PCONP register
• Where is accessible in system_17xx.c
• Set Clock using PCLKSEL0 register
• Already set
• Enable ADC0 pins through PINSEL registers
• Enable interrupts using CMSIS APIs
• Now, start conversion.
• Wait until the ADC status shows the conversion is done after ~52 ticks.
• Response to the interrupt
6/23/2016 MTE241 – Fall2014 13
Example3: Reading Potentiometer
1) Enable power
LPC_SC->PCONP |= ( 1 << 12 );
2) Potentiometer connected to p0.25 is in ADC mode
LPC_PINCON->PINSEL1 &= ~( 0x3 << 18 ); //clear bits
LPC_PINCON->PINSEL1 |= ( 0x1 << 18 ); //set bits
3) Set the ADC control register
LPC_ADC->ADCR = ( 1 << 2 ) | // Select the second channel
( 4 << 8 ) | // ADC clock is 25MHz/(4+1)
( 0 << 24 ) | // Do not start the conversion yet
( 1 << 21 ); // Enable ADC
4) Enable interrupt for all ADC channels
LPC_ADC->ADINTEN = ( 1 << 8);
5) Register interrupt
NVIC_EnableIRQ( ADC_IRQn );
6) Start Conversion
LPC_ADC->ADCR |= ( 1 << 24 );
LPC_SC->PCONP |= ( 1 << 12 );
7) Read the converted value
I. Polling (i.e. busy waiting) to see when the conversion is done. There is
no need to activate and register interrupts in this way.
// wait for conversion complete
while (LPC->ADGDR & 0x8000 == 0);
// read 12 bits result
ADC_Value = (LPC_ADC->ADGDR>>4) & 0xFFF;
II. Response for the interrupt
// Read ADC Status clears the interrupt condition
aDCStat = LPC_ADC->ADSTAT;
ADC_Value = (LPC_ADC->ADGDR >> 4) & 0xFFF;
6/23/2016 MTE241 – Fall2014 14
Resources
• LPC176x/5x User manual. (2014, April 2014). 3.1, 846. NXP Semiconductor.
Retrieved November 1, 2014, from
http://www.nxp.com/documents/user_manual/UM10360.pdf
• Roehl, B. (2011, April 18). Lab Manual for ECE 455. 39. Waterloo, ON, Canada.
Retrieved November 1, 2014, from
http://www.arm.com/files/pdf/ece455labmanual_preliminary.pdf
• Yiu, J. (2009). The Definitive Guide to the ARM® Cortex-M3
6/23/2016 MTE241 – Fall2014 15
@MANUAL {lpc178:usermanual, title = "UM10360: LPC176x/5x User manual",
organization = "NXP Semiconductor", edition = "Rev.3.1", month = "apr", year = "2014" }

More Related Content

PDF
7 problemas libro de estructuras
PPT
2010 Sfpe Cpd On Explosion Venting
PDF
ملزمة الرياضيات للصف السادس الاحيائي الفصل الاول
PDF
Tp2 Matlab
PDF
ملزمة الرياضيات للصف السادس الاحيائي الفصل الثاني القطوع المخروطية 2022
PPT
Exponentials
PDF
Tcc cal
PPTX
Air Pollution
7 problemas libro de estructuras
2010 Sfpe Cpd On Explosion Venting
ملزمة الرياضيات للصف السادس الاحيائي الفصل الاول
Tp2 Matlab
ملزمة الرياضيات للصف السادس الاحيائي الفصل الثاني القطوع المخروطية 2022
Exponentials
Tcc cal
Air Pollution

What's hot (9)

DOC
Toán 8 hsg 2016 2017
PDF
Ocw capitulo iii
PDF
BEER Cap 05 Solucionario
DOCX
Actividad n 01 mecanica1
DOC
Anschp37
PDF
ゲーム理論BASIC 演習69 -3人ゲームの混合戦略ナッシュ均衡-
PPT
1.6,5.4 bending stress in straight beams
PDF
66.-Merle C. Potter, David C. Wiggert, Bassem H. Ramadan - Mechanics of Fluid...
PPT
07 periodic functions and fourier series
Toán 8 hsg 2016 2017
Ocw capitulo iii
BEER Cap 05 Solucionario
Actividad n 01 mecanica1
Anschp37
ゲーム理論BASIC 演習69 -3人ゲームの混合戦略ナッシュ均衡-
1.6,5.4 bending stress in straight beams
66.-Merle C. Potter, David C. Wiggert, Bassem H. Ramadan - Mechanics of Fluid...
07 periodic functions and fourier series
Ad

Similar to How to use peripherals on MCB1700 (20)

PDF
Unit II Study of Onchip Peripherals
PDF
Analog To Digital Conversion (ADC) Programming in LPC2148
PPTX
Introduction to PIC.pptx
PDF
Blinking Of LEDs On LPC2148 ARM 7 TDMIS Based Microcontroller
DOCX
Arm7 Interfacing examples
PDF
Pic24HJ256GP210 course 2015 09-23
PPTX
Lpc 17xx adc
PPT
MC9S08MP16: 8-bit MCU For BLDC Motor Control
PDF
2014 ii c08t-sbc pic para ecg
PPTX
Iot Workshop NITT 2015
PPTX
An Introduction to Microcontrollers part 2
PDF
Arm Processor Based Speed Control Of BLDC Motor
PPTX
microprocessor systems Lecture 2 Parallel port
PDF
Micro-controllers (PIC) based Application Development
PPTX
Brain wave controlled robot
PPTX
MICROCONTROLLER.pptx
PPT
dsPIC33FJ06GSXXX DSCs
PPTX
Microprocessor based Temperature Controller
PPTX
STM_ADC para microcontroladores STM32 - Conceptos basicos
PDF
embedded system introduction to microcontrollers
Unit II Study of Onchip Peripherals
Analog To Digital Conversion (ADC) Programming in LPC2148
Introduction to PIC.pptx
Blinking Of LEDs On LPC2148 ARM 7 TDMIS Based Microcontroller
Arm7 Interfacing examples
Pic24HJ256GP210 course 2015 09-23
Lpc 17xx adc
MC9S08MP16: 8-bit MCU For BLDC Motor Control
2014 ii c08t-sbc pic para ecg
Iot Workshop NITT 2015
An Introduction to Microcontrollers part 2
Arm Processor Based Speed Control Of BLDC Motor
microprocessor systems Lecture 2 Parallel port
Micro-controllers (PIC) based Application Development
Brain wave controlled robot
MICROCONTROLLER.pptx
dsPIC33FJ06GSXXX DSCs
Microprocessor based Temperature Controller
STM_ADC para microcontroladores STM32 - Conceptos basicos
embedded system introduction to microcontrollers
Ad

Recently uploaded (20)

PPT
Introduction Database Management System for Course Database
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
Digital Strategies for Manufacturing Companies
PPTX
assetexplorer- product-overview - presentation
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
Softaken Excel to vCard Converter Software.pdf
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PPTX
Computer Software and OS of computer science of grade 11.pptx
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PPTX
ai tools demonstartion for schools and inter college
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
Introduction Database Management System for Course Database
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Odoo Companies in India – Driving Business Transformation.pdf
Design an Analysis of Algorithms II-SECS-1021-03
Digital Strategies for Manufacturing Companies
assetexplorer- product-overview - presentation
Which alternative to Crystal Reports is best for small or large businesses.pdf
How to Choose the Right IT Partner for Your Business in Malaysia
CHAPTER 2 - PM Management and IT Context
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Softaken Excel to vCard Converter Software.pdf
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Computer Software and OS of computer science of grade 11.pptx
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
ai tools demonstartion for schools and inter college
wealthsignaloriginal-com-DS-text-... (1).pdf

How to use peripherals on MCB1700

  • 1. How to use peripherals on MCB1700 MTE241 – Fall2014
  • 2. Peripherals • GPIO • ADC/DAC • Ethernet • USB 6/23/2016 MTE241 – Fall2014 2(UM10360, 2014)
  • 3. Power Control Block Power is a major concern in ARM-based chips • By powering down the unused peripherals, considerable power is saved Peripheral power control register is referenced from CMISIS as LPC_SC->PCONP • LPC_SC is a general system-control register block • PCONP refers to Power CONtrol for Peripherals µVision provides the peripherals power through system_17xx.c 6/23/2016 MTE241 – Fall2014 3
  • 4. Pin Connect Block Most chip pins can perform up to four different functions • You must specify what function you want each pin to be used for Programming a set of registers known as the Pin Connect Block • From CMSIS as a struct called LPC_PINCON, with fields called PINSEL1, PINSEL2, PINMODE1, PINMODE2 and so on. 6/23/2016 MTE241 – Fall2014 4 (UM10360, 2014) (UM10360, 2014)
  • 5. Interrupt Service Routine • Almost all Peripherals can generate interrupts. • The conditions on generating interrupts are different for each peripherals. • Interrupt Service Routines in CMIS is just a function with the interrupt source appended by _IRQHandler • E.g. ADC_IRQHandler • CMIS provides APIs for enabling/disabling, prioritizing, and Pending ISRs: • Interrupts can be fired by writing interrupt number in NVIC->STIR • But, they are cleared depending on the peripherals caused. void NVIC_EnableIRQ( IRQn_Type IRQn ) void NVIC_DisableIRQ( IRQn_Type IRQn ) void NVIC_SetPriority( IRQn_Type IRQn, int32_t priority ) uint32_t NVIC_GetPriority( IRQn_Type IRQn ) 6/23/2016 MTE241 – Fall2014 5
  • 6. The chip directly communicates with its environment through pins in GPIO mode • The pin can be set for input or output directions • In case of MCB1700: • 8 LEDs are connected as output pins • Joystick and INT0 button are connected as input pins General-Purpose I/O 6/23/2016 MTE241 – Fall2014 6
  • 7. Steps to Configure GPIO Enable the power Set Pins and their modes • Selecting the GPIO LPC_PINCON->PINSEL[0-4] • Input/output direction LPC_GPIO[0-2]->FIODIR Set appropriate interrupts if needed • Raising/falling edge LPC_GPIOINT->IO2IntEnF • Registering NVIC_EnableIRQ( EINT3_IRQn ) • Clearing interrupt LPC_GPIOINT->IO2IntClr Manipulating the pins • Set an output pin FIOSET • Read an input pin FIOPIN • Clear an output pin FIOCLR 6/23/2016 MTE241 – Fall2014 7
  • 8. Example 1: Turning On/Off a LED 1) Enable power LPC_SC->PCONP |= (1 << 15); 2) LED connected to p1.28 is in GPIO mode LPC_PINCON->PINSEL3 &= ~(3 << 25); 3) LED connected to p1.28 is an output pin LPC_GPIO1->FIODIR |= (1 << 28); 4) Turning on the LED LPC_GPIO1->FIOSET |= (1 << 28); 5) Turning off the LED LPC_GPIO1->FIOCLR |= (1 << 28); 6/23/2016 MTE241 – Fall2014 8 (UM10360, 2014)
  • 9. Example 2: Intercepting push-button click 1) Enable power 2) Push-button connected to p2.10 is in GPIO mode LPC_PINCON->PINSEL4 &= ~( 3 << 20 ); 3) P2.10 is an input pin LPC_GPIO2->FIODIR &= ~( 1 << 10 ); 4) P2.10 reads the falling edges to generate an interrupt LPC_GPIOINT->IO2IntEnF |= ( 1 << 10 ); 5) IRQ is enabled in NVIC. NVIC_EnableIRQ( EINT3_IRQn ); 6) Clear interrupt condition when it has been fired LPC_GPIOINT->IO2IntClr |= (1 << 10); 6/23/2016 MTE241 – Fall2014 9
  • 10. Clocks • Clock in LPC178 is very flexible to generate different frequencies at the same time • Clock source is selected through Clock Source Select register LPC_SC->CLKSRCSEL: • Internal 4 MHz RC oscillator (this is the default) • 12 MHz external oscillator • 32 kHz real-time clock oscillator • The input clock is directly fed into PLL to increase the clock frequency and clock divider to decrease the clock • The clock can be divided further for peripheral clockSetup the PLL and frequency devisors is complex and involves many registers • µVision provides a straightforward interface to set the clock through system_17xx.c 6/23/2016 MTE241 – Fall2014 10 (UM10360, 2014)
  • 11. Configuring the clock • Select the Main oscillator • The main oscillator generates 12 MHz clock, OSCRANGE has to cover it. • Select PLL0 to accelerate the clock • The output frequency of PLL is 2 × M × F ÷ N • F is input frequency • 6 ≤ M ≤ 512 • 1 ≤ N ≤ 32 • E.g., 400 MHz = 2 × 100 × 12 ÷ 6 • Pick a proper clock divider for 100 MHz ARM • CCLKSEL = 4 • Now the clock are ready for peripherals in 100 MHz, 50 MHz, 25 MHz and 12.5 MHz 6/23/2016 MTE241 – Fall2014 11
  • 12. Analogue to Digital Convertor • A 12-bit analog to digital converter • 8 converting channels through 8-input analog mux • A potentiometer connected to analog input 2 • Three registers are particularly to be configured • The analog/digital control register LPC_ADC->ADCR • The analog/digital global data register LPC_ADC->ADGDR • The analog/digital interrupt enable register LPC_ADC->ADINTEN 6/23/2016 MTE241 – Fall2014 12
  • 13. ADC configuration steps • Set Power using PCONP register • Where is accessible in system_17xx.c • Set Clock using PCLKSEL0 register • Already set • Enable ADC0 pins through PINSEL registers • Enable interrupts using CMSIS APIs • Now, start conversion. • Wait until the ADC status shows the conversion is done after ~52 ticks. • Response to the interrupt 6/23/2016 MTE241 – Fall2014 13
  • 14. Example3: Reading Potentiometer 1) Enable power LPC_SC->PCONP |= ( 1 << 12 ); 2) Potentiometer connected to p0.25 is in ADC mode LPC_PINCON->PINSEL1 &= ~( 0x3 << 18 ); //clear bits LPC_PINCON->PINSEL1 |= ( 0x1 << 18 ); //set bits 3) Set the ADC control register LPC_ADC->ADCR = ( 1 << 2 ) | // Select the second channel ( 4 << 8 ) | // ADC clock is 25MHz/(4+1) ( 0 << 24 ) | // Do not start the conversion yet ( 1 << 21 ); // Enable ADC 4) Enable interrupt for all ADC channels LPC_ADC->ADINTEN = ( 1 << 8); 5) Register interrupt NVIC_EnableIRQ( ADC_IRQn ); 6) Start Conversion LPC_ADC->ADCR |= ( 1 << 24 ); LPC_SC->PCONP |= ( 1 << 12 ); 7) Read the converted value I. Polling (i.e. busy waiting) to see when the conversion is done. There is no need to activate and register interrupts in this way. // wait for conversion complete while (LPC->ADGDR & 0x8000 == 0); // read 12 bits result ADC_Value = (LPC_ADC->ADGDR>>4) & 0xFFF; II. Response for the interrupt // Read ADC Status clears the interrupt condition aDCStat = LPC_ADC->ADSTAT; ADC_Value = (LPC_ADC->ADGDR >> 4) & 0xFFF; 6/23/2016 MTE241 – Fall2014 14
  • 15. Resources • LPC176x/5x User manual. (2014, April 2014). 3.1, 846. NXP Semiconductor. Retrieved November 1, 2014, from http://www.nxp.com/documents/user_manual/UM10360.pdf • Roehl, B. (2011, April 18). Lab Manual for ECE 455. 39. Waterloo, ON, Canada. Retrieved November 1, 2014, from http://www.arm.com/files/pdf/ece455labmanual_preliminary.pdf • Yiu, J. (2009). The Definitive Guide to the ARM® Cortex-M3 6/23/2016 MTE241 – Fall2014 15 @MANUAL {lpc178:usermanual, title = "UM10360: LPC176x/5x User manual", organization = "NXP Semiconductor", edition = "Rev.3.1", month = "apr", year = "2014" }