Example 2: An Immediate Output Of 0S And 1S On A Gpio Port; Writing To Ioset/Ioclr Vs. Iopin; Output Signal Frequency Considerations When Using The Legacy And Enhanced Gpio Registers; Koninklijke Philips Electronics N.v. 2006. All Rights Reserved - Philips LPC2101 User Manual

Table of Contents

Advertisement

Philips Semiconductors
Volume 1

8.5.2 Example 2: an immediate output of 0s and 1s on a GPIO port

Write access to port's IOSET followed by write to the IOCLR register results with pins
outputting 0s being slightly later then pins outputting 1s. There are systems that can
tolerate this delay of a valid output, but for some applications simultaneous output of a
binary content (mixed 0s and 1s) within a group of pins on a single GPIO port is required.
This can be accomplished by writing to the port's IOPIN register.
The following code will preserve existing output on PORT0 pins P0.[31:16] and P0.[7:0]
and at the same time set P0.[15:8] to 0xA5, regardless of the previous value of pins
P0.[15:8]:
IO0PIN = (IO0PIN && 0xFFFF00FF) || 0x0000A500
The same outcome can be obtained using the fast port access.
Solution 1: using 32-bit (word) accessible fast GPIO registers
FIO0MASK = 0xFFFF00FF;
FIO0PIN = 0x0000A500;
Solution 2: using 16-bit (half-word) accessible fast GPIO registers
FIO0MASKL = 0x00FF;
FIO0PINL = 0xA500;
Solution 3: using 8-bit (byte) accessible fast GPIO registers
FIO0PIN1 = 0xA5;

8.5.3 Writing to IOSET/IOCLR vs. IOPIN

Write to the IOSET/IOCLR register allows easy change of the port's selected output pin(s)
to HIGH/LOW level at a time. Only pin/bit(s) in the IOSET/IOCLR written with 1 will be set
to HIGH/LOW level, while those written as 0 will remain unaffected. However, by just
writing to either IOSET or IOCLR register it is not possible to instantaneously output
arbitrary binary data containing mixture of 0s and 1s on a GPIO port.
Write to the IOPIN register enables instantaneous output of a desired content on the
parallel GPIO. Binary data written into the IOPIN register will affect all output configured
pins of that parallel port: 0s in the IOPIN will produce LOW level pin outputs and 1s in
IOPIN will produce HIGH level pin outputs. In order to change output of only a group of
port's pins, application must logically AND readout from the IOPIN with mask containing
0s in bits corresponding to pins that will be changed, and 1s for all others. Finally, this
result has to be logically ORred with the desired content and stored back into the IOPIN
register. Example 2 from above illustrates output of 0xA5 on PORT0 pins 15 to 8 while
preserving all other PORT0 output pins as they were before.
8.5.4 Output signal frequency considerations when using the legacy and
enhanced GPIO registers
The enhanced features of the fast GPIO ports available on this microcontroller make
GPIO pins more responsive to the code that has task of controlling them. In particular,
software access to a GPIO pin is 3.5 times faster via the fast GPIO registers than it is
when the legacy set of registers is used. As a result of the access speed increase, the
User manual
Rev. 01 — 12 January 2006
UM10161
Chapter 8: GPIO
© Koninklijke Philips Electronics N.V. 2006. All rights reserved.
79

Advertisement

Table of Contents
loading

This manual is also suitable for:

Lpc2103Lpc2102

Table of Contents