Introduction To ARM7

This generation introduced the Thumb 16-bit instruction set providing improved code density compared to previous designs. The most widely used ARM7 designs implement the ARMv4T architecture, but some implement ARMv3 or ARMv5TEJ. All these designs use a Von Neumann architecture, thus the few versions comprising a cache do not separate data and instruction caches.

ARM ARCHITECTURE

In this section we will start programming LPC2138 with the brief introduction we had in the previous section. As described earlier in order to start programming LPC 2138 programming, we will start with the architecture of LPC 2138 first and then proceed with the GPIO pins.

ABOUT GPIO

General-purpose input/output (GPIO) is a generic pin on an integrated circuit whose behavior, including whether it is an input or output pin, can be controlled by the user at run time.

ARM

ARM is a family of instruction set architectures for computer processors based on a reduced instruction set computing (RISC) architecture developed by British company ARM Holdings..

mobile computing

A CPU chip is designed for portable computers, it is typically housed in a smaller chip package, but more importantly, in order to run cooler, it uses lower voltages than its desktop counterpart and has more "sleep mode" capability. A mobile processor can be throttled down to different power levels or sections of the chip can be turned off entirely when not in use. Further, the clock frequency may be stepped down under low processor loads. This stepping down conserves power and prolongs battery life..

ARM 7

ARM is the industry's leading supplier of microprocessor technology, offering the widest range of microprocessor cores to address the performance, power and cost requirements for almost all application markets.
Showing posts with label GPIO. Show all posts
Showing posts with label GPIO. Show all posts

Wednesday, 3 December 2014

GPIO

GPIO Configurations for basic programming for ARM lpc2148


ARM 7 has two ports named as PORT0 and PORT1
Each port can be used as an output/input Port.

Basically
  • ·        PORT0 has pins PORT0 has 0 to 031 pins
  • ·        PORT1 has 16 to 031 pins.

Each Port can be used as GPIO (General Purpose input and output) or as SFR (Special Function Register).

We need Five registers to program ARM7 for GPIO Programming
  • ·        PINSELx
To use it as GPIO we have to set some register.
PINSEL0 it must be 0 to use LSB of port 0 as GPIO(0 -15)
PINSEL1 it must be 0 to use MSB of port 0 as GPIO(16-31)
PINSEL2 it must be 0 to use Port 1 as GPIO(16-31)


For example to set the PORT0 as GPIO port
We set this by PINSELO=0x00000000;
For example to set the 0th pin of PORTO as an UART0 Transmitter
WE set this by PINSELO=0x00000001;

  • IODIRx
GPIO Port Direction control register.
This register individually controls the direction of each port pin.
This word accessible register is used to control the direction of the pins when they are Configured as GPIO port pins.

Direction bit for any pin must be set according to the pin functionality.
 0-controlled PIN is INPUT
1-controlled PIN is OUTPUT

IODIRx=0x00000000;
For example if we want to set the PORT0 PINS (0-3) as output ports/individual pins as output.
We set by this IODIR0=0x0000000F; / by this the four pins 0-3 directed to be as output.
If we want to set the PORT0 pins (4-7) as input ports/individual pins as input.
We set bt this IODIR0=0xFFFFFF0F; / by this the four pins 4-7 directed to be as input.

  • IOSETx

This register is used to produce a HIGH level output at the port pins configured as GPIO in an OUTPUT mode.
GPIO Port Output Set register.
This register controls the state of output pins in conjunction with the IOCLR register.
Writing ones produces highs at the corresponding port pins. Writing zeroes has no effect.

If any pin is configured as an input or a secondary function, writing 1 to the corresponding bit in the IOSET has no effect.

When any of the PORT pins used in OUTPUT mode and to make HIGH/Enable the particular PORT pins we use this IOSET register.

If we directed the PORT0 pins (0-3) as output mode / IODIR0=0x0000000F;
And now we want to enable/high the particular pins of that PORT0 we use the IOSETO register as follows
           IOSET0=0x0000000F;/ we enable the pins (0-3) of PORT0

  • IOCLRx

This register is used to produce a LOW level output at port pins configured as GPIO in an OUTPUT mode.
GPIO Port Output Clear register.
This register controls the state of output pins.
Writing ones produces lows at the corresponding port pins and clears the corresponding bits in the IOSET register.

Writing zeroes has no effect.

When any of the PORT pins used in OUTPUT mode and to make LOW/Disable the particular PORT pins we use this IOCLR register.

If we directed the PORT0 pins (0-3) as output mode / IODIR0=0x0000000F;
And now we want to Disable/Low the particular pins of that PORT0 we use the IOCLR register as follows
            IOCLR0=0x0000000F;/ we Disable the pins (0-3) of PORT0

 IO0SET=0x00000001;     //it means 0th bit of Port 0 will be set
 IO0CLR=0x00000001;    //it means 0th bit of Port 0 will be cleared

  • IOPINx

 GPIO Port Pin value register.

This register provides the value of port pins that are configured to perform only digital functions.

The register will give the logic value of the pin regardless of whether the pin is configured for input or output, or as GPIO or an alternate digital function.

The current state of the GPIO configured port pins can always be read from this register, regardless of pin direction.

As an example,
A particular port pin may have GPIO input, GPIO output, UART receive, and PWM output as selectable functions. Any configuration of that pin will allow its current logic state to be read from the IOPIN register.

Writing to the IOPIN register stores the value in the port output register, bypassing the need to use both the IOSET and IOCLR registers to obtain the entire written value.
This feature should be used carefully in an application since it affects the entire port.
                       
if((0x00010000&IO1PIN)==0x00000000)

The above statement will execute when the status of PORT1 and given data string    equal to zero.
i.e. the status of PORT1 can be checked by using IOPINx Instruction