Port pins in quasi-bidirectional output mode function similar to the standard 8051 port pins. A
quasi-bidirectional port can be used as an input and output without the need to reconfigure the
port. This is possible because when the port outputs logic high, it is weakly driven, allowing an
external device to pull the pin low. When the pin outputs low, it is driven strongly and able to
sink a large current. There are three pull-up transistors in the quasi-bidirectional output that
serve different purposes.
One of these pull-ups, called the “very weak” pull-up, is turned on whenever the port register
for the pin contains a logic “1”. This very weak pull-up sources a very small current that will
pull the pin high if it is left floating.
A second pull-up, called the “weak” pull-up, is turned on when the port register for the pin
contains a logic “1” and the pin itself is also at a logic “1” level. This pull-up provides the
primary source current for a quasi-bidirectional pin that is outputting a ‘1’. If this pin is pulled
low by the external device, this weak pull-up turns off, and only the very weak pull-up remains
on. In order to pull the pin low under these conditions, the external device has to sink enough
current to over-power the weak pull-up and pull the port pin below its input threshold voltage.
The third pull-up is referred to as the “strong” pull-up. This pull-up is used to speed up
low-to-high transitions on a quasi-bidirectional port pin when the port register changes from a
logic “0” to a logic “1”. When this occurs, the strong pull-up turns on for two CPU clocks,
quickly pulling the port pin high.
VDDVDDVDD
2 clocks
delay
StrongVery weak
Port latch data
Weak
Port pin
Input data
STC12C5Axx Technical Summary 19
http://www.DataSheet4U.net/
datasheet pdf - http://www.DataSheet4U.net/
Open-drain Output
The open-drain output configuration turns off all pull-ups and only drives the pull-down
transistor of the port pin when the port register contains logic “0”. To use this configuration in
application, a port pin must have an external pull-up, typically tied to VDD. The input path of
the port pin in this configuration is the same as quasi-bidirection mode.
Port pin
Port latch data
Input data
Input-only Mode
The input-only configuration is a Schmitt-triggered input without any pull-up resistors on the
pin.
Input data
Port pin
Push-pull Output
The push-pull output configuration has the same pull-down structure as both the open-drain
and the quasi-bidirectional output modes, but provides a continuous strong pull-up when the
port register contains a logic “1”. The push-pull mode may be used when more source current
is needed from a port output.
VDD
Port latch data
Port pin
Input data
20 STC12C5Axx Technical Summary
Timer/Counter
http://www.DataSheet4U.net/
datasheet pdf - http://www.DataSheet4U.net/
STC12C5Axx has two 16-bit timers, and they are named T0 and T1. Each of them can also
be used as a general event counter, which counts the transition from 1 to 0.
Since the STC12C5Axx is a RISC-like MCU which execute faster than traditional 80C51 MCU
from other providers. Based on consideration of compatibility with traditional 80C51 MCUs,
the frequency of the clock source for T0 and T1 is designed to be selectable between
oscillator frequency divided-by-12 (default) or oscillator frequency.
The user can configure T0/T1 to work under mode-0, mode-1, mode-2 and mode-3. It is fully
the same to a traditional 80C51 MCU.
There are two SFR designed to configure timers T0 and T1. They are TMOD, TCON.
The user also should take a glace of SFR AUXR which decide the frequency of the clock
source driving the T0 and T1.
SFR:
TMOD(Timer Mode Control Register)
Read/Write Address: 0X89H
Default: 0000-0000
Bit 7 6 5 4 3 2 1 0
Name
GATE: = Gating control
C//T: = Timer or Counter function selector. 0: =timer, 1: =counter
{M1, M0}: mode select
GATE
0: = (default)
Timer x is enabled whenever “TRx” control bit is set.
1: =
Timer/Counter x is enabled only while “/INTx” pin is high and “TRx” control bit is set.
0: = (default)
Configure Tx as Timer use
1: =
Configure Tx as Counter use
{0, 0}: =
Configure Tx as 13-bit timer/counter
{0, 1}: =
Configure Tx as 16-bit timer/counter
{1, 0}: =
Configure Tx as 8-bit timer/counter with automatic reload capability
{1, 1}: =
for T0, set TL0 as 8-bit timer/counter, TH0 is locked into 8-bit timer
for T1, set Timer/Counter1 Stopped
For Timer-1 Only For Timer-0 Only
C//T
M1 M0 GATE
C//T
M1 M0
STC12C5Axx Technical Summary 21
http://www.DataSheet4U.net/
datasheet pdf - http://www.DataSheet4U.net/
SFR:
TCON
Read/Write Address: 0X88H
Default: 0000-0000
Bit 7 6 5 4 3 2 1 0
Name
TF1 TR1 TF0 TR0 IE1 IT1 IE01 IT0
TF1: = Timer1 overflow flag.
This bit is automatically set by hardware on T1 overflow, and will be automatically cleared by
hardware when the processor vectors to the interrupt routine.
TR1: = Timer1 run control bit.
0: = (default)
Stop T1 counting
1: =
Start T1 counting
TF0: = Timer0 overflow flag.
This bit is automatically set by hardware on T0 overflow, and will be automatically cleared by
hardware when the processor vectors to the interrupt routine.
TR0: = Timer0 run control bit.
0: = (default)
Stop T0 counting
1: =
Start T0 counting
IE1: = External Interrupt-1 flag.
This bit is automatically set by hardware on interrupt from the external interrupt-1, and will be
automatically cleared by hardware when the processor vectors to the interrupt routine.
IT1: = Interrupt-1 type control bit.
0: = (default)
Set the interrupt-1 triggered by low duty from pin EX1
1: =
Set the interrupt-1 triggered by negative falling edge from pin EX1
IE0: = External Interrupt-0 flag.
This bit is automatically set by hardware on interrupt from the external interrupt-0, and will be
automatically cleared by hardware when the processor vectors to the interrupt routine.
IT0: = Interrupt-0 type control bit.
0: = (default)
Set the interrupt-0 triggered by low duty from pin EX1
1: =
Set the interrupt-0 triggered by negative falling edge from pin EX1
Set the frequency of the clock source for T0 as the oscillator frequency divided-by-12.
It will compatible to the traditional 80C51 MCU.
1: =
Set the frequency of the clock source for T0 as the oscillator frequency.
It will drive the T0 faster than a traditional 80C51 MCU.
T1X12: = T1 clock source selector
0: = (default)
Set the frequency of the clock source for T1 as the oscillator frequency divided-by-12.
It will compatible to the traditional 80C51 MCU.
1: =
Set the frequency of the clock source for T1 as the oscillator frequency.
It will drive the T1 faster than a traditional 80C51 MCU.
UARTM0X6: = Baud rate selector of UART while it is working under Mode-0
0: = (default)
Set the baud rate of the UART functional block as oscillator frequency divided-by-12.
It will compatible to the traditional 80C51 MCU.
1: =
Set the baud rate of the UART functional block as oscillator frequency divided-by-2.
It will transmit/receive data faster than a traditional 80C51 MCU.
BRTR: = Setting this bit will enable the baud-rate generator of UART2 to run.
S2SMOD: = Setting this bit can double up the baud-rate of UART2.
BRTRX12: = Set this bit to set the clock source for the UART2 is BRT, or clear it to set the clock
source for or the UART2 as BRT/12.
S1BRS: = S1 Baud-Rate clock source selector
0: = (default)
Select timer-1 for baud-rate clock source to S1
1: =
Select BRT for baud-rate clock source to S1
STC12C5Axx Technical Summary 23
x
/
/
http://www.DataSheet4U.net/
datasheet pdf - http://www.DataSheet4U.net/
Mode 0
The timer register is configured as a 13-bit register. As the count rolls over from all 1s to all 0s,
it sets the timer interrupt flag TFx. The counted input is enabled to the timer when TRx = 1
and either GATE=0 or INTx = 1. Mode 0 operation is the same for Timer0 and Timer1.
OSC/12
OSC
AUXR.x
0
1
T0 or T1 pin
(sampled)
C
GATE
/INTx
0
1
T
TR
0
1
TLx[4:0] THx[7:0]
TFx
Mode 1
Mode1 is the same as Mode0, except that the timer register is being run with all 16 bits.
OSC/12
OSC
AUXR.x
0
1
T0 or T1 pin
(sampled)
0
1
0
1
TLx[7:0] THx[7:0]
TFx
Interrupt
Interrupt
GATE
/INTx
Mode 2
Mode 2 configures the timer register as an 8-bit counter (TLx) with automatic reload. Overflow
from TLx does not only set TFx, but also reloads TLx with the content of THx, which is
determined by user’s program. The reload leaves THx unchanged. Mode 2 operation is the
same for Timer0 and Timer1.
OSC/12
OSC
AUXR.x
0
1
T0 or T1 pin
(sampled)
GATE
/INTx
0
1
0
1
TLx [7:0]
THx [7:0]
Reload
TFx
Interrupt
24 STC12C5Axx Technical Summary
Loading...
+ 54 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.