LPC2148 GPIO PDF
Document Details
Uploaded by Deleted User
Tags
Summary
This document provides an overview of the LPC2148 microcontroller, focusing on its GPIO (General Purpose Input/Output) functionality. It details the various features, use cases, and applications of this ARM7-based device.
Full Transcript
LPC2148-GPIO LPC2148 and GPIO LPC2148 LPC2148 LPC2148 is a 32-bit Microcontroller based on the ARM 7TDMI-S Family. It is manufactured by NXP Semiconductors (formerly Philips) and is one of the widely used and highly successful ARM7-based Microcontroller. Even though ARM7 family is considered obs...
LPC2148-GPIO LPC2148 and GPIO LPC2148 LPC2148 LPC2148 is a 32-bit Microcontroller based on the ARM 7TDMI-S Family. It is manufactured by NXP Semiconductors (formerly Philips) and is one of the widely used and highly successful ARM7-based Microcontroller. Even though ARM7 family is considered obsolete with the introduction of many advanced processors and controllers, it is one of the best and easiest microcontrollers to work around for beginners in ARM based microcontrollers. LPC2148 The LPC2142/2148 microcontrollers are based on a 32/16-bit ARM7TDMI-S CPU with real-time emulation and embedded trace support. Due to their tiny size and low power consumption, LPC2142/2148 are ideal for applications where miniaturization is a key requirement, such as access control and point-of-sale reduces code by more than 30% with minimal performance penalty. Due to their tiny size and low power consumption, LPC2142/2148 are ideal for applications where miniaturization is a key requirement, such as access control and point-of-sale A blend of serial communications interfaces ranging from a USB 2.0 Full-speed device, multiple UARTs(Universal Asynchronous Receiver Transmitter) , SPI (Serial Peripheral Interface (SPI) ), and on-chip SRAM of 16 kB/40 kB, make these devices very well suited for communication gateways and protocol converters, soft modems, voice recognition and low end imaging, providing both large buffer size and high processing power. Various 32-bit timers, single or dual 10-bit ADC(s), 10- bit DAC, PWM channels and 45 fast GPIO lines with up to nine edge or level sensitive external interrupt pins make these microcontrollers particularly suitable for industrial control and medical systems. 16 kB/40 kB of on-chip static RAM and 64 kB/512 kB of on-chip flash program memory. 128-bit wide interface/accelerator enables high- speed 60 MHz operation. In-System Programming/In-Application Programming (ISP/IAP) via on- chip boot-loader software. Single flash sector or full chip erase in 400 ms and programming of 256 bytes in 1 ms. EmbeddedICE RT and Embedded Trace interfaces offer real-time debugging with the on-chip RealMonitor software and high-speed tracing of instruction execution. USB 2.0 Full-speed compliant device controller with 2 kB of endpoint RAM. In addition, the LPC2148 provides 8 kB of on-chip RAM accessible to USB by DMA. One or two (LPC2142/48) 10-bit ADCs provide a total of 6/14 analog inputs, with conversion times as low as 2.44 µs per channel. Single 10-bit DAC provides variable analog output. Two 32-bit timers/external event counters (with four capture and four compare channels each), PWM unit (six outputs) and watchdog. Low power Real-Time Clock (RTC) with independent power and dedicated 32 kHz clock input. Multiple serial interfaces including two UARTs (16C550), two Fast I2C-bus (400 kbit/s), SPI and SSP with buffering and variable data length capabilities. Vectored Interrupt Controller (VIC) with configurable priorities and vector addresses. Up to 45 of 5 V tolerant fast general purpose I/O pins in a tiny LQFP64 package. Up to nine edge or level sensitive external interrupt pins available. 60 MHz maximum CPU clock available from programmable on-chip PLL with settling time of 100 µs. On-chip integrated oscillator operates with an external crystal in range from 1 MHz to 30 MHz and with an external oscillator up to 50 MHz. Power saving modes include Idle and Power-down. Individual enable/disable of peripheral functions as well as peripheral clock scaling for additional power optimization. Processor wake-up from Power-down mode via external interrupt or BOD. Single power supply chip with POR and BOD circuits: CPU operating voltage range of 3.0 V to 3.6 V (3.3 V ± 10 %) with 5 V tolerant I/O pads. General Purpose Input Output (GPIO) pins of a microcontroller are the first thing we need to learn before starting its embedded programming, as input/output pins are the only way to interface with the microcontroller. Uses: driving loads, reading digital and analog signal, controlling external components, generating triggers for external devices etc GPIO-General Purpose Input Output Ports Port is a collection of 32 GPIO pins Ports are used to connect I/O devices (peripherals) to the processor; the processor may interact with the outside world through a group of GPIO pins called ports; GPIO pins are used to interface the processor with the external peripherals like Buttons, LEDs, Switches, LCD, etc. LPC2148 has two IO ports namely PORT0 (P0) and PORT1 (P1). These two IO ports are of 32-bit wide and are provided by the 64 pins of the microcontroller. The naming convention of the I/O pins on the LPC2148 Microcontroller is Pa.bc where ‘a’ is the number of the port i.e. 0 or 1 (as LPC2148 has only two ports) and ‘bc’ is the number of the pin in the port a. For example, P0.1 indicates pin number 1 of PORT0 and P1.10 indicates pin number 10 of PORT1. [Refer the naming given in each pin to identify the corresponding port of LPC2148] Most of the pins in both the I/O ports of the LPC2148 have more than one function i.e. they are multiplexed with different functions. For example, Pin 19 of the LPC2148 has three functions namely P0.0, a general purpose I/O pin, TXD0, the transmitter O/P for UART0 and PWM1, the pulse width modulator O/P 1. At any point of operation, each pin can have a single function At any point of operation, each pin can have a single function and the function can be selected with the help of three Configuration Registers which control the multiplexers to allow connection between the external pin and the on-chip peripheral. The configuration register is called PINSEL classified in to three registers: PINSEL0, PINSEL1 and PINSEL2 These configuration registers are of 32-bit wide Any pin on the LPC2148 can have a maximum of 4 functions. Hence in order to select one of the four functions, two corresponding bits of the PINSEL register are needed. For example: pins 13, 14, 15 of LPC2148 Any pin on the LPC2148 can have a maximum of 4 functions. Hence in order to select one of the four functions, two corresponding bits of the PINSEL register are needed. For example: pins 13, 14, 15 of LPC2148 So, a 32-bit PINSEL register can control 16 pins with 2-bits to control each pin. PINSEL0 controls PORT0 pins P0.0 to P0.15, PINSEL1 controls PORT0 pins P0.16 to P0.31 and PINSEL2 controls PORT1 pins P1.16 to P1.31. The default function of all the Pins is GPIO. But it is a good programming practice to mention “PINSEL0=0” in order to select the GPIO function of the Pins. GPIO function is the most frequently used functionality of the microcontroller. The GPIO function in both the Ports are controlled by a set of 4 registers: a) IOPIN, b) IODIR, c) IOSET and d) IOCLR. IOPIN: It is a GPIO Port Pin Value register and can be used to read or write values directly to the pin. The status of the Pins that are configured as GPIO can always be read from this register irrespective of the direction set on the pin (Input or Output) The syntax for this register is IOxPIN, where ‘x’ is the port number i.e. IO0PIN for PORT0 and IO1PIN for PORT1. An important note to remember is that since the LPC2148 is a 32-bit microcontroller, the length of all the registers mentioned is also 32-bits. Each bit in the above mentioned registers is directly linked to the corresponding pin in the microcontroller i.e. bit ‘a’ in IO0SET corresponds to Pin ‘a’ in the PORT0. Registers in LPC2148 follow Big Endian format i.e. bit 0 is the LSB on the extreme right of the register and bit 31 is the MSB on the extreme left of the register. Another important note is that when reset, all the pins are set as GPIO pins and the direction of each pin is set as Input. Now, we’ll see how to use the above mentioned registers in programming. First, is to set the direction of a pin. For example, if we want to set 4th pin of PORT0 i.e. P0.3 as output, then it can be set in various ways as shown below. Method 1: IO0DIR = (1