2.4 I/o Ports and Crossbar
The standard 8051 Ports (0, 1, 2, and 3) are available on the C8051F020, as well as 4 additional ports (4, 5, 6, and 7) for a total of 64 general purpose port I/O pins. The port I/O behaves like the standard 8051 with a few enhancements. Access is possible through reading and writing the corresponding Port Data registers.
C8051F020 All port pins are 5 V tolerant, and support configurable Push-Pull or 64 general Open-Drain output modes and weak pull-ups.
2.4 I/o Ports and Crossbar
The standard 8051 Ports (0, 1, 2, and 3) are available on the C8051F020, as well as 4 additional ports (4, 5, 6, and 7) for a total of 64 general purpose port I/O pins. The port I/O behaves like the standard 8051 with a few enhancements. Access is possible through reading and writing the corresponding Port Data registers.
All port pins are 5 V tolerant, and support configurable Push-Pull or Open-Drain output modes and weak pull-ups. In addition, the pins on Port 1 can be used as Analog Inputs to ADC1.
The four lower ports (P0-P3) can be used as General-Purpose I/O (GPIO) pins or be assigned as inputs/outputs for the digital peripherals by programming a Digital Crossbar (Figure 2.6). The lower ports are both bit- and byte-addressable. The four upper ports (P4-P7) serve as byte-addressable GPIO pins.
The Digital Crossbar is essentially a large digital switching network that allows mapping of internal digital peripherals to the pins on Ports 0 to 3. The on-chip counter/timers, serial buses, HW interrupts, ADC Start of Conversion input, comparator outputs, and other digital signals in the controller can be configured to appear on the I/O pins by configuring the Crossbar Control registers XBRO, XBR1 and XBR2. This allows the system designer to select the exact mix of GPIO and digital resources needed for the particular application, limited only by the number of pins available. Unlike microcontrollers with standard multiplexed digital I/O, all combinations of functions are supported.
The digital peripherals are assigned Port pins in a priority order, starting with PO.O and continue through P3.7 if necessary. UARTO has the highest priority and CNVSTR has the lowest priority (refer to Chapter 5 for examples on configuring the crossbar).
12-Bit Analog to Digital Converter
The C8051F020 has an on-chip 12-bit successive approximation register (SAR) Analog to Digital Converter (ADCO) with a 9-channel input multiplexer and programmable gain amplifier (Figure 2.7). A voltage reference is required for ADCO to operate and is selected between the DACO output and an external VREF pin.
The ADC is configured via its associated Special Function Registers. One input channel is tied to an internal temperature sensor, while the other eight channels are available externally. Each pair of the eight external input channels can be setup as either two single-ended inputs or a single differential input.
A programmable gain amplifier follows the analog multiplexer. The gain can be set in software from 0.5 to 16 in powers of 2. The gain stage is useful when different ADC input channels have widely varied input voltage signals, or when "zooming in" on a signal with a large DC offset (in differential mode, a DAC could be used to provide the DC offset).
Conversions can be started in four ways:
1) Software command,
2) Overflow of Timer 2,
3) Overflow of Timer 3, or
4) External signal input (CNVSTR).
Conversion completions are indicated by a status bit and an interrupt (if enabled). The resulting 12 bit data word is latched into two SFRs upon completion of a conversion. The data can be right or left justified in these registers (since ADC output is 12 bits but the two SFRs are 16 bits) under software control.
T
he
Window Compare registers for the ADC data can be configured to
interrupt the controller when ADC data is within or outside of a
specified range. The ADC can monitor a key voltage continuously in
background mode, but not interrupt the controller unless the
converted data is within the specified window.
8-Bit Analog to Digital Converter
The C8051F020 has an on-board 8-bit SAR Analog to Digital Converter (ADC1) with an 8-channel input multiplexer and programmable gain amplifier (Figure 2.8). Eight input pins are available for measurement. The ADC is again configurable via the SFRs. The ADC1 voltage reference is selected between the analog power supply (AV+) and an external VREF pin.
A programmable gain amplifier follows the analog multiplexer. The gain can be set in software to 0.5, 1, 2, or 4. Just as with ADCO, the conversion scheduling system allows ADC1 conversions to be initiated by software commands, timer overflows or an external input signal. ADC1 conversions may also be synchronized with ADCO software-commanded conversions. Conversion completions are indicated by a status bit and an interrupt (if enabled), and the resulting 8 bit data word is latched into a SFR upon completion.
