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

PPTX
Cyber threat Intelligence and Incident Response by:-Sandeep Singh
PDF
MITRE ATT&CKcon 2018: From Automation to Analytics: Simulating the Adversary ...
PDF
MITRE ATT&CKcon 2018: ATT&CK: All the Things, Neelsen Cyrus and David Thompso...
PDF
What is ATT&CK coverage, anyway? Breadth and depth analysis with Atomic Red Team
PDF
Starting Over with Sub-Techniques
PDF
Tracking Noisy Behavior and Risk-Based Alerting with ATT&CK
PDF
MITRE ATT&CKcon 2.0: Alertable Techniques for Linux Using ATT&CK; Tony Lamber...
PPTX
Présentation audits de sécurité
Cyber threat Intelligence and Incident Response by:-Sandeep Singh
MITRE ATT&CKcon 2018: From Automation to Analytics: Simulating the Adversary ...
MITRE ATT&CKcon 2018: ATT&CK: All the Things, Neelsen Cyrus and David Thompso...
What is ATT&CK coverage, anyway? Breadth and depth analysis with Atomic Red Team
Starting Over with Sub-Techniques
Tracking Noisy Behavior and Risk-Based Alerting with ATT&CK
MITRE ATT&CKcon 2.0: Alertable Techniques for Linux Using ATT&CK; Tony Lamber...
Présentation audits de sécurité

Similar to How to use peripherals on MCB1700 (20)

PDF
Assembly programming II
PDF
Assembly programming II
PDF
Assembly programming II
PPTX
PIC-MICROCONTROLLER TUTORIALS FOR BEGINNERS
PDF
GPIO In Arm cortex-m4 tiva-c
DOCX
1 PageAlarm Clock Design Using PIC18F45E.docx
PPTX
Introduction to PIC.pptx
PDF
04 adc (pic24, ds pic with dma)
PPTX
Serial_communication protocol of msp430.pptx
PPTX
mpmc-unit-iv.pptx best part of the life is this
PPTX
MicrocontrollersII (1).pptx
PDF
PSC9131UG_C4_FD
PDF
Analog to Digital Converter
PPTX
THERMOMETER_963258_DIGITAL THERMOMETER.pptx
PPT
chapter 4
PDF
89c5131datasheet
PDF
CAN_controller_integrated_transceiver_microchip_MCP25625.pdf
PDF
Timers and Endge-aligned PWM
PPT
Introduction to PIC18FX6J Series MCUs
PDF
Blinking Of LEDs On LPC2148 ARM 7 TDMIS Based Microcontroller
Assembly programming II
Assembly programming II
Assembly programming II
PIC-MICROCONTROLLER TUTORIALS FOR BEGINNERS
GPIO In Arm cortex-m4 tiva-c
1 PageAlarm Clock Design Using PIC18F45E.docx
Introduction to PIC.pptx
04 adc (pic24, ds pic with dma)
Serial_communication protocol of msp430.pptx
mpmc-unit-iv.pptx best part of the life is this
MicrocontrollersII (1).pptx
PSC9131UG_C4_FD
Analog to Digital Converter
THERMOMETER_963258_DIGITAL THERMOMETER.pptx
chapter 4
89c5131datasheet
CAN_controller_integrated_transceiver_microchip_MCP25625.pdf
Timers and Endge-aligned PWM
Introduction to PIC18FX6J Series MCUs
Blinking Of LEDs On LPC2148 ARM 7 TDMIS Based Microcontroller
Ad

Recently uploaded (20)

PDF
Workplace Software and Skills - OpenStax
PDF
The Dynamic Duo Transforming Financial Accounting Systems Through Modern Expe...
DOCX
How to Use SharePoint as an ISO-Compliant Document Management System
DOC
UTEP毕业证学历认证,宾夕法尼亚克拉里恩大学毕业证未毕业
PDF
Wondershare Recoverit Full Crack New Version (Latest 2025)
PPTX
4Seller: The All-in-One Multi-Channel E-Commerce Management Platform for Glob...
PDF
Type Class Derivation in Scala 3 - Jose Luis Pintado Barbero
PDF
AI/ML Infra Meetup | Beyond S3's Basics: Architecting for AI-Native Data Access
PDF
Introduction to Ragic - #1 No Code Tool For Digitalizing Your Business Proces...
PDF
Top 10 Software Development Trends to Watch in 2025 🚀.pdf
PDF
Microsoft Office 365 Crack Download Free
PDF
Ableton Live Suite for MacOS Crack Full Download (Latest 2025)
PPTX
Introduction to Windows Operating System
PDF
Internet Download Manager IDM Crack powerful download accelerator New Version...
PPTX
Trending Python Topics for Data Visualization in 2025
PPTX
Cybersecurity: Protecting the Digital World
PPTX
Airline CRS | Airline CRS Systems | CRS System
PDF
AI Guide for Business Growth - Arna Softech
PDF
DuckDuckGo Private Browser Premium APK for Android Crack Latest 2025
PPTX
Cybersecurity-and-Fraud-Protecting-Your-Digital-Life.pptx
Workplace Software and Skills - OpenStax
The Dynamic Duo Transforming Financial Accounting Systems Through Modern Expe...
How to Use SharePoint as an ISO-Compliant Document Management System
UTEP毕业证学历认证,宾夕法尼亚克拉里恩大学毕业证未毕业
Wondershare Recoverit Full Crack New Version (Latest 2025)
4Seller: The All-in-One Multi-Channel E-Commerce Management Platform for Glob...
Type Class Derivation in Scala 3 - Jose Luis Pintado Barbero
AI/ML Infra Meetup | Beyond S3's Basics: Architecting for AI-Native Data Access
Introduction to Ragic - #1 No Code Tool For Digitalizing Your Business Proces...
Top 10 Software Development Trends to Watch in 2025 🚀.pdf
Microsoft Office 365 Crack Download Free
Ableton Live Suite for MacOS Crack Full Download (Latest 2025)
Introduction to Windows Operating System
Internet Download Manager IDM Crack powerful download accelerator New Version...
Trending Python Topics for Data Visualization in 2025
Cybersecurity: Protecting the Digital World
Airline CRS | Airline CRS Systems | CRS System
AI Guide for Business Growth - Arna Softech
DuckDuckGo Private Browser Premium APK for Android Crack Latest 2025
Cybersecurity-and-Fraud-Protecting-Your-Digital-Life.pptx
Ad

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" }