The SST89E5xxRD2 and SST89V5xxRD2 are mem bers
of the FlashFlex51 family of 8-bit microcontroller products
designed and m anufactured with SST’s patented and proprietary SuperFlash CMOS semiconductor process technology. The split-gate cell design a nd thick-oxide tunn elin g
injector offer significant cost and reliability benefits for SST’s
customers. The device s use the 8051 ins truction set and
are pin-for-pin compatible with standard 8051 microcontroller devices .
The devices come with 16/24/40/72 KByte of on-chip flash
EEPROM program memory which is partitioned into 2
independent program memory blocks. The primary Block 0
occupies 8/16/32/64 KByte of internal program memory
space and the secondary Block 1 occupies 8 KByte of
internal program memory space.
The 8-KByte seco ndary bloc k can be map ped to the lowest
location of th e 8/16 /32 /64 KB yte addr ess spac e; i t can a lso
be hidden from the program counter and used as an independent EEPROM-like data memory.
The SST logo, SuperFlash, and FlashFlex are registered trademarks of Silicon Storage Technology, Inc.
In addition to the 16/24/ 40 /72 KByte of EE PROM program
memory on- chip, the devices can addre ss up to 64 KByte
of external program memor y. In addition to 1024 x8 bits of
on-chip RAM, up to 64 KByte of external RAM can be
addressed.
The flash memor y blocks can be programmed via a sta ndard 87C5x OTP EPROM programmer fitted with a special
adapter and the firmware for SST’s devices. During poweron reset, the devices can be configured as either a slave to
an external host for source code storage or a master to an
external host for an in- appli ca tion prog r amm ing (I AP) oper ation. The devices are designed to be programmed in-system and in-application on the printed circuit board for
maximum flexibility. The devices are pre-programmed wit h
an example of the bootstrap loader in the memory , demonstrating the initial user program code loading or subsequent
user code updating via the IAP operation. The sample
bootstrap loader is available for the user’s reference and
convenience only; SST does not guarantee its functionality
or usefulness. Chip-Erase or Block-Erase operations will
erase the pr e-pro gra mmed sa mple code .
These specifications are subject to change without notice.
sink several LS TTL inputs. Port 0 pins float that have ‘1’s written to them, and in this state
can be used as high-imped ance inputs . P ort 0 is also the multi ple x ed low -order addres s and
data bus during accesse s to e xte rnal memory. In this applic ation, it uses stro ng internal pull ups when transitioning to V
mode programming, and outputs the code bytes during the external host mode verification.
External pull-ups are required during program verification.
Port 1: Port 1 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 1 output buffers can drive LS TTL inputs. Port 1 pins are pulled high by the internal pull-ups when “1”s
are written to them and can be used as inputs in this state. As inputs, Port 1 pins that are
externally pulled low will source current because of the internal pull-ups. P1[5, 6, 7] have
high current drive of 16 mA. Port 1 also receives the low-order address bytes during the
external host mode programming and verification.
This signal is the external clock input for the PCA timer/counter.
Each compare/capture module connects to a Port 1 pin for external I/O. When not used by
the PCA, this pin can handle standard I/O.
OR
CEX1: Compare/Capture Module External I/O
OR
CEX2: Compare/Capture Module External I/O
OR
CEX3: Compare/Capture Module External I/O
OR
CEX4: Compare/Capture Module External I/O
Port 2: Port 2 is an 8-bit bi-directional I/O port with internal pull-ups. Port 2 pins are pulled
high by the in ternal pul l-up s when “1”s are written to them an d c an be used as inputs in th is
state. As inputs , Port 2 pins that are ex ternally pulled low will s ource c urre nt because of the
internal pull-ups. Port 2 sends the high-ord er ad dre ss byte during fetch es from external Program memory and during accesses to external Data Memory that use 16-bit address
(MOVX@DPTR). In this application, it uses strong internal pull-ups when transitioning to
. Port 2 also receives some control signals and a partial of high-order address bits dur-
V
OH
ing the external host mode programming and verification.
Port 3: Port 3 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 3 output buff-
ers can drive LS TTL inputs. Port 3 pins are pulled high by the internal pull-ups when “1”s
are written to them and can be used as inputs in this state. As inputs, Port 3 pins that are
externally pulled low will source current because of the internal pull-ups. Port 3 also
receives some control signals and a partial of high-order address bits during the external
host mode programming and verification.
Port 0 also receives the code bytes during the external host
OH.
SymbolType
P0[7:0]I/OPort 0: Port 0 is an 8-bit open drain bi-directional I/O port. As an output port each pin can
P1[7:0]I/O with internal
P1[0]I/OT2: External count input to Timer/Counter 2 or Clock-out from Timer/Counter 2
P1[1]IT2EX: Timer/Counter 2 capture/reload trigger and direction control
P1[2]IECI: PCA Timer/Counter External Input:
P1[3]I/OCEX0: Compare/Capture Module External I/O
P1[4]I/OSS#: Master Input or Slave Output for SPI.
P1[5]I/OMOSI: Master Output line, Slave Input line for SPI
P1[6]I/OMISO: Master Input line, Slave Output line for SPI
P1[7]I/OSCK: Master clock output, slave clock input line for SPI
P3[3]IINT1#: External Interrupt 1 Input
P3[4]IT0: External count input to Timer/Counter 0
P3[5]IT1: External count input to Timer/Counter 1
P3[6]OWR#: External Data Memory Write strobe
P3[7]ORD#: External Data Memory Read strobe
PSEN#I/OProgram Store Enable: PSEN# is the Read strobe to External Program Store. When the
RSTIReset: While the oscillator is running, a high logic state on this pin for two machine cycles
EA#IExternal Access Enable: EA# must be driven to V
ALE/PROG#I/OAddress Latch Enable: ALE is the output signal for latching the low byte of the address
5
P4[3:0]
I/O with internal
P4[0]I/OBit 0 of port 4
P4[1]I/OBit 1 of port 4
P4[2] / INT3#I/OBit 2 of port 4 / INT3# External interrupt 3 input
P4[3] / INT2#I/OBit 3 of port 4 / INT2# External interrupt 2 input
XTAL1ICrystal 1: Input to the inverting oscillator amplifier and input to the internal clock generator
XTAL2OCrystal 2: Output from the inverting oscillator amplifier
V
DD
V
SS
1. I = Input; O = Output
2. It is not necessary to receive a 12V programming supply voltage during flash programming.
3. ALE loading issue: When ALE pin experiences higher loading (>30pf) during the reset, the MCU may accidentally enter into modes
other than normal working mode. The solution is to add a pull-up resistor of 3-50 KΩ to V
4. For 6 clock mode, ALE is emitted at 1/3 of crystal frequency.
5. Port 4 is not present on the PDIP package.
1
Name and Functions
device is executing from Internal Program Memory, PSEN# is inactive (VOH). When the
device is executing code from External Program Memory, PSEN# is activated twice each
machine cycle, except when access to External Data Memory while one PSEN# activation
is skipped in each machine cycle. A forced high-to-low input transition on the PSEN# pin
while the RST input is co ntinually held high for more than ten machine cycles will cause the
device to enter External Host mode for programming.
will reset the device . After a reset, if the PSEN# pin is driv en by a high-to-lo w input trans ition
while the RST input pi n is he ld hig h, the device will ent er th e External Ho st mode , o therwi se
the device will enter the Normal operation mode.
code from the External Program Memory. EA# must be driven to V
execution. However, Security lock level 4 will disable EA#, and program execution is only
possible from internal program memory. The EA# pin can tolerate a high voltage2 of 12V.
during an access to external memory. This pin is also the programming pulse input
(PROG#) for flash prog r a mm in g. No rmally the ALE3 is emitted at a constant rate of 1/6 the
crystal frequency
skipped during each access to external data memory. However, if AO is set to 1, ALE is disabled.
Port 4: Port 4 is an 4-bit bi-directional I/O port with internal pull-ups. The port 4 output buff-
pull-ups
ers can drive LS T TL inputs . P ort 4 pins are p ulled hig h by the internal pull -ups when ‘ 1’ s are
written to them and can be used as inputs in this state. As inputs, port 4 pins that are externally pulled low will source current because of the internal pull-ups.
circuits.
IPower Suppl y
IGround
in order to enable the device to fetch
IL
4
and can be used for external timing and clocking. One ALE pulse is
The device has separate addr e ss s pa ce s for program an d
data memory.
3.1 Program Flash Memory
There are two internal flash memory blocks in the device.
The primar y flash memor y block (Block 0) has 8/16/3 2/64
KByte. The secondary flash memory block (Block 1) has 8
KByte. Since the total program address space is limited to
64 KByte, the SF CF[1:0] bit are used to control pro gram
EA# = 1
SFCF[1:0] = 00
E000H
8 KByte
Block 1
FFFFH
EA# = 0
FFFFH
DFFFH
bank selectio n. Pleas e re fer to Figur es 3-1 t hrou gh 3- 4 for
the program memor y configuration. Program bank sele ction is described in the next section.
The 8K/16K/32K/64K x8 primary SuperFlash block is organized as 64/128/256/51 2 sectors, each sector consists of
128 Bytes.
The 8K x8 secondary SuperFlash block is organized as 64
sectors, each sector consists also of 128 Bytes.
For both blocks, the 7 least significant program address bits
select the byte within the sector. The remainder of the program addr ess bi ts selec t the sect or with in the bloc k.
FIGURE3-4: PROGRAM MEMORY ORGANIZATIONFOR 64 KBYTE SST89E/V516RD2
3.2 Program Memory Block Switching
The program memory block switching feature of the device allows either Block 1 or the lowest 8 KByte of Block 0 to be
used for the lowest 8 KByte of the program address space. SFCF[1:0] controls program memory block switching.
TABLE3-1: SFCF VALUESFOR PROGRAM MEMORY BLOCK SWITCHINGFOR SST8 9E/V5 16RD2
SFCF[1:0]Program Memory Block Switching
01, 10, 11Block 1 is not visible to the program counter (PC).
Block 1 is reachable only via in-application programming from 0000H - 1FFFH.
00Block 1 is overlaid onto the low 8K of the program address space; occupying address locations 0000H - 1FFFH.
When the PC falls within 0000H - 1FFFH, the instruction will be fetched from Block 1 instead of Block 0.
Outside of 0000H - 1FFFH, Block 0 is used. Locations 0000H - 1FFFH of Block 0 are reachable through
in-application programming.
T3-1.0 1255
TABLE3-2: SFCF VALUESFOR PROGRAM MEMORY BLOCK SWITCHINGFOR SST8 9E/V5 XRD2
SFCF[1:0]Program Memory Block Switching
10, 11Block 1 is not visible to the PC;
Block 1 is reachable only via in-application programming from E000H - FFFFH.
01Both Block 0 and Block 1 are visible to the PC.
Block 0 is occupied from 0000H - 7FFFH. Block 1 is occupied from E000H - FFFFH.
00Block 1 is overlaid onto the low 8K of the program address space; occupying address locations 0000H - 1FFFH.
When the PC falls within 0000H - 1FFFH, the instruction will be fetched from Block 1 instead of Block 0.
Outside of 0000H - 1FFFH, Block 0 is used. Locations 0000H - 1FFFH of Block 0 are reachable through
in-application programming.
3.2.1 Reset Configuration of Program Memory
Block Switching
Program memory block switching is initialized after reset
according to the state of the Start-up Configuration bit SC0
and/or SC1. The SC0 an d SC1 bits are programmed via
an external host mode co mmand or an IAP Mode command. See T able 4-1, Table 4-6, and Tabl e 4-7.
Once out of reset, the SFCF[0] bit can be changed dynamically by the progr am f or desir ed eff ects . Changing SFCF[0]
will not change the SC0 bit.
Caution must be taken when dynamically changing the
SFCF[0] bit. Since this will cause different physical memory
to be mapped to the logical pr ogram address space. The
user must avoid executing block switching instructions
within the address range 0000H to 1FFFH.
TABLE3-3: SFCF V
R
1
SC1
U (1)U (1)00
U (1)P (0)01x111
P (0)U (1)101010
P (0)P (0)111111
1. P = Programmed (Bit logic state = 0),
U = Unprogrammed (Bit logic state = 1)
SC0
1
ALUES UNDER DIFFERENT
ESET CONDITIONS(SST89E/V5XRD2)
State of SFCF[1:0] after:
Power-on
or
External
Reset
(default)
WDT Reset
or
Brown-out
Reset
x010
Software
Reset
T3-3.0 1255
TABLE3-4: SFCF VALUES UNDER DIFFERENT
R
ESET CONDITIONS(SST89E/V516RD2)
State of SFCF[1:0] after:
Power-on
or
External
1
SC0
U (1)00
P (0)01x111
1. P = Programmed (Bit logic state = 0),
U = Unprogrammed (Bit logic state = 1)
Reset
(default)
WDT Reset
or
Brown-out
Reset
x010
Software
Reset
T3-4.0 1255
3.3 Data RAM Memory
The data RAM has 1024 bytes of internal memor y. The
RAM can be addressed up to 64KB for external data
memory .
3.4 Expanded Data RAM Addressing
The SST89E/V554A both have the capability of 1K of
RAM. See Figure 3-5.
The devi ce has f our sections of inte rnal data mem ory:
1. The lower 128 Bytes of RAM (00H to 7FH) are
directly and indirectly addressable.
2. The higher 128 Bytes of RAM (80H to FFH) are
indirectly addressable.
3. The special funct ion registers (80H to FFH) are
directly addressable only.
4. The expanded RAM of 768 Bytes (00H to 2FFH) is
indirectly addressable by the move external
instruction (MOVX) and clearing the EXTRAM bit.
(See “Auxiliary Register (AUXR)” in Section 3.6,
“Special Function Registers”)
Since the upper 128 bytes occupy the same addresses as
the SFRs , the RAM mus t be acce ssed i ndir ec tly. The RAM
and SFRs space are physically separate even though they
have the same addresses.
When instructions access addresses in the upper 128
bytes (above 7FH), the MCU determines whether to
access the SFRs or RAM by the type of instruction given. If
it is indirect, then RAM is accessed. If it is direct , then an
SFR is accessed. See the examples below.
Indirect Access:
MOV@R0, #data; R0 contains 90H
Register R0 points to 90H which is locate d in the upper
address range. Data in “#data” is writ ten to RAM l ocation
90H rather than port 1.
Direct Access:
MOV90H, #data; write data to P1
Data in “#data” is wr itten to por t 1. Instructions that write
directly to the address write to the SFRs.
To acce ss the expanded RAM, t he EXTRAM bit mus t be
cleared and MOVX instruc tions must be used. The extra
768 bytes of memory is physically loc at ed on the chip an d
logically occu pies the first 768 bytes of externa l memory
(addresses 000H to 2FFH).
When EXTRAM = 0, the expanded RAM is indirectly
addressed using the MOVX instruction in combination
with any of the registers R0, R1 of the selected bank or
DPTR. Accessing the expanded RAM does not affect
ports P0, P3.6 (WR#), P3.7 (RD#), or P2. With
EXTRAM = 0, the expanded RAM can be accessed as
in the following e xample.
DPTR points to 0A0H and data in “A” is w r itt en to addr es s
0A0H of the expanded R AM ra the r th an external memory.
Access to extern al memory higher than 2 FFH using the
MOVX instruction will access extern al memor y (0300H t o
FFFFH) and will perform in the same way as the standard
8051, with P0 an d P2 a s data /addr ess bus, and P3 .6 an d
P3.7 as write and read timing signals.
When EXTRAM = 1, MOVX @Ri and MOVX @DPTR will
be similar to the standard 8051. Using MOVX @Ri provides an 8-bit address with multiplexed data on Port 0.
address bits. This provides external paging capabilities.
Using MOVX @DPTR generates a 16-bit address. This
allows external addressing up the 64K. Port 2 provides the
high-order eight address bits (DPH), and Port 0 multiplexes
the low order eight address bits (DPL) with data. Both
MOVX @Ri and MOVX @DPTR generates the necessary
read and writ e signals (P3.6 - WR # and P3.7 - RD#) for
external memory use. Table 3-5 shows external data memory RD#, WR# operation with EXTRAM bit.
The stack pointer (SP) can be located anywhere within the
256 bytes of internal RAM (lower 128 bytes and upper 128
bytes). The st ack pointer may not be located in any part of
the expanded RAM.
Other output port pins c an be u sed to outp ut high er order
The device has two 16-bit data pointers. The DPT R Select (DPS) bit in AUXR1 determines which of the two dat a
pointers is accessed. When DPS=0, DPTR0 is selected; when DPS=1, DPTR1 is selected. Quickly switching
between the two data pointers can be accomplished by a single INC instruction on AUXR1. (See Figure 3-6)
AUXR1 / bit0
DPS
DPTR1
DPS = 0 → DPTR0
DPTR0
DPS = 1 → DPTR1
DPH
83H
DPL
82H
External Data Memory
1255 F06.0
FIGURE3-6: D
UAL DATA POINTER ORGANIZATION
3.6 Special Function Registers
Most of the unique features of the FlashFlex51 microcontroller family are controlled by bits in special function registers (SFRs) located in the SFR memory map shown in Table 3-6. Individual descriptions of each SFR are provided
and reset values indicated in Tables 3-7 to 3-11.
PPCPCA interrupt priority bit
PT2Timer 2 interrupt priority bit
PSSerial Port inter r upt priority bit
PT1Timer 1 interrupt priority bit
PX1External interrupt 1 priority bit
PT0Timer 0 interrupt priority bit
PX0External interrupt 0 priority bit
Interrupt Priority High (IPH)
Location76543210Reset Value
B7H-PPCHPT2HPSHPT1HPX1HPT0HPX0Hx0000000b
SymbolFunction
PPCHPCA interrupt priority bit high
PT2HTimer 2 interrupt priority bit high
PSHSerial Port interrupt priority bit high
PT1HTimer 1 interrupt priority bit high
PX1HExternal interrupt 1 priority bit high
PT0HTimer 0 interrupt priority bit high
PX0HExternal interrupt 0 priority bit high
Interrupt Priority 1 (IP1)
Location76543210Reset Value
F8H1--1PBOPX3PX211xx10001b
SymbolFunction
PBOBrown-out interrupt priority bit
PX2External Interrupt 2 priority bit
PX3External Interrupt 3 priority bit
Interrupt Priority 1 High (IP1H)
Location76543210Reset Value
F7H1--1PBOHPX3HPX2H11xx10001b
SymbolFunction
PBOHBrown-out Interrupt priority bit high
PX2HExternal Interrupt 2 priority bit high
PX3HExternal Interrupt 3 priority bit high
0: Internal Expanded RAM access within range of 00H to 2FFH using MOVX @Ri /
@DPTR. Beyond 300H, the MCU always accesses external data memory.
For details, refer to Section 3.4, “Expanded Data RAM Addressing” .
1: External data memory access.
AODisable/Enable ALE
0: ALE is emitted at a constant rate of 1/3 the oscillator frequency in 6 clock mode, 1/6 f
12 clock mode.
1: ALE is active only during a MOVX or MOVC instruction.
Auxiliary Register 1 (AUXR1)
Location76543210Reset Value
A2H----GF20-DPSxxxx00x0b
OSC
in
SymbolFunction
GF2General purpose use r -defi ned fla g.
DPSDPTR registers select bit.
0: DPTR0 is selected.
1: DPTR1 is selected.
Watchdog Timer Control Register (WDTC)
Location76543210Reset Value
C0H---WDOUTWDREWDTSWDTSWDTxxx00000b
SymbolFunction
WDOUTWatchdog output enable.
0: Watchdog reset will not be exported on Reset pin.
1: Watchdog reset if enabled by WDRE, will assert Reset pin for 32 clocks.
WDTDInitial/Reload value in Watchdog Timer. New value won’t be effective until WDT is set.
PCA Timer/Counter Control Register1 (CCON)
Location76543210Reset Value
D8HCFCR-CCF4CCF3CCF2CCF1CCF000x00000b
1. Bit addressable
SymbolFunction
CFPCA Counter Overflow Flag
Set by hardware when the counter rolls over. CF flags an interrupt if bit ECF in CMOD
is set. CF may be set by either hardware or software, but can only cleared by software.
CRPCA Counter Run control bit
Set by software to turn the PCA counter on. Must be cleared by software to turn the
PCA counter off.
-Not implemented, reserved for future use.
Note: User should not write ‘1’s to reserved bits. The value read from a reserved bit is indeterminate.
CCF4PCA Module 4 interrupt flag. Set by hardware when a match or capture occurs.
Must be cleared by software.
CCF3PCA Module 3 interrupt flag. Set by hardware when a match or capture occurs.
Must be cleared by software.
CCF2PCA Module 2 interrupt flag. Set by hardware when a match or capture occurs.
Must be cleared by software.
CCF1PCA Module 1 interrupt flag. Set by hardware when a match or capture occurs.
Must be cleared by software.
CCF0PCA Module 0 interrupt flag. Set by hardware when a match or capture occurs.
Note: User should not write ‘1’s to reserved bits. The value read from a reserved bit is indeterminate.
ECOMnEnable Comparator
0: Disables the comparator function
1: Enables the comparator function
CAPPnCapture Positive
0: Disables positive edge capture on CEX[4:0]
1: Enables positive edge capture on CEX[4:0]
CAPNnCapture Negative
0: Disables negative edge capture on CEX[4:0]
1: Enables negative edge capture on CEX[4:0]
MATnMatch: Set ECOM[4:0] and MAT[4:0] to implement the software timer mode
0: Disables software timer mode
1: A match of the PCA counter with this module’s compare/capture register causes the
CCFn bit in CCON to be set, flagging an interrupt.
TOGnToggle
0: Disables toggle function
1: A match of the PCA counter with this module’s compare/capture register causes the
the CEXn pin to toggle.
PWMnPulse Width Modulation mode
0: Disables PWM mode
1: Enables CEXn pin to be used as a pulse width modulated output
ECCFnEnable CCF Interrupt
0: Disables compare/capture flag CCF[4:0] in the CCON register to generate an
interrupt request.
1: Enables compare/capture flag CCF[4:0] in the CCON register to generate an
interrupt request.
SMOD1Double Ba ud r at e bi t. If S MOD 1 = 1, T imer 1 is u sed to gen er ate the ba ud r at e , an d the
serial port is used in modes 1, 2, and 3.
SMOD0FE/SM0 Selection bit.
0: SCON[7] = SM0
1: SCON[7] = FE,
BOFBrown-out detection status bit, this bit will not be affected by any other reset. BOF
should be cleared by software. Power-on reset will also clear the BOF bit.
0: No brown-out.
1: Brown-out occurred
POFPow er-on reset status bit, this bit will not be affected by any other reset. POF should be
cleared by software.
0: No Power-on reset.
1: Power-on reset occurred
GF1General-purpose flag bit.
GF0General-purpose flag bit.
PDPower-down bit, this bit is cleared by hardware after exiting from power-down mode.
0: Power-down mode is not activated.
1: Activates Power-down mode.
IDLIdle mode bit, this bit is cleared by hardware after exiting from idle mode.
0: No framing error
1: Framing Error. Set by receiver when an invalid stop bit is detected. This bit needs to
be cleared by software.
SM0SMOD0 = 0 to access SM0 bit.
Serial Port Mode Bit 0
SM1Serial Port Mode Bit 1
SM0SM1ModeDescriptionBaud Rate
000Shift Register f
0118-bit UARTVariable
1029-bit UARTf
1139-bit UARTVariable
1. f
= oscillator frequency
OSC
OSC
f
OSC
OSC
or
f
OSC
1
/6 (6 clock mode) or
/12 (12 clock mode)
/32 or f
/64 or f
/16 (6 clock mode)
OSC
/32 (12 clock m ode)
OSC
SM2Enables the Automatic Address Recognition feature in Modes 2 or 3. If SM2 = 1 then RI
will not be set unless the received 9th data bit (RB8) is 1, indicating an address, and
the received byte is a given or broadcast address. In Mode 1, if SM2 = 1 then RI will not
be activated unless a valid stop bit was received. In Mode 0, SM2 should be 0.
RENEnables serial reception.
0: to disable reception.
1: to enable reception.
TB8The 9th data bit that will be transmitted in Modes 2 and 3. Set or clear by software as
desired.
RB8In Modes 2 and 3, the 9th data bit that was received. In Mode 1, if SM2 = 0, RB8 is the
stop bit that was received. In Mode 0, RB8 is not used.
TITransmit interrupt flag. Set by hardware at the end of the 8th bit time in Mode 0, or at
the beginning of the stop bit in the other modes, in any serial transmission, Must be
cleared by software.
RIReceive interrupt flag. Set by hardware at the end of the8th bit time in Mode 0, or
halfway through the stop bit time in the other modes, in any serial reception (except see
SM2). Must be cleared by software.
TF2Timer 2 overflow flag set by a Timer 2 overflow and must be cleared by software. TF2
will not be set when either RCLK or TCLK = 1.
EXF2Timer 2 external flag set when either a capture or reload is caused by a negative
transition on T2EX and EXEN2 = 1. When Timer 2 interrupt is enabled, EXF2 = 1 will
cause the CPU to vector to the Timer 2 interrupt routine. EXF2 must be cleared by
software. EXF2 does not cause an interrupt in up/down counter mode (DCEN = 1).
RCLKReceive clock flag. When set, causes the serial port to use Timer 2 overflow pulses for
its receive clock in modes 1 and 3. RCLK = 0 causes Timer 1 overflow to be used for
the receive clock.
TCLKTransmit clo ck flag. When set, ca us es t h e se ria l p ort to us e Tim e r 2 overflow pulse s for
its transmit clock in modes 1 and 3. TCLK = 0 causes Timer 1 overflow to be used for
the transmit clock.
EXEN2Timer 2 external enable flag. When set, allows a capture or reload to occur as a result
of a negative transition on T2EX if Timer 2 is not being used to clock the serial port.
EXEN2 = 0 causes Timer 2 to ignore events at T2EX.
TR2Start/stop control for Timer 2. A logic 1 starts th e timer.
C/T2#Timer or counter select (Timer 2)
0: Internal timer (OSC/6 in 6 clock mode, OSC/12 in 12 clock mode)
1: External event counter (falling edge triggered)
CP/RL2#Capture/Reload flag. When set, captures will occur on negative transitions at T2EX if
EXEN2 = 1. When cleared, auto-reloads will occur either with Timer 2 overflows or
negative transitions at T2EX when EXEN2 = 1. When either RCLK = 1 or TCLK = 1,
this bit is ignored and the timer is forced to auto-reload on Timer 2 overflow.
Timer/Counter 2 Mode Control (T2MOD)
Location76543210Reset Value
C9H------T2OEDCENxxxxxx00b
SymbolFunction
-Not implemented, reserved for future use.
Note: User should not write ‘1’s to reserved bits. The value read from a reserved bit is indeterminate.
T2OETimer 2 Output Enable bit.
DCENDown Count Enable bit. When set, this allows Timer 2 to be configured as an up/down
The device internal fl ash memor y can be programmed or
erased us ing the f o llowin g two m ethod s:
•External Host Programming mode
•In-Application Programming (IAP) mode
logic high to a logic low while RST input is being held continuously high. The device will stay in external host m ode
as long as RST = 1 and PSEN# = 0.
A Read-ID operation is necessary to “ar m” the device in
external host mode, and no other external host mode com-
4.1 External Host Programming Mode
External ho st programming mode allows the user to program the flash memory directly without using the CPU.
External host mo de is entered by forcing PSEN# from a
mands can be enabled until a Read-ID is performed. In
external host mode, the internal flash memory blocks are
accessed through the re-assigned I/O port pins (see Figure
4-1 for details) b y an ex ternal host, such as a MCU programmer, a PCB tester or a PC-controlled dev elopment board.
The Read-ID command accesses the Signature Bytes that
identify the device and the m anufacturer as SST. External
programmers primarily use these Signature Bytes in the
selection of programming algorithms. The Read-ID command is selected by the command c ode of 0H on P3[7:6 ]
and P2[7:6 ]. See Fi gure 14 -14 f o r timi ng wa v ef orms .
An arming command sequence must take place before
any external host mode sequence command is recognized
by the device. This prevents accidental tr iggerin g of external host mode commands due to noise or programmer
error. The arming command is as follows:
1. PSEN# goes low while RST is high. This will get
the machine in external host mode, re-configuring
the pins, and turning on the on-chip oscillator.
2. A Read-ID command is issued, and after 1 ms the
external host mode commands can be issued.
After the above sequence, all other external host mode
commands are enabled. Before the Read-ID command is
received , al l ot her external host mode commands r eceived
are ignored.
4.1.3 External Host Mode Commands
The external host mode commands are Read-ID, ChipErase, Block-Erase, Sector-Erase, Byte-Program, ByteVerify, Prog-SB1, Prog-SB2, Prog-SB3, Prog-SC0, ProgSC1, Select-Block0, Select-Block1. See Table 4-1 for all
signal logic assignments, Figure 4-1 for I/O pin assignments, an d Table 14-1 1 for the timin g parame ters . The critical timing for all Erase and Program commands is
generated by an on-chip flash memory controller. The highto-low transition of the PROG# signal initiates the Erase or
Program commands, which are synchronized internally.
The Read comman ds are asynchronous read s, independent of the PROG# signal level.
A detailed description of the external host mode commands follows.
The Select-Block0 com mand enables Block 0 to be programmed in external host mode. Once this command is
executed, all subsequent extern al host Com mands will be
directed at Bloc k 0. See Fig ure 14-15 for timing wav ef orms .
The Select-Block1 command enables Block 1 (8 KByte
Block) to be programmed. Once this command is executed, all subsequent external host Commands that are
directed to the address range below 2000H will be directed
at Block 1. The Sele ct-Block1 command only a ffects the
lowest 8 KByte of the program address space. For
addresses greater than or equal to 2000H, Block 0 is
accessed by default. Upon entering external host mode,
Block 1 is selecte d by def ault .
The Chip-Erase, Block-Erase, and Sector-Erase commands are used for erasing all or part of the memory array .
Erased data bytes in the memo ry array will be erased to
FFH. Memor y locations that are to be programmed must
be in the erased state prior to programming.
The Chip-Erase command erases all bytes in both memory
blocks, regardless of any previous Select-Block0 or SelectBlock1 commands. Chip-Erase ignores the Security Lock
status and will erase the Security Lock, returning the device
to its Unlocked state. The Chip-Erase command will also
erase the SC0 bit. Upon completion of the Chip-Erase
command, Block 1 wi ll be the selec ted block. See Figur e
14-16 for timing waveforms.
The Block-Erase command erases all bytes in the selected
memory blocks. This command will not be executed if the
security lock is enabled. The selection of the memory block
to be erased is d etermined by t he prior execution Selec tBlock0 or Select-B lock1 command. See Figure 14-18 for
the timing waveforms.
The Sector-Erase c ommand erases all of the bytes in a
sector. The sector size for the fla sh memory is 128 B ytes.
This command wi ll not be executed if the Sec urity lock is
enabled. See Figure 14-19 for timing waveforms.
The Byte-Program command is used for programming new
data into the memory array. Programming will not take
place if any security locks are enabled. See Fig ure 14-20
for timing waveforms.
The Byte-Verify command allows the user to verify that the
device correctly performed an Erase or Program command. This comm an d wi l l b e d isabled if any security l ocks
are enabled. See Figure 14-23 for timing waveforms.
The Prog-SB1, Prog-SB2, Prog-SB3 commands program
the security bits, the functions of these bits are described in
the Security Lock secti on an d al s o i n Table 9-1. Once programmed, these bits can only be erased through a ChipErase command. See Figure 14-21 for timing waveforms.
Prog-SC0 comma nd pr ograms SC0 b it, whi ch de ter min es
the state of SFCF[0] out of reset. Once programmed, SC0
can only be re stored to a n erased state v ia a Chip- Erase
command. See Figure 14-22 for timing waveforms.
Prog-SC1 comma nd pr ograms SC1 b it, whi ch de ter min es
the state of SFCF[1] out of reset. Once programmed, SC1
can only be re stored to a n erased state v ia a Chip- Erase
command. See Figure 14-22 for timing waveforms.
4.1.4 External Host Mode Clock Source
In external host mode, an internal oscillator will provide
clocking for the device, and the os cillator is un affected by
the clock dou b ler l ogic. Th e on- chip oscil lat or wi ll be turned
on as the device enters external host mode; i.e. when
PSEN# goes low while RST is high . During external host
mode, the CPU core is held in reset. Upon exit from external host mode, the internal oscillator is turned off.
4.1.6 Instructions to Perform External Host Mode
Commands
To program data into the memory array, ap ply power
supply voltage (V
) to VDD and RST pins, and per-
DD
form the following steps:
1. Maintain RST high and set PSEN# from logic high
to low, in sequence according to the appropriate
timing diagram.
2. Raise EA# High (V
).
IH
3. Issue Read-ID command to enable the external
host mode.
4. Verify that the memory blocks or sectors for programming is in the erased state, FFH. If they are
not erased, then erase them using the appropriate
Erase command.
5. Select the memory location using the address
lines (P3[5:4], P2[5:0], P1[7:0]).
4.1.5 Flash Operation Status Detection Via External
Host Handshake
The device provides two meth ods for an external host to
detect the completi on of a flash me mory operatio n to opt imize the Program or Erase time. The e nd of a fla sh me mory operation cycle can be detected by:
1. monitoring the Ready/Busy# bit at P3[3];
2. monitoring the Data# Polling bit at P0[3] .
4.1.5.1 Ready/Busy# (P3[3])
The progress of the flash memory programming can be
monitored by the Ready/Busy# output signal. P3[3] is
driven low, some time after ALE/PROG# goes low during a
flash memory operation to indicate the Busy# status of the
Flash Control Unit (FCU). P3[3] is driven high when the
flash programming o peration is complet ed to indicate th e
ready status.
4.1.5.2 Data# Polling (P0[3])
During a Program op eration, any attempts to read (Byt eVerify), wh ile the device is busy, will rece ive the complement of the data of the last byte loaded (logic low, i.e. “ 0” for
an Erase) on P0[3] wi th the rest of the bits “ 0”. During a
Program operation, the Byte-Verify command is reading
the data of the last byte loaded, not the data at the address
specified.
8. Wait for low to high transition on Ready/Busy#
(P3[3]).
9. Repeat steps 5 - 8 until programming is finished.
10. Verify the flash memory contents.
4.1.7 Additional Read Commands in External Host
Mode
The procedure to issue additional read commands, shown
in Table 4-4 below, is the same as the read ID command
format, only the ad dres s i s c ha nge d. He re is a s ho rt list o f
useful features:
•Read the status of the security bits
(SB1_i, SB2_i, SB3_i).
•Read the configuration bits (SC0_i, SC1_i) status.
The device offers either 16/24/40/72 KByte of in-application
programmable flash memory. During in-application programming, the CPU of the microcontroller enters IAP
mode. The two blocks of flash me mory allow the CPU to
execute user code from one block, while the other is being
erased or reprogrammed concu rre ntly. The CPU may also
fetch code from an external memory while all internal flash
is being reprogrammed. The mailbox registers (SFST,
SFCM, SFAL, SF AH, SFDT and SFCF) located in the special function register (SFR), control and monitor the
device’s erase and program process.
Table 4-6 and Table 4-7 outline the c ommands and their
associated mailb ox re gister set tings .
4.2.1 In-Application Programming Mode Cloc k
Source
During IAP mode, both the CPU core and the flash controller unit are dri ven off th e external clock. However, an internal oscillator will provide timing references for Program and
Erase operations. The inte rnal oscill ator is only tur ned on
when required, and is turned off as soon as the flash operation is compl eted.
T4-4.0 1255
4.2.2 Memory Bank Selection for In-Application
Programming Mode
With the addressi ng range limit ed to 16 bit, on ly 64 KByt e
of program address sp ace is “visible” at any o ne time. As
shown in Table 4-5, the ba nk selec tio n (th e conf igu r ati on of
EA# and SFCF[1:0]), allows Block 1 memory to be overlaid
on the lowest 8 KByte of Block 0 memory, making Block 1
reachable. The same c oncept is employed to allow both
Block 0 and Block 1 flash to be acces sible to IAP operations. C ode fr om a b lo c k th at is not vi sib l e ma y not be u sed
as a source to program another address. However , a b loc k
that is not “visible” may be programm ed by code from th e
other block through mailbox registers.
The device allows IAP code in one block of memory to program the other block of memory, but may not program any
location in the sam e block. If an IAP operation origi nates
physically from Block 0, the target of this operation is implicitly defined to be in Blo ck 1. If the IAP op eratio n or igi nates
physically from Block 1, then the target address is implicitly
defined to be in Block 0. If the IAP operation originates from
external program space, then, the target will depend on the
address and the state of bank selection.
4.2.3 IAP Enable Bit
The IAP enable bit, SFCF[6], enables in-application programming mode. Until this bit is set, all flash programming
IAP commands will be ignored.
TABLE4-5: IAP ADDRESS RESOLU TIO NFOR SST89E /V516RD2
EA#SFCF[1:0]Address of IAP Inst.Target AddressBlock Being Programmed
All of the following commands can only be initiated in the
IAP mode. In all situations, wri ting the control byte to the
SFCM register will initiate all of the operations. All commands will not be enabled if the security locks are enabled
on the selected me mory bloc k.
The Program command is for programming new data int o
the memory array. The portion of the memory array to be
programmed should be in the erased state, FFH. If the
memory is not erased, it should first be erased with an
appropriate Erase command. Warning: Do not attempt to
write (program or erase) to a block that the code is currently fetching from. This will cause unpredictable program behavior and may corrupt program data.
4.2.4.1 Chip-Erase
The Chip-Erase command erases all bytes in both memory
blocks. This command is only allowed when EA#=0 (external memor y execution). Additi onally this command i s not
permitted when the device is in level 4 locking. In all oth er
instances, this co mmand ignor es the Secu rity Lo ck status
and will erase the security lock bits and re-map bits.
IAP Enable
ORL SFCF, #40H
FlashFlex51 MCU
IAP Enable
ORL SFCF, #40H
Erase Block 0
MOV SFAH, #00H
Polling scheme
MOV SFCM, #0DH
SFST[2] indicates
operation completion
OR
Set-Up
MOV SFDT, #55H
4.2.4.3 Sector-Erase
The Sector-Erase c ommand erases all of the bytes in a
sector. The sector size for the flash memor y blocks is 128
Bytes. The selection of the sector to be erased is determined by the contents of SFAH and SF AL.
Erase Block 1
MOV SFAH, #F0H
Interrupt scheme
MOV SFCM, #8DH
INT1 interrupt
indicates completion
1255 F09.0
Set-Up
MOV SFDT, #55H
Polling scheme
MOV SFCM, #01H
SFST[2] indicates
operation completion
Interrupt scheme
MOV SFCM, #81H
INT1 interrupt
indicates completion
1255 F08.0
4.2.4.2 Block-Erase
The Block-Erase command erase s all bytes in one of the
two memory blocks (Blo ck 0 or Block 1). The selecti on of
the memory block to be erased is determined by the
(SFAH[7]) of the SuperFlash Address Register. For
SST89x516RD2, re fer to Ta ble 4-5. For SST89 x5xRD2, i f
SFAH[7] = 0b, the primary flash memory Block 0 is
selected. If SFAH[7:4] = EH, t he second ar y flash memor y
Block 1 is selected. The Block-Erase command sequence
for SST89x5xRD2 is as follows:
The Byte-Program comm and programs data into a s ingle
byte. The address is deter m ined by the contents of SFAH
and SFAL. The data byte is in SFDT .
IAP Enable
ORL SFCF, #40H
MOV SFAH, #byte_addressH
IAP Enable
ORL SFCF, #40H
Program byte address
MOV SFAL, #byte_addressL
Preliminary Specifications
Program byte address
MOV SFAH, #byte_addressH
MOV SFAL, #byte_addressL
Move data to SFDT
MOV SFDT, #data
Polling scheme
MOV SFCM, #0EH
SFST[2] indicates
operation completion
Interrupt scheme
MOV SFCM, #8EH
INT1 interrupt
indicates completion
1255 F11.0
4.2.4.5 Byte-Verify
The Byte-Verify command allows the user to verify that the
device has correctly performed an Erase or Program command. Byte-Verify command returns the data byte in SFDT
if the command is successful. The user is required to check
that the previous flash operation has fully completed before
issuing a Byte- Verify. Byte-Verify command execution time
is short enough that there is no need to poll for command
completion and no interrupt is generated.
MOV SFCM, #0CH
SFDT register
contains data
1255 F12.0
4.2.4.6 Prog-SB3, Prog-SB2, Prog-SB1
Prog-SB3, Prog-SB2, Prog-SB1 commands are used to
program the security bits (see Table 9-1). Completion of
any of these commands, the security options will be
updated immediately.
Security bits previously in un-programmed state can be
programmed by these commands. Prog-SB3, Prog-SB2
and Prog-SB1 comm an ds sho ul d on ly re si de in Bl ock 1 or
external code memory .
Prog-SC0 comman d is used to p rogram the SC0 bi t. This
command only chang es the SC0 bit a nd has no effect on
BSEL bit until after a reset cycle.
SC0 bit previously in un-programmed state can be programmed by this command. The Prog-SC0 command
should resi de only i n Bloc k 1 or e xte rnal code memory.
Prog-SC1 comman d is used to p rogram the SC1 bi t. This
command only chang es the SC1 bit a nd has no effect on
SFCF[1] bit un til a fter a r eset cycle .
SC1 bit previously in un-programmed state can be programmed by this command. The Prog-SC1 command
should resi de only i n Bloc k 1 or e xte rnal code memory.
ORL SFCF, #40H
Set-up Enable-Clock-Double
MOV SFAH, #55H
MOV SFDT, #0AAH
Program Enable-Clock-Double
Polling scheme
MOV SFCM, #08H
Polling SFST[2]
indicates completion
FlashFlex51 MCU
IAP Enable
Program Enable-Clock-Double
Interrupt scheme
MOV SFCM, #88H
INT1# Interrupt
indicates completion
1255 F15.0
IAP Enable
ORL SFCF, #40H
Set-up Program SC0
MOV SFAH, #5AH
MOV SFDT, #0AAH
Program SC0 or SC1 -
Polling scheme
MOV SFCM, #09H
Polling SFST[2]
indicates completion
Set-up Program SC1
MOV SFAH, #0AAH
MOV SFDT, #0AAH
Program SC0 or SC1 -
Interrupt scheme
MOV SFCM, #89H
INT1# Interrupt
indicates completion
1255 F14.0
4.2.4.8 Enable-Clock-Double
Enable-Clock-Double command is used to make the MCU
run at 6 clocks per machine cycle. The standard (default) is
12 clocks per machine cycle (i.e. clock double command
disabled).
.
There are no IAP counterparts for the external host commands Select-Block0 and Select-Block1.
4.2.5 Polling
A command that uses the polling method to detect flash
operation completi on s hould poll on the FLA SH_BUS Y bit
(SFST[2]). When FLASH_BUSY de-asserts (logic 0), the
device is ready for the next operation.
MOVC instruction may als o be used for verifi cation of th e
Programming and Erase operation of the flash memory.
MOVC instruction will fail if it is directed at a flash block that
is still busy.
4.2.6 Interrupt Termination
If interrupt ter mination is selected, (SFCM[7] is set), the n
an interrupt (INT1) will be generated to indicate flash operation completion. Under this condition, the INT1 becomes an
internal in terrupt s ource. The INT 1# pin can now be us ed
as a general purp ose po rt pin and it ca nnot be the so urce
of External Interrupt 1 during in-application programming.
In order to use an interrupt to signal flash operation termination. EX1 and E A bi ts of IE r egi ster mus t be s et. The IT1
bit of TCON register must also be set for edge trigger
detection.
The device has three 16 -bit regist ers that c an be used as
either timers or event counters. The thr ee timers/counters
are denoted Timer 0 (T0), Timer 1 (T1) , and Time r 2 (T2).
Each is design ated a pair of 8-bit regi sters in the SFRs.
The pair consists of a most significant (high) byte and least
significant (low) byte. The respective registers are TL0,
TH0, TL1, TH1, TL2, and TH2.
5.2 Timer Set-up
Refer to Table 3-10 for TMOD, TCON, and T2CON registers regarding time rs T0, T1, and T2. The following tables
provide TMOD values to be used to se t up T imers T0, T1,
and T2.
Except for the baud rate generator mode, the values given
for T2 CON do not incl ude t he s ett ing o f the TR2 b it. The refore, bit TR2 must be set separately to turn the timer on.
TABLE5-1: T
ModeFunction
Used as
Timer
Used as
Counter
1. The Timer is tur ned ON/OFF by setting/clearing
bit TR0 in the software.
2. The Timer is turned ON/OFF by the 1 to 0 transition
on INT0# (P3.2) when TR0 = 1 (hardware control).
1. The Timer is tur ned ON/OFF by setting/clearing bit
TR1 in the software.
2. The Timer is turned ON/OFF by the 1 to 0 transition
on INT1# (P3.3) when TR1 = 1 (hardware control).
T5-2.0 1255
TABLE5-3: TIMER/COUNTER 2
T2CON
1
External
Control
T5-3.0 1255
2
Internal
Mode
Control
16-bit Auto-Reload00H08H
2
Used as
Timer
16-bit Capture01H09H
Baud rate generator
34H36H
receive and transmit
same baud rate
Receive only24H26H
Transmit only14H16H
Used as
Counter
1. Capture/Reload occurs only on timer/counter overflow.
2. Capture/Reload occurs on timer/counter overflow and a 1
to 0 transition on T2EX (P1.1) pin except when Timer 2 is
used in the baud rate generating mode.
A 50% duty cycle clock can be programmed to come out
on P1.0. This pin, besides being a regular I/O pin, has two
alternate functions. It can be programmed:
1. to input the external clock for Timer/Counter 2, or
2. to output a 50% duty cycle clock ranging from 122
Hz to 8 MHz at a 16 MHz operating frequency (61
Hz to 4 MHz in 12 clock mode).
To configure Timer/Counter 2 as a clock generator, bit
C/#T2 (in T2CON) must be cleared and bit T20E in
T2MOD must be set. Bit TR2 (T2CON.2) also must be set
to start the timer.
The Clock-Out frequency depends on the oscillator frequency and the relo ad value of Timer 2 captu re registers
(RCAP2H, RCAP2L) as shown in this equation:
Oscillator Frequency
n x (65536 - RCAP2H, RCAP2L)
n =2 (in 6 clock mode)
4 (in 12 clock mode)
Where (RCAP2H, RCAP2L) = the contents of RCAP2H
and RCAP2L taken as a 16-bit unsigned integer.
In the Clock-Out mode, Timer 2 roll-overs will not generate
an interrupt. This is similar to when it is used as a baud-rate
generator. It is possible to use Timer 2 as a baud-rate generator and a clock generator simultaneously. Note, however, that the baud-rate and the Clock-Out frequenc y will
not be the same.
6.0 SERIAL I/O
6.1 Full-Duplex, Enhanced UART
The device serial I/O port is a full-duplex port that allows
data to be transmitted and received simultaneously in
hardware by the transmit and receive registers, respectively, while the software is perfor ming other tasks. The
transmit and receive registers are both located in the
Serial Data Buffer (SBUF) special function register. Writing to the SBUF register loads the transmit register, and
reading from the SBUF register obtains the contents of
the receive regi ster.
The UART has four modes of operation which are selected
by the Serial Port Mode Specifier (SM0 and SM1) bits of
the Serial Port Control (SCON) special function register. In
all four modes, transmission is ini tiated by any instruction
that uses the SBUF register as a destination register.
Reception is initiated in mode 0 when the Receive Interrupt
(RI) flag bit of the Serial Port Control (SCON) SFR is
cleared and the Reception Enable/ Disable (REN) bit of the
SCON register is set. Reception is initiated in the other
modes by the incoming start bit if the REN bit of the SCON
register is set.
6.1.1 Framing Error Detection
Framing Error Detection is a feature, which allows the
receiving controller to check for valid stop bits in modes 1,
2, or 3. Missing stops bits can be caused by noise in serial
lines or from simultaneous transmission by two CPUs.
Framing Error Detection is selected by goin g to the P CO N
register and chang ing SMOD0 = 1 (see Figure 6 -1). If a
stop bit is missing, th e Framing Error bit (FE ) will be set.
Software may examine the FE bit after each reception to
check for data errors. After the F E bit has b een set, it can
only be cleared by software. V alid stop bits do not clear FE.
When FE is enabled, RI rises on the stop bit, instead of the
last data bit (see Figure 6-2 and Figure 6-3).
Automatic Address Recog nition helps to redu ce the MCU
time and power required to talk to multiple se rial devices.
Each device is hooked t ogether sharing the same serial
link with its own addr ess. In this confi guration, a device is
only interrupted when it receives its own address, thus
eliminating the software overhead to compare addresses.
This same feature helps to save power because it can be
used in conjunction with id le mode to redu ce the syst em’s
overall power consumption. Since there may be multiple
slaves hooked up serial to one master, only one slave
would have to be interrupted from idl e m ode to res po nd to
the master’s transmission. Automati c A dd re ss Re c ogn ition
(AAR) allows the other slaves to remain in idle mode while
only one is interr upted. By li miting the numb er of interru ptions, the total current draw on the system is reduced.
There are two ways to communicate with slaves: a group of
them at once , or all of the m at once. To communicate with a
group of slaves, the master sends out an addr ess called
the given address. To communi c ate with all the slaves, the
master sends out an address called the “broadcast”
address.
AAR can be configur ed as mo de 2 or 3 (9-b it mode s) an d
setting the SM2 bit in SCON. Each slave has its own SM2
bit set waiting for an address byte (9th bit = 1). The Receive
Interrupt (RI ) flag will only be s et when the received byte
matches either the given address or the broadcast
address. Next, the slave then clears its SM2 bit to enable
reception of the data bytes (9th bit = 0) from the master.
When the 9th bit = 1 , the master is sending a n address.
When the 9th bit = 0, the master is sending actual data.
6.1.2.1 Using the Given Address to Select Slaves
Any bits masked off by a 0 from SADEN become a “don’t
care” bit for the given address. Any bit masked off by a 1,
becomes ANDED with SADDR. The “do n’t cares” provide
flexibility in the user-defined addresses to address more
slav es when using t he giv en a ddres s.
Shown in the example above, Slave 1 has been given an
address of 1111 0001 (SADDR). The SADEN byte has
been used t o mask o ff bits to a gi ve n address to allo w mor e
combinations of selecting Slave 1 and Slave 2. In this case
for the given addresses, the last b it (LSB) of Slave 1 is a
“don’t care” and the l ast bit of Slave 2 is a 1. To communicate with Slave 1 and Slave 2, the master would ne ed to
send an address with the last bit equal to 1 (e.g. 1111
0001) since Slave 1’s last bit is a don’t care and S lave 2’s
last bit has to be a 1. To communicate with Slave 1 alone,
the master wo uld send an a ddre ss wi th t he l ast bit equa l to
0 (e.g. 1111 0000), since Slave 2’s last bit is a 1. See the
table belo w f o r other p ossib le com binat ions .
Slave 1Given AddressPossible Addresses
Slave 2
SADDR = 1111 0011
SADEN = 1111 1001
GIVEN = 1111 0XX1
Select Slave 1 Only
1111 0X0X1111 0000
Preliminary Specifications
1111 0100
If mode 1 is used, the stop bit takes the place of the 9th bit.
Bit RI is set only when the received command frame
address matches the device’s address and is termin ated
by a valid stop bit. Note that mode 0 ca nnot be use d. Se tting SM2 bit in the SCON register in mode 0 will have no
Slave 2Given AddressPossible Address es
Select Slave 2 Only
1111 0XX11111 0111
1111 0011
effect.
Each slave’s individual address is specified by SFR
SADDR. SFR SADEN is a ma sk byte that defines “don’t
Slaves 1 & 2Possible Addresses
care” bits to form t he given address when combined with
SADDR. See the example below:
The user could use the possible addresses above to select
slav e 3 only. Another combinatio n could be to select sl av e 2
and 3 only as shown below.
Select Slaves 2 & 3 Only
Slaves 2 & 3Possible Addresses
1111 0011
More than one slave may have the same SADDR address
as well, and a given address could be used to modify th e
address so that it is unique.
6.1.2.2 Using the Broadcast Address to Select Slaves
Using the broadcast address, the master can communicate
with all the slaves at once. It is formed by performing a logical OR of SADDR and SADEN with ‘0’s in the result treated
as “don’t cares”.
Slave 1
1111 0001 = SADDR
+1111 1010 = SADEN
1111 1X11 = Broadcast
“Don’t cares” all ow for a wider range in def in ing the broadcast address, but in most cases, the broadcast address will
be FFH.
On reset, SADDR and SADEN are “0”. This produces an
given address of all “don’t cares” as well as a b roadcast
address of all “don ’t cares.” This effectively disables Automatic Addressing m ode and allows the microcon troller to
function as a standa rd 8051, wh ich does no t make use of
this feature.
6.2 Serial Peripheral Interface
6.2.1 SPI Features
•Master or slave operation
•10 MHz bit frequency (max)
•LSB first or MSB first data transfer
•Four programmable bit rates
•End of transmission (SPIF)
•Write collision flag protection (WCOL)
•Wake up from idle mode (slave mode only)
6.2.2 SPI Description
The serial periphe ral int erf ace (SPI) al lows hi gh-speed synchronous data transfer between the SST89E/V554A and
peripheral devices or between several SST89E/V554A
devices .
Figure 6-4 shows the correspondence between master
and slav e SPI de vices . The S CK pin is the cl ock output and
input for the master and slave modes, respectively . The SPI
clock generator will start following a write to the master
devices SPI data register. The written d ata is then shi fted
out of the MOSI pin on the master device into the MOSI pin
of the slave device. Following a complete transmission of
one byte of data, the SPI clock generator i s stopped and
the SPIF flag is set. An SPI interrupt request will be generated if the SPI Interr upt Enable bit (SPIE) and the Serial
Port Interrupt Enable bit (ES) are both set.
An external master dr ives the Slave Select inpu t pin, S S#/
P1[4], low to select the SPI module as a slave. If SS#/P1[4]
has not been driven low, then the slave SPI unit is not
active and the MOSI/P1[5] port can also be used as an
input port pin.
CPHA and CPOL control the phase and polarity of the SPI
clock. Figures 6-5 and 6-6 show the four possible combinations of these two bits.
The devic e off ers a pro gram mable Wa tchdog Ti mer (WDT )
for fail safe protection against software dea dlock an d aut omatic recovery.
To protec t the syste m against s oftware dead lock, the user
software must refresh the W DT w ithin a us er-d efine d tim e
period. If the software fails to do this perio dical refresh , an
internal hardware reset will be initiated if enabled (WDRE=
1). The software can be designed such that the WDT times
out if the program does not work properly .
The WDT in the device uses the syst em clock (XTAL1) as
its time base. So strictly speaking, it is a watchdog counter
rather than a watchdog timer. The WDT registe r will i ncrement every 344,064 crystal clocks. The up pe r 8 -bits of the
time base register (WDTD) are used as the reload register
of the WDT.
344064
clks
WDT Upper Byte
Ext. RST
CLK (XTAL1)
Counter
The WDTS flag bit is set by WDT overflow and is not
changed by WDT reset. User software can clear WDTS by
writing “1” to it.
Figure 7-1 provides a block diagram of the WDT . Two SFRs
(WDTC and WDTD) control watchdog timer operation.
During idle mode, WDT operation is temporarily suspended, and resumes upon an interrupt exit from idle.
The time-out period of the WDT is calculated as follows:
Period = (255 - WDTD) * 344064 * 1/f
CLK (XTAL1)
where WDTD is the value loaded into the WDTD register
and f
The Programmable Counter Array (PCA) prese nt on the
SST89E/V5xRD2 is a special 16-bit timer that has five 16bit capture/ compa re mod ules . Each of the mo dule s can be
programmed to operate in one of four modes: rising and/or
falling edge capture, sof tware timer, high-speed output, or
pulse width modulator. The 5th module can be programmed as a Watchdog Timer in addition to the other four
modes. Each module has a pin associated with it in port 1.
Module 0 is connect ed to P1. 3 (CEX0) , modu le 1 to P 1[4]
(CEX1), module 2 to P1[5] (CEX2), module 3 to P1[6]
(CEX3), and module 4 to P1[7] (CEX4). PCA configuration
is shown in Figure 8-1.
8.1 PCA Overview
PCA provides more timing capabilities with less CPU intervention than the standard timer/counter. Its advantages
include reduced software overhead and improv ed accuracy.
The PCA consists of a dedicated timer/counter which
serves as the ti me base for an array of five compar e/capture modules. Figure 8-1 shows a block diagram of the
PCA. External events associated with modules are shared
with corresponding Port 1 pins. Modules not using the port
pins can still be used for standard I/O.
Each of the five modules can be programmed in any of the
following modes:
•Rising and/or falling edge capture
•Software timer
•High speed output
•Watchdog Timer (Module 4 only )
•Pulse Width Modulator (PWM)
8.2 PCA Timer/Counter
The PCA timer is a free-running 16-bit timer consisting of
registers CH and CL ( the high and low bytes of the count
values). The PCA time r is common time base for all five
modules and can be programmed to run at: 1/6 the oscillator frequency, 1/2 the oscillator frequency , Timer 0 overflow ,
or the input on the ECI pin (P1.2). The timer/counter source
is determined from the CPS1 and CPS0 bits in the CMOD
SFR as follows (see “PCA Timer/C ounter Mode Register
(CMOD)” on page 28):
8-bit mode256 µsec192 µsec
16-bit mode65 msec49 µsec
8-bit auto-reload1 to 255 µsec0.75 to 191 µsec
Mode 3: External Input MAX0.66 µsec0.50 µsec
1. In Mode 2, the overflow interrupt for Timer 0 does not need to be enabled.
/121 µsec0.75 µsec
OSC
IMER/COUNTER INPUTS
Clock Increments
12 MHz16 MHz
1
T8-2.0 1255
The four possible CMOD timer modes w ith and without the overflow interrupt enabled are shown below. This list
assumes that PCA will be left running during idle mode.
TABLE8-3: CMOD VALUES
CMOD Value
PCA Count Pulse Selected
Internal clock, f
Internal clock, f
Timer 0 overflow04H05H
External clock at P1.206H07H
/1200H01H
OSC
/402H03H
OSC
Without Interrupt EnabledWith Interrupt Enabled
T8-3.0 1255
The CCON register is associated with all PCA timer functions. It contains run cont rol bits and flags for the PCA
timer (CF) and all modules. To run the PCA the CR bit (CCON.6) must be set by software. Clearing the bit, will turn
off PCA. When the PC A counter overflows, the CF (CCON.7) will be set, and a n interru pt will be generate d if the
ECF bit in the CMO D register is set. The CF bit can only be c leared by software. Eac h module h as its own timer
interrupt or capture interrupt flag (CCF0 for module 0, CCF4 for module 4, etc.). They are set when either a match
or capture occurs. These flags can only be cleared by software. (See “PCA Timer/Counter Control Register
(CCON)” on page 27.)
Each PCA module has an associated SFR with it. These
registers are: CCAPM0 for module 0, CCAPM1 for module
1, etc. Refer to “PCA Compare/Capture Module Mode Register (CCAPMn)” on page 29 for details. The registers each
contain 7 bits which are used to control the mode each
module will operate in. The ECCF bit (CCAPMn.0 where n
= 0, 1, 2, 3, or 4 depending on module) will enable the CCF
flag in the CCON SFR to generate an interrupt when a
match or compare occurs. PWM (CCAPMn.1) enables the
pulse width modulation mode. The TOG bit (CCAPMn.2)
when set, causes the CEX output associated with the module to toggle when there is a match between the PCA
counter and the module’s capture/compare register. When
there is a match between the PCA counter and the mod-
Bits CAPN (CCAPMn.4) and CAPP (CCAPMn.5) determine whether the cap ture input will be ac tive on a pos itive
edge or negative edge. The CAPN bit enables the negative
edge that a capture in put will be active on, and th e CAPP
bit enables the positive edge. When both bits are set , bot h
edges will be ena bled and a capture will occur for either
transition. The last bit in th e register ECOM (CCAPMn. 6)
when set, enables the comparator function. Table 8-5
shows the CCAPMn settings for the various PCA functions.
There are two additio nal register associated with each of
the PCA modu les: CCAP nH a nd CCAPn L. Th e y a re regi sters that hol d the 16-bi t coun t v al ue wh en a ca ptur e occu rs
or a compare occurs. When a module is used in PWM
mode, these registers are used to control the duty cycle of
the output. See Figure 8-1.
ule’s capture/compare register, the MATn (CCAPMn.3) and
the CCFn bit in the CCON register to be set.
Capture mode is used to capture the PCA timer/counter
value into a module’s capture registers (CCAPnH and
CCAPnL). The capture will occur on a positive edge, negative edge, or both on the corr esponding module’s pin. To
use one of the PCA modu les in the capture mo de, either
one or both the CCAPM bits CAPN and CAPP for that
module must be set. When a valid transition occurs on the
CEX pin corresponding to the module used, the PCA hardware loads the 16-bit value of the PCA counter register (CH
and CL) into the module’s capture regis ters (C CAPn L and
CCAPnH). If the CCFn bit for the module in the CCON
SFR and th e ECC Fn bi t i n th e CCAP Mn SF R a re se t, th en
an interrupt will b e generated. In th e interru pt servi ce routine, the 16-bit capture value must be saved in RAM before
the next event capture occurs. If a subsequent capture
occurred, the o riginal capture values would be lost. After
flag event flag has been set by hardware, the u ser must
clear the flag in software. (See Figure 8-2)
The 16-bit software timer mode is used to trigger interrupt
routines, which must occur at pe rio dic inte rvals. It is setup
by setting both the ECO M and MAT bits in the module’s
CCAPMn register. The PCA timer wi ll be comp ared to the
module’s capture registers (CCAPnL and CCAPnH) and
when a match occurs, an interr upt will occur, if the CCFn
(CCON SFR) and the ECCFn (CCAPMn SFR) bits for the
module are both set.
Write to
CCAPnL
Write to
CCAPnH
10
Reset
CCAPnHCCAPnL
EnableMatch
CFCRCCF4CCF3CCF2CCF1CCF0
16-bit Comparator
CHCL
If necessar y, a new 16-bit co mpare value can be loaded
into CCAPnH and CCAPnL during the interrupt routine.
The user should be aware that the hardware temporarily
disables the comparat or functi on whil e these r egisters are
being updated so that an invalid match will not occur. Thus,
it is recommended that the us er write to the low byte first
(CCAPnL) to disable the comparator, then write to the high
byte (CCAPnH) to re-enable it. If a ny upd ate s to th e r eg isters are done, the user m ay want to hold o ff a ny in ter r u pts
from occurring by clearing the EA bit. (See Figure 8-3)
The high speed ou tput mode is used to toggle a por t pin
when a match occurs between the PCA timer and the preloaded value in the compare registers. In this mode, the
CEX output pin (on por t 1) asso ciated with the PCA module will toggle every time there is a match between the PCA
counter (CH and CL) and the captu re registers ( CCAPnH
and CCAPnL). To activate this mode, the user must set
TOG, MAT , and ECOM bits in the module’s CCAPMn SFR.
Write to
CCAPnL
Write to
CCAPnH
10
Reset
CCAPnHCCAPnL
EnableMatch
CFCRCCF4CCF3CCF2CCF1CCF0
16-bit Comparator
CHCL
High speed output mo de is muc h m ore a cc u rate tha n to ggling pins since the toggle occurs before branchi ng to an
interrupt. In this case, interrupt latency wi ll not affect the
accuracy of the output. When using high speed output,
using an interr upt is optional. Only if the user wishes to
change the time for the next toggle is it necessary to
update the compare regi sters. Otherwise, the next toggle
will occur when th e PCA ti mer rolls over and matche s the
last compare value. (See Figure 8-4)
The Pulse Width Modulator (PWM) mode is used to generate 8-bit PWMs by comparing the low byte of the PCA
timer (CL) with the low byte of the compare register
(CCAPnL). When CL < CCAPnL the output is low. When
CL ≥ CCAPnL the output is high. T o activate this mode, the
user must set the PWM an d ECOM bits in the module’s
CCAPMn SFR. (See Figure 8-5 and Table 8-7)
In PWM mode, the frequency of the output depends on the
source for the PCA timer. Since there is only one set of CH
and CL registers, all modules share the PCA timer and frequency. Duty cycle of the outpu t is co ntrolled by the value
CCAPnH
FlashFlex51 MCU
loaded into the high byte (CCAPnH) . Since writes to the
CCAPnH register are asynchronous, a new value written to
the high byte will not be shifted into CCAPnL for comparison until the n ext period of the outp ut (when CL rolls over
from 255 to 00).
To calculate values for CCAPnH for any duty cycle, use
the following equation:
CCAPnH = 256(1 - Duty Cycle)
where CCAPnH is an 8-bit integer and Duty Cycle is a
fraction.
The Watchdog Timer mode is used to impro v e reliability in
the system without increasing chip count (See Figure 8-6).
Watchdog Timers are useful f or systems that are susceptible to noise, power glitches, or electrostatic discharge. It
can also be used to prev ent a softw a re deadlock. If during
the execution of the user’s code, there is a deadlock, the
Watchdog Timer will time out and an internal reset will
occur. Only module 4 can be pr ogra mmed as a W atchd og
Timer (but still can be programmed to other modes if the
Watchdog T imer is not used ).
To use the Watchdog Timer, the user pre-loads a 16-bit
value in the compare register. Just like the other compare
modes, this 16-bit value is compared to the PCA timer
value. If a match is allowed to occur , an internal reset will be
generated. This will not cause the RST pin to be driven high.
In order to hold off the reset, the user has three options:
1. periodically change the compare value so it will
never match the PCA timer,
2. periodically change the PCA timer value so it will
never match the compare values, or
3. disable the watchdog timer by clearing the WDTE
bit before a match occurs and then re-enable it.
The first two options are more reliable because the Watchdog Timer is never disabled as in option #3. If the program
counter ever goes astray , a match will eventually occur and
cause an internal reset. The second option is also not recommended if other PCA modules are being used. Remember, the PCA timer is the time base for all modules;
changing the tim e base for other modul es would not be a
good idea. Thus, in most application the first solution is the
best option.
Use the code below to initialize the Watchdog Timer. Module 4 can be configure d in either comp are mode, and the
WDTE bit in CMOD must also be set. The user’s software
then must periodically change (CCAP4H, CCAP4L) to
keep a match from occurring with the PCA timer (CH, CL).
This code is given in the Watchdog routine below.
MOVCCAPM4, #4CH; Module 4 in compare mode
MOVCCAP4L, #0FFH; Write to low byte first
MOVCCAP4H, #0FFH; Before PCA timer counts up
; to FFFF Hex, these compare
; values must be changed.
ORLCMOD, #40H; Set the WDTE bit to enable the
; watchdog timer without
; changing the other bits in
; CMOD
;==============================================
;Main program goes here, but call WATCHDOG periodically.
;==============================================
WATCHDOG:
CLR EA; Hold off interrupts
MOVCCAP4L, #00; Next compare value is within
MOVCCAP4H, CH; 65,535 counts of the
; current PCA
SETBEA; timer value
RET
;==============================================
This routine should not be part of an interrupt ser vice routine. If the program counter goes astra y and gets stuck in an
infinite loop, interrupts will still be serviced and the watchdog
will keep getting reset. Thus, the purpose of the watchdog
would be defeated. Instead, call this subroutine from the
main program of the PCA timer .
The security lock protects against software piracy and prevents the contents of the flash from being read by unauthorized parties. It also protects against code corruption
resulting from acc idental erasing and pro gramming to the
internal flash memory. There are two different types of
security locks in the device security lock system: hard lock
and SoftLock.
9.1 Hard Lock
When hard lock is activated, MOVC or IAP instructions executed from an unlocked or soft locked program address
space, are disabled from reading code bytes in hard locked
memory blocks (See Table 9-2). Hard lock can eithe r lock
both flash memo ry blocks or just lock the 8 K Byte flash
memory block (Block 1 ). All external host and IAP co mmands except for Chip-Erase are ignored for memory
blocks that are hard locked.
9.2 SoftLock
SoftLoc k allow s flash cont ents to be alt ered unde r a secure
environment. This lock option allows the user to update
program code in the so ft locked memor y block through i napplication programming mode under a predetermined
secure environmen t. For example, if Bl ock 1 (8K) mem or y
block is locked (hard locked or sof t locked), and Block 0
memory block is soft locked, code residing in Block 1 can
program Block 0. The following IAP mode commands
issued throu gh the comman d mail bo x regi ster, SFCM, exe cuted from a Locked (hard locked or soft locked) block, can
be operated on a sof t locked block: Block-Erase, SectorErase, By te-Pr ogr am and By te-Verify.
In external host mode, Sof tLock behaves the same as a
hard lock.
9.3 Security Lock Status
The three bits that indicate the device security lock
status are located in S FST [7: 5]. A s shown in Fig ure 91 and Table 9-1, the thr ee se curity lock bits control th e
lock status of the primary and secondary blocks of
memory. There are four distinct levels of security lock
status. In the first level, none of the secur ity lock bits
are programmed and both blocks are unlo cked. In the
second level, although both blocks are now locked and
cannot be programmed, they are available for read
operation via Byte-Verify. In t he third level, three different options are available: Block 1 hard lock / Block 0
SoftLock, SoftLock on both blocks, and hard lock on
both blocks. Locking both blocks is the same as Level
2, Block 1 except read operation isn’t available. The
fourth level of security is the most secure level. It
doesn’t allow read/program of internal memory or boot
from external memor y. For details on how to program
the security lock bits refer to the external hos t mode
and in-application programming sections.
UPU/SS
UUU/NN
PUU/SS
UUP/LS
Level 1
Level 2
Level 3
UPP/LLPPU/LS
FIGURE9-1: S
Note: P = Programmed (Bit logic state = 0), U = Unprogrammed (Bit logic state = 1), N = Not Locked, L = Hard locked, S = Soft locked
1000UUUUnlockUnlockNo Security Features are Enabled.
2100PUUSoftLockSoftLockMOVC instructions executed from
3011
4111PPPHard LockHard LockSame as Level 3 hard lock/hard lock,
1. P = Programmed (B it logic state = 0), U = Unprogrammed (Bit logic state = 1).
2. SF ST [7:5] = Secur ity Lock Status Bits (SB1_i, SB2_i, SB3_i)
ECURITY LOCK OPTIONS
Security Lock Bits
U
101
010UPUSoftLockSoftLockLevel 2 plus Verify disabled. Code in
110
001
P
P
U
1,2
1
P
U
P
U
SB3
P
P
U
P
1
Security Status of:
Block 1Block 0
Hard LockHard LockLevel 2 plus Verify disabled, both
Hard LockSoftLockLevel 2 plus Verify disabled. Code in
Security TypeSFST[7:5]SB1SB2
external program memory are disabled from fetching code bytes from
internal memory, EA# is sampled and
latched on Reset, and further programming of the flash is disabled.
blocks locked.
Block 1 ma y prog ram Blo ck 0 an d vice
versa.
Block 1 may program Block 0.
but MCU will start code execution
from the internal memory regardless
of EA#.
T9-1.0 1255
9.4 Read Operation Under Lock Condition
The status of secu rity bits SB1, SB2, and SB 3 can be r ead
when the read command is disabled by security lock.
There are three ways to read the status.
A system reset initializes the MCU and begins program
execution at program memor y location 0000H. The r eset
input for the device is the RST pin. In order to reset the
device, a logic level high must be applied to the RST pin for
at least two machine cycle s (24 clo cks), after the oscil lator
becomes stable. ALE, PSE N# are weakly pulled hi gh dur ing reset. During reset, ALE and PSEN# output a high level
in order to perform a prop er reset. This level must not be
affected by external element. A system reset will not affect
the 1 KByte of on-chip RAM while the device is running,
however, the contents of the on-chip RAM during power up
are indeterminate. Following reset, all Special Function
Registers (SFR) return to their reset values outlined in
Tables 3-7 to 3-11.
10.1 Power-on Reset
At initial power up, the port pins will be in a random state
until the oscill ator has star ted and the internal reset algorithm has weakly pulled all pins high. Powering up the
device without a valid reset could cause the MCU to
start executing instructions from an indeterminate
location. Such undefined states may inadvertently corrupt the code in the flash.
When power is applied to the device, the RST pin must be
held high long enoug h for the oscilla tor to st art up (usual ly
sev eral milliseco nds f or a lo w freq uency crystal), i n addition
to two machine cycles for a valid power-on reset. An example of a method to extend the RST signal is to implement a
RC circuit by connecting the RST pin to V
µF capacitor and to V
through an 8.2KΩ resistor as
SS
shown in Figure 10- 1. Note that if an RC circui t is being
used, provisions shou ld be made to ensure the V
time does not exceed 1 millisecond and the oscillator startup time does not exceed 10 milliseconds.
For a low frequency oscillator wit h slow start-up tim e the
reset signal must be extended in order to a ccount for the
slow start-up ti me. This method maintains the necessar y
relationship between V
and RST to avoid programming
DD
at an indeterm inate locati on, which may cause corr uption
in the code of the flash. The power-on detection is
designed to wor k as power up initia lly, before the voltage
reaches the brown-out detection level. The POF flag in the
PCON register i s set to in dicate an i nitial power up condition. The POF flag w ill remain act ive until cleared by software. Please refer to Section 3.5, PCON register definition
for detail information.
For more information on system level design techniques,
please review the
FlashFle x51 Family Microcontrolle r
Design Considerations for the SST
application note.
through a 10
DD
DD
rise
DD
10µF
8.2K
FIGURE 10-1: P
+
-
C
2
C
1
OWER-ON RESET CIRCUIT
10.2 Software Reset
The software reset is executed by changing SFCF[1]
(SWR) from “0” to “1”. A software reset will reset the program counter to address 0000H. All SFR registers will be
set to their reset values, except SFCF[1] (SWR), WDTC[2]
(WDTS), and RAM data will not be altered.
10.3 Brown-out Detection Reset
The device includes a brown-out detection circuit to protect
the system fr om s e v ered sup plied v olt age V
SST89E5xxRD2 internal brown-out detection threshold is
3.85V, SST89V5xxRD2 brown-out detection threshold is
2.35V. For brown -out voltage parameters, please r efer to
Tables 14-6 and 14-7.
When V
out detector triggers the circuit to generate a brown-out
interrupt but the CPU still runs until the supplied voltage
returns to the brown-out detection voltage V
default operation for a brown-out detection is to cause a
processor reset.
V
DD
ods before the brown-out detection circuit will respond.
Brown-out interr upt ca n be ena bled by setting th e EBO bi t
in IEA register (address E8H, bit 3). If EBO bit is set and a
brown-out condition occurs, a brown-out int errupt will be
generated to execute the program at location 0 04BH. It is
required that the EB O bit be cleare d by software after the
brown-out interrupt is serviced. Clearing EBO bit when the
brown-out condition i s active will pr oper ly res et the d evice.
If brown-out interru pt is not enabled, a br own-o ut c ond it io n
will reset the program to resume execution at location
0000H.
The device support s eight int errupt s ources un der a four level priority sch eme. Table 11-1 summarizes the p olling
sequence of the supported interrupts. Note that th e SPI serial in terface and the UART share the same interrup t
vector. (See Figure 11-1)
The device provides two power saving modes of operation
for applications where power consumption is crit ical. The
two modes are idle and power-down, see Tabl e 12-1.
12.1 Idle Mode
Idle mode is entered setting the IDL bit in the PCON register. In idle mode, the program counter (PC) is stopped. The
system clock continues to run and all interrupts and peripherals remain active. The on-chip RAM and the special function registers hold their data during this mode.
The device exits idle mode through either a system interrupt or a hardware reset. Exiting idle mode via system
interrupt, the start of the interrupt clears the IDL bit and
exits idle mode . After e x it th e Inte rrupt Se rvice Routin e , the
interrupted program resumes execution beginning at the
instruction immediately following the instruction which
invoked the idle mode. A hardware reset sta r ts th e device
similar to a power-on reset.
TABL E 12-1: P
ModeInitiated byState of MCUExited by
Idle ModeSoftware
Power-down
Mode
OWER S AVING MODES
(Set IDL bit in PCON)
MOV PCON, #01H;
Software
(Set PD bit in PCON)
MOV PCON, #02H;
CLK is running.
Interrupts, serial port and timers/counters are active. Program Counter is stopped.
ALE and PSEN# signals at a
HIGH level during Idle. All
registers remain unchanged.
CLK is stopped. On-chip
SRAM and SFR data is maintained. ALE and PSEN# signals at a LOW level during
power -down. External Interrupts are only active for level
sensitive interrupts , if
enabled.
12.2 Power-down Mode
The power-down mode is entered by setting the PD bit in
the PCON register. In the power-down mode, the clock is
stopped and external interrupts are active for level sensitive
interrupts only. SRAM contents are retained during powerdown, the minimu m V
The device exits power-down mode through either an
enabled external level sensitive interrupt or a hardware
reset. The star t of the int errup t clears the PD bi t and exits
power-down. Holding the external interrupt pin low restarts
the oscillator, the signal must hol d low at least 1024 c lock
cycles before bringing back high to complete the exit. Upon
interrupt si gnal b eing re st ored t o logic V
tion of the interrupt service routine will execute. A hardware
reset starts the device similar to power-on reset.
To exit properly out of power-down, the reset or external
interrupt should not be executed before the V
restored to its normal operating voltage. Be sure to hold
V
voltage long enough at its normal operating level for
DD
the oscillator to restart and stabilize (normally less than
10 ms).
level is 2.0V.
DD
the first instruc-
IH,
line is
DD
Enabled interrupt or hardware reset.
Start of interrupt clears IDL bit and
exits idle mode, after the ISR RETI
instruc tion, program r esumes execution beginning at the instruction following the one that invoked idle m ode. A
user could consider placing two or
three NOP instructions after the
instruction that invokes idle mode to
eliminate any problems. A hardware
reset restarts t he device similar t o a
power-on rese t.
Enabled external level sensitive interrupt or hardware reset. Start of interrupt clears PD bit and exits powerdown mode, after the ISR RETI
instruction program resumes execution
beginning at the instruction following
the one that invoked power-down
mode. A user could consider placing
two or three NOP instructions after th e
instruction that invokes power -down
mode to eliminate any problems. A
hardware reset restarts the de vice s imilar to a power-on reset.
13.1 Clock Input Options and Recommended Capacitor Values for Oscillator
Shown in Figure 13 -1 are the i nput a nd out put of an internal inverting am plifier ( XTAL1, XTAL2), which can be configured for use as an on-chip oscillator.
When driving the device from an external clock source,
XTAL2 should be l eft disconne cted and XTAL1 should be
driven.
At star t-up, the external oscillat or may encoun ter a high er
capacitive load at XTAL1 due to interaction between the
amplifier and its feedback capacitance. However, the
capacitance will not exceed 15 pF once the external signal
meets the V
Crystal manufacturer, supply voltage, and other factors
may cause circuit perfor mance to differ from one application to another. C1 and C2 shou ld be adjusted appropr iately fo r each design. Table 13-1, shows the typical values
for C1 and C2 vs. crystal type for various frequencies
TABL E 13-1:RECOMMENDED VALUESFOR C1 AND
and VIH specifications.
IL
C2
BY CRYSTAL TYPE
CrystalC1 = C2
Quartz20-30pF
Ceramic40-50pF
T13-1.0 1255
More specific information about on-chip oscillator design
can be found in the
Considera tions
FlashFlex51 Oscill ator Circuit Des ign
application note.
13.2 Clock Doubling Option
By default, the device runs at 12 clo cks pe r mac h in e c ycl e
(x1 mode). The device has a clock doubling option to
speed up to 6 clocks per ma chine cycle. Please refer to
Table 13-2 for detail.
Clock double mode can be e nabled eit her vi a the external
host mode or the IAP mode. Please refer to Table 4-1 for
the ext e rnal ho st mo de en a bling command an d t o Table 46 and Table 4-7 for the IAP mode enabling commands
(When set, the EDC# bit in SFST register will indicate 6
clock mode.).
The clock double mode is only for doubling the internal system clock and the internal flash memory, i.e.
EA#=1. To access the external memory and the peripheral
devices, careful consideration must be taken. Also note
that the crystal output (XTAL2) will not be doubled.
Absolute Maximum Stress Ratings (Applied conditions greater than those listed under “Absolute Maximum
Stress Ratings” may cause pe r manent dama ge to the device. This is a stres s rating only and funct ional operatio n
of the device at these conditions or conditions greater tha n those defined in the ope rational sections of this data
sheet is not implied. Exposure to absolute maximum stress rating conditions may affect device reliability.)
1. Outputs shorted for no more than one second. No more than one output shorted at a time.
(Based on package heat transfer limitations, not device power consumption.
Note: This specification contains preliminary information on new products in production.
The specifications are subject to change without notice.
1. Under steady state (non-transient) conditions, IOL must be externally limited as follows:
Maximum I
Maximum I
Maximum I
If I
OL
Pins are not guaranteed to sink current greater than the listed test conditions.
2. Capacitive loading on Ports 0 & 2 may cause spurious noise to be superimposed on the V
to external bus capacitance discharging into the Port 0 & 2 pins when the pins make 1-to-0 transitions during bus operations. In the
worst cases (capacitive loading > 100pF), the noise pulse on the ALE pin may exceed 0.8V. In such cases, it may be desirable to
qualify ALE with a Schmitt Trigger, or use an address latch with a Schmitt Trigger STROBE input.
3. Load capacitance for Port 0, ALE & PSEN#= 100pF, load capacitance for all other outputs = 80pF.
4. Capacitive loading on Ports 0 & 2 may cause the V
the address bits are stabilizing.
5. Pins of Ports 1, 2 & 3 source a transition current when they are being externally driven from 1 to 0. The transition current reaches its
maximum value when V
6. Pin capacitance is characterized but not tested. EA# is 25pF (max).
per port pin:15mA
OL
per 8-bit port:26mA
OL
total for all outputs:71mA
OL
exceeds the test condition, VOL may exceed the related specification.
on ALE and PSEN# to momentarily fall below the VDD - 0.7 specification when
2. Capacitive loading on Ports 0 & 2 may cause spurious noise to be superimposed on the VOLs of ALE and Ports 1 & 3. The noise due
to external bus capacitance discharging into the Port 0 & 2 pins when the pins make 1-to-0 transitions during bus operations. In the
worst cases (capacitive loading > 100pF), the noise pulse on the ALE pin may exceed 0.8V. In such cases, it may be desirable to
qualify ALE with a Schmitt Trigger, or use an address latch with a Schmitt Trigger STROBE input.
3. Load capacitance for Port 0, ALE & PSEN#= 100pF, load capacitance for all other outputs = 80pF.
4. Capacitive loading on Ports 0 & 2 may cause the V
the address bits are stabilizing.
5. Pins of Ports 1, 2 & 3 source a transition current when they are being externally driven from 1 to 0. The transition current reaches its
maximum value when V
6. Pin capacitance is characterized but not tested. EA# is 25pF (max).
is approximately 2V.
IN
on ALE and PSEN# to momentarily fall below the VDD - 0.7 specification when
RD# Low to Address Float000ns
RD# to WR# High to ALE High555T
1040T
- 25 (3V)T
CLCL
- 15 (5V)T
CLCL
+ 25 (3V) ns
CLCL
+ 15 (5V)ns
CLCL
T14-8.0 1255
Explanation of Symbols Each timing symbol has 5 characters. The first character is always a ‘T’ (stands for
time). The other characters, depending on their positions, stand for the name of a signal or the logical status of that
signal. The following is a list of all the characters and what they stand for.
A: AddressQ: Output data
C: ClockR: RD# signal
D: Input dataT: Time
H: Logic level HIGHV: Valid
I:Instruction (program memory contents)W: WR# signal
L: Logic level LOW or ALEX: No longer a valid logic level
P: PSEN#Z: High Impedance (Float)
Serial Port Clock Cycle Time1.00.312T
Output Data Setup to Clock Rising Edge70011710T
Output Data Hold After Clock Rising Edge502 T
Input Data Hold After Clock Rising Edge000ns
Clock Rising Edge to Input Data Valid70011710T
Min Max MinMaxMinMax
CLCL
- 133ns
CLCL
- 117ns
CLCL
02T
- 50ns
CLCL
Preliminary Specifications
Units
µs
- 133ns
CLCL
T14-10.0 1255
INSTRUCTION
ALE
0
12345678
T
XLXL
CLOCK
T
XHQX
T
T
XHDV
VALIDVALIDVALIDVALIDVALIDVALIDVALIDVALID
XHDX
OUTPUT DATA
WRITE TO SBUF
INPUT DATA
CLEAR RI
T
QVXH
01 234 567
FIGURE 14-7: SHIFT REGISTER MODE TIM IN G WAVEFORMS
V
IHT
V
ILT
AC Inputs during testing are driven at V
V
(0.45V) for a Logic "0". Measurement reference points for inputs and
ILT
outputs are at V
HT
V
HT
V
LT
(VDD -0.5V) for Logic "1" and
IHT
(0.2VDD + 0.9) and VLT (0.2VDD - 0.1)
Note: VHT- V
VLT- V
V
IHT-VINPUT
V
ILT
1255 F40.0
HIGH
LOW
- V
INPUT
Test
Test
HIGH Test
LOW Test
SET TI
SET R I
1255 F39.0
V
+0.1V
LOAD
V
LOAD
V
-0.1V
LOAD
For timing purposes, a port pin is no longer floating when a 100 mV
change from load voltage occurs, and begins to float when a 100 mV
change from the loaded VOH/VOL level occurs. IOL/I
TABL E 14-11: EXTERNAL MODE FLASH MEMORY PROGRAMMING/VERIFICATION PARAMETERS
Parameter
Reset Setup TimeT
Read-ID Command WidthT
PSEN# Setup TimeT
Address, Command, Data Setu p TimeT
Chip-Erase TimeT
Block-Erase TimeT
Sector-Erase TimeT
Program Setup TimeT
Address, Command, Data HoldT
Byte-Program Time
Select-Block Program TimeT
Re-map or Security bit Program TimeT
Verify Command Delay TimeT
Verify High Order Address Delay TimeT
V eri fy Lo w Ord er Addres s Delay TimeT
1. For IAP operations, the program execution overhead must be added to the above timing parameters.
2. Program and Erase times will scale inversely proportional to programming clock frequency.
3. All timing measurements are from the 50% of the input to 50% of the output.
Programs the addressed cod e byte if the byte location has be en successfully erased and not yet programmed .
Byte-Program operation is only allowed when the security lock is not activated on that flash memory block.
T
SU
RST
T
T
ES
ADS
T
PROG
T
DH
PSEN#
ALE/PROG#
EA#
P3[3]
T
PS
P3[7:6], P2[7:6]
FIGURE 14-21: P
ROG-SB1 / PROG-SB2 / PROG-SB3
1111b / 0011b / 0101b
1255 F53.0
Programs the Security bits SB1, SB2 and SB3 respectively . Only a Chip-Erase will erase a programmed security bit.
Programs the star t-up configuration bit SC0/SC1. O nly a Chip-Erase will erase a programmed SC0/SC1 bit.
Prog-SC1 applies to SST89E5 xRD 2/S ST89V5xRD2 only.
T
SU
RST
PSEN#
ALE/PROG#
EA#
P3[7:6], P2[7:6]
P0
P1
T
ES
T
OA
1100b
T
AHA
DO
AL
T
ALA
P3[5:4], P2[5:0]
FIGURE 14-23: B
YTE-VERIFY
AH
1255 F55.0
Reads the code byte from the addres sed flas h memory location if the secur ity lock is not act ivated on that flas h
memory block.
Note: 1. Complies with JEDEC publication 95 MS-011 AC dimensions (except as noted), although some dimensions may be more stringent.
† = JEDEC min is .115; SST min is
2. All linear dimensions are in inches (min/max).
3. Dimensions do not include mold flash. Maximum allowable mold flash is .010 inches.
Note: 1. Complies with JEDEC publication 95 MS-018 AC dimensions (except as noted), although some dimensions may be more stringent.
† = JEDEC min is .650; SST min is
2. All linear dimensions are in inches (min/max).
3. Dimensions do not include mold flash. Maximum allowable mold flash is .008 inches.