Escolar Documentos
Profissional Documentos
Cultura Documentos
C8051F020
Enhanced 8051
# cycles (acc) x 4
Execution time = # cycles x (T)
With 22.1184 MHz External Osc. With 2 MHz Internal Osc.
T = 45.211 ns T = 0.5 s
Execution time = (acc) x (180.8 ns) Execution time = (acc) x (2 s)
Timer0
Timer clock selects
Timer4
0 = system clock 12 (for compatibility
with original 8051,
and for slow stuff)
1 = system clock
Timer 1 Timer 0
GATEn: 0 = timer enabled with TR only
1 = timer enables with TR and \INT
(mode 1
8 bits)
address
data
CPU Memory
control
“external” RAM
Can add MORE
accessed with
memory
movx instruction
Interfaced using
External Data
Memory Bus
Prof. Cherrice Traver ECE/CS-352: Embedded Microcontroller Systems
Memory Expansion
Can add more external RAM
port 4 implements
control lines
ports 5 and 6
implement
address bus
port 7 implements
data bus
Analog Signal
ideal
actual
2R analog output
4 Q2 Rout
4R
Q1
1111
Q0 8R
1100
1000
0100
0000
4 R 1111
2R
Q2 1100
R
2R
Q1 1000
2R R
Q0 0100
2R
0000
When
disabled,
output is high
impedance
Data registers
12 bit digital value
Prof. Cherrice Traver ECE/CS-352: Embedded Microcontroller Systems
DAC0CN: DAC Control Register
Example: Vref = 3V
3V V Range = 0 to (3V-732.6 V)
= 732.6
4095 levels level
0 to 2.999267
• Can be the
internal
reference
voltage VREF
(2.4V)
V Digital value
01111110
01111100
11101110
11111110
01110000
10110000
10111110
01111110
11111110
time time
Analog A/D
Converter Digital (8-bit)
GND
DAC
DAC
n
• ADC1
– 8-bit SAR
– 500ksps
+
V
-
V can be positive or negative
AMX0CF
Bit2-Bit0:
Internal Amplifier Gain
000: Gain = 1
001: Gain = 2
010: Gain = 4
011: Gain = 8
10x: Gain = 16
11x: Gain = 0.5
ADC0CF
ADC0CN
Bit3-2: ADC0 Start of Conversion Mode Select.
If AD0TM = 0 (tracking mode on:
00: ADC0 conversion initiated on every write of ‘1’ to AD0BUSY.
01: ADC0 conversion initiated on overflow of Timer 3.
10: ADC0 conversion initiated on rising edge of external CNVSTR.
11: ADC0 conversion initiated on overflow of Timer 2.
If AD0TM = 1: Same as above except conversion takes 3 SAR clock cycles longer
2.0V
AD0WInt = 1
Control registers
similar to
ADC0, but
simpler
Bypass
crossbar
• Clock sources:
– External oscillator 8 (allows for real-time clock input for timed applications)
– Sysclk or Sysclk 12 (like all other timers)
• Always 16-bit, auto-reload.
– Write “reload” value to TMR3RLH : TMR3RLL
– Defines the time between overflows
• Can be used to start ADC conversion
• Can be used for SMBbus timing
0000
FFFF
07D0h counts
…
F830 Auto-reload value = 0000 - 07D0 = F830h
…
= - 07D0h
0000
or
Interrupt on
Capture occurs on
overflow or on
edge of T2EX when Capture register capture when
EXEN2 enables it.
enabled
Prof. Cherrice Traver ECE/CS-352: Embedded Microcontroller Systems
Capture Mode to Measure Intervals
1 2
8051
TEX2
time interval
RCAP2 Timer2 value, RCAP2 Timer2 value,
EXF2 flag goes high, EXF2 flag goes high,
Timer2 interrupt generated if Timer2 interrupt generated if
enabled enabled
If time interval is less than FFFF counts, then ISR can just
subtract captured value 2 from captured value 1 to find time
interval. Otherwise ISR must also keep track of overflows.
Prof. Cherrice Traver ECE/CS-352: Embedded Microcontroller Systems
Programmable Counter Array
• The ultimate timer/counter!
– SIX different possible clock sources
– SIX modes of operation
• Capture modes (with 3 edge options)
• Software timer (Compare) mode (interrupt when timer register
= compare register)
• High speed output : (output pin is toggled when timer register
= compare register)
• Frequency output: (square wave produced at a specified
frequency)
• 8-bit Pulse-Width-Modulation mode
• 16-bit Pulse-Width-Modulation mode
T
“Average” value of signal is
Duty Cycle = Tp proportional to duty cycle.
T
Pulse width modulation means varying the duty cycle.
(256 PCA0CPHn)
DutyCycle
256
(65536 PCA0CPn)
DutyCycle
65536