ST ST7263 User Manual

查询ST72631供应商
ST7263
LOW SPEED USB 8-BIT MCU F AMILY with up to 16K MEMORY,
up to 512 BYTES RAM, 8-BIT ADC, WDG, TIMER, SCI
Up to 16Kbytes program memory
Data RAM: up to 512 bytes with 64 bytes stack
Run, Wait and Halt CPU modes
12 or 24 MH z os c illator
RAM retention mode
USB (Universal Serial Bus) Interface with DMA
for low speed applications compliant with USB
1.5 Mbs specification (version 1.1) and USB HID specifications (version 1.0)
Integrated 3.3V voltage regulator and
transceivers
Suspend and Resume operations
3 endpoints with programmable in/out
configuration
19 programmable I/O lines with:
– 8 high current I/Os (10mA at 1.3V) – 2 very high current pure Open Drain I/Os
(25mA at 1.5V)
– 8 lines individually programmable as interrupt
inputs
Optional Low Voltage Detector (LVD)
Programmable Watchdog for system reliability
16-bit Timer with:
– 2 Input Captures – 2 Output Compares – PWM Generation capabilities – External Clock input
Asynchronous Serial Communications Interface
(8K and 16K program memory versions only)
2
I
C Multi Master Interface up to 400 KHz
(16K program memory version only)
8-bit A/D Converter (ADC) with 8 channels
Fully static operation
63 basic instructions
17 main addressing modes
8x8 unsigned multiply instruction
True bit manipulation
Versatile Development Tools (und er Windows)
including assembler, linker, C-compiler, archiver, source level debugger, software library, hardware emulator, programming boards and gang programmers
PSDIP32
CSDIP32W
SO34 (Shrink)
& I2C
Table 1. Device Summary
Features
ROM - OTP (bytes) 16K 8K 4K RAM (stack) - bytes 512 (64) 256 (64)
Peripherals Operating Supply 4.0V to 5.5V
CPU frequency 8 Mhz (with 24 MHz oscillator) or 4 MHz (with 12 MHz oscillator) Operating temperature 0°C to +70°C
Packages SO34/SDIP32 EPROM device ST72E631
Watchdog, 16-bit timer, SCI, I
Note 1: EPROM version for development only
August 2000 1/109
ST72631
USB
2
C, ADC,
ST72632 ST72633
Watchdog, 16-bit timer,
SCI, ADC, USB
1
(CSDIP32W)
Watchdog, 16-bit timer,
ADC, USB
Rev. 1.8
1
Table of Contents
1 GENERAL DESCRIPTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.1 INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.2 PIN DESCRIPTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.3 EXTERNAL CONNECTIONS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.4 REGISTER & MEMORY MAP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.5 EPROM/OTP PROGRAM MEMORY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1.5.1 EPROM ERASURE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2 CENTRAL PROCESSING UNIT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.1 INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.2 MAIN FEATURES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.3 CPU REGISTERS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3 CLOCKS AND RESET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.1 CLOCK SYSTEM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.1.1 General Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.1.2 External Clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.2 RESET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.2.1 Low Voltage Detector (LVD) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.2.2 Watchdog Reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.2.3 External Reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
4 INTERRUPTS AND POWER SAVING MODES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
4.1 INTERRUPTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
4.1.1 Interrupt Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
4.2 POWER SAVING MODES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.2.2 HALT mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.2.3 WAIT mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
5 ON-CHIP PERIPHERALS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
5.1 I/O PORTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
5.1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
5.1.2 Functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
5.1.3 I/O Port Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
5.1.4 Port A . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
5.1.5 Port B . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
5.1.6 Port C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
5.1.7 Register Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
5.2 MISCELLANEOUS REGISTER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
5.3 WATCHDOG TIMER (WDG) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
5.3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
5.3.2 Main Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
5.3.3 Functional Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
5.3.4 Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
5.3.5 Register Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
5.4 16-BIT TIMER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
5.4.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
5.4.2 Main Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
109
2/109
Table of Contents
5.4.3 Functional Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
5.4.4 Low Power Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
5.4.5 Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
5.4.6 Summary of Timer modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
5.4.7 Register Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
5.5 SERIAL COMMUNICATIONS INTERFACE (SCI) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
5.5.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
5.5.2 Main Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
5.5.3 General Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
5.5.4 Functional Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
5.5.5 Low Power Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
5.5.6 Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
5.5.7 Register Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
5.6 USB INTERFACE (USB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
5.6.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
5.6.2 Main Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
5.6.3 Functional Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
5.6.4 Register Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
5.6.5 Programming Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
5.7 I²C BUS INTERFACE (I²C) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
5.7.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
5.7.2 Main Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
5.7.3 General Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
5.7.4 Functional Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
5.7.5 Low Power Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
5.7.6 Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
5.7.7 Register Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
5.8 8-BIT A/D CONVERTER (ADC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
5.8.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
5.8.2 Main Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
5.8.3 Functional Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
5.8.4 Low Power Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
5.8.5 Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
5.8.6 Register Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
6 INSTRUCTION SET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
6.1 ST7 ADDRESSING MODES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
6.1.1 Inherent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
6.1.2 Immediate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
6.1.3 Direct . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
6.1.4 Indexed (No Offset, Short, Long) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
6.1.5 Indirect (Short, Long) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
6.1.6 Indirect Indexed (Short, Long) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
6.1.7 Relative Mode (Direct, Indirect) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
6.2 INSTRUCTION GROUPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
7 ELECTRICAL CHARACTERISTICS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
7.1 ABSOLUTE MAXIMUM RATINGS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
7.2 THERMAL CHARACTERISTICS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
3/109
ST7263
7.3 OPERATING CONDITIONS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
7.4 POWER CONSUMPTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
7.5 I/O PORT CHARACTERISTICS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
7.6 LOW VOLTAGE DETECTOR (LVD) CHARACTERISTICS . . . . . . . . . . . . . . . . . . . . . . . . 98
7.7 CONTROL TIMING CHARACTERISTICS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
7.8 COMMUNICATION INTERFACE CHARACTERISTICS . . . . . . . . . . . . . . . . . . . . . . . . . . 99
7.8.1 USB - Universal Bus Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
7.8.2 I2C - Inter IC Control Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
7.9 8-BIT ADC CHARACTERISTICS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
8 PACKAGE CHARACTERISTICS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
8.1 PACKAGE MECHANICAL DATA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
9 DEVICE CONFIGURATION AND ORDERING INFORMATION . . . . . . . . . . . . . . . . . . . . . . . . 106
9.1 DEVICE ORDERING INFORMATION AND TRANSFER OF CUSTOMER CODE . . . . . 106
9.2 ST7 APPLICATION NOTES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
9.3 TO GET MORE INFORMATION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
10 SUMMARY OF CHANGES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
4/109
1 GENERAL DESCRIPTION
1.1 INTRODUCTION
ST7263
The ST7263 Microcontrollers form a sub family of the ST7 dedicated to USB applications. The de­vices are based on an industry-standard 8-bit core and feature an enhanced instruction set. They op­erate at a 24MHz or 12 MHz oscillator frequency. Under software control, the ST7263 MCUs may be placed in either Wait or Halt modes, thus reducing power consumption. The enhanced instruction set and addressing modes afford real programming potential. In addition to standard 8-bit data man­agement, the ST7263 MCUs feature true bit ma­nipulation, 8x8 unsigned multiplication and indirect addressing modes. The devices include an ST7 Core, up to 16K program memory, up to 512 bytes RAM, 19 I/O lines and the following on-chip pe­ripherals:
– USB low speed interface with 3 endpoints with
programmable in/out configuration using the DMA architecture with embedded 3.3V voltage regulator and transceivers (no external compo­nents are needed).
– 8-bit Analog-to-Digital converter (ADC) with 8
multiplexed analog inputs
Figure 1. General Block Diagram
Internal CLOCK
OSCIN
OSCOUT
V V
RESET
DD
SS
OSCILLATOR
POWER
SUPPLY
WATCHDOG
CONTROL
8-BIT CO RE
ALU
LVD
USB DMA
OSC/3
OSC/4 or OSC/2
(for USB)
– industry standard asynchronous SCI serial inter-
face (not on all products - see device summary
below) – digital Watchdog – 16-bit Timer featuring an External clock input, 2
Input Captures, 2 Output Compares with Pulse
Generator capabilit ies – fast I2C Multi Master interface (not on all prod-
ucts - see device summary) – Low voltage (LVD) reset ensuring proper power-
on or power-off of the device All ST7263 MCUs are available in ROM and OTP
versions. The ST72E631 is the EPROM version of the
ST7263 in CSDIP32 windowed packages. A specific mode is available to allow programming
of the EPROM user memory array. This is set by a specific voltage source applied to the V
PP
pin.
I2C*
PORT A
16-BI TTIMER
ADDRESS AND DATA BUS
PORT B
ADC
PORT C
SCI*
(UART)
PA[7:0]
(8 bits)
PB[7:0]
(8 bits)
PC[2:0]
(3 bits)
/TEST
VPP/TEST
V
DDA
V
SSA
* not on all products ( ref er to Table 1: Device Summary)
PROGRAM
MEMORY
(4K/8K/16K Byte s)
RAM
(256/512 Bytes)
USB SIE
USBDP USBDM USBVCC
5/109
ST7263
1.2 PIN DESCRI PTION Figure 2. 34-Pin SO Package Pinout
OSCOUT
OSCIN
PC2/USBOE
PC1/TDO
PC0/RDI
RESET
AIN7/IT8/PB7 AIN6/IT7/PB6
AIN5/IT6/PB5 AIN4/IT5/PB4
* V
on EPROM/OTP versions only
PP
AIN3/PB3 AIN2/PB2 AIN1/PB1
(10mA) (10mA)
VPP/TEST
(10mA) (10mA) (10mA) (10mA) (10mA)
V
V
DD
SS
NC
1 2 3 4 5 6 7 8 9 10 11 12 13
14 15 16
17
V
34
DDA
USBVCC
33
USBDM
32
USBDP
31
V
30
SSA
PA0/MCO
29
PA1
28
NC
27
NC
26
NC
25
PA2
24 23
PA3/EXTCLK
22
PA4/ICAP1/IT1 PA5/ICAP2/IT2
21
PA6/OCMP1/IT3
20
PA7/OCMP2/IT4
19
PB0
18
(25mA)
(25mA)
(10mA)
/SDA
/SCL
/AIN0
Figure 3. 32-Pin SDIP Package Pinout
V
DD
OSCOUT
OSCIN
V
SS
PC2/USBOE
PC1/TDO
PC0/RDI
RESET
AIN7/IT8/PB7
AIN6/IT7/PB6
AIN5/IT6/PB5 AIN4/IT5/PB4
* V
on EPROM/OTP versions only
PP
AIN3/PB3 AIN2/PB2
AIN1/PB1/
(10mA)
(10mA)
VPP/TEST*
(10mA) (10mA) (10mA) (10mA) (10mA)
10 11 12 13 14 15 16
1 2 3 4 5 6 7 8 9
V
32
USBVCC
31
USBDM
30
USBDP
29
V
28
PA0/MCO
27
PA1
26 25 24
PA2
23
PA3/EXTCLK
22 21
PA4/ICAP1/IT1 PA5/ICAP2/IT2
20
PA6/COMP1/IT3
19
PA7/COMP2/IT4
18
PB0
17
DDA
NC NC
SSA
(25mA)
(25mA)
(10mA)
/SDA
/SCL
/AIN0
6/109
PIN DESCRIPTION (Cont’d) RESET
(see Note 1): Bidirectional. This active low
signal forces the initialization of the MCU. This event is the top priority non maskable interrupt. This pin is switched low when the Watchdog has triggered or V
is low. It can be used to reset ex-
DD
ternal peripherals. OSCIN/OSCOUT: Input/Output Oscillator pin.
These pins connect a pa rallel-resonant crystal, or an external sou rc e to the on -c h ip o s cilla t o r.
V
/TEST: EPROM programming input. This pin
PP
must be held low during normal operating modes.
V
DD/VSS
(see Note 2): Main power supply and
Ground voltages.
V
DDA/VSSA
(see Note 2): Power Supply and
Ground for analog peripherals.
Table 2. Device Pin Description
ST7263
Alter na te Fu nct i ons : Several pins of the I/O ports
assume software programmable alternate func­tions as shown in the pin description.
Note 1: Adding t wo 100nF de coupling capa citors
V
together
DD
DD
and
on Reset pin (respectively connected to
V
) will significantly improve produc t electromag-
SS
netic susceptibility performances. Note 2: To enhance reliability of operation, it is
recommended to conn ect
V
DDA
and V
on the application board. The same recommenda-
V
tions apply to
and VSS.
SSA
Pin n°
Pin Name
SO34
SDIP32
11V 2 2 OSCOUT O Oscillator output 3 3 OSCIN I Oscillator input 44V 5 5 PC2/USBOE I/O C 6 6 PC1/TDO I/O C 7 7 PC0/RDI I/O C 8 8 RESET I/O X X Reset
-- 9 NC -- Not connected
9 10 PB7/AIN7/IT8 I/O C 10 11 PB6/AIN6/IT7 I/O C 11 12 V 12 13 PB5/AIN5/IT6 I/O C 13 14 PB4/AIN4/IT5 I/O C 14 15 PB3/AIN3 I/O C 15 16 PB2/AIN2 I/O C 16 17 PB1/AIN1 I/O C 17 18 PB0/AIN0 I/O C 18 19 PA7/OCMP2/IT4 I/O C 19 20 PA6/OCMP1/IT3 I/O C
DD
SS
/TEST S Supply for EPROM and test input
PP
Level Port / Control
Input Output
Type
Input
Output
float
S Power supply voltage (4V - 5.5V)
S Digital ground
T T T
10mA X XX XPort B7 ADC analog input 7
T
10mA X XX XPort B6 ADC analog input 6
T
10mA X XX XPort B5 ADC analog input 5
T
10mA X XX XPort B4 ADC analog input 4
T
10mA X XXPort B3 ADC analog input 3
T
10mA X XXPort B2 ADC analog input 2
T
10mA X XXPort B1 ADC analog input 1
T
10mA X XXPort B0 ADC Analog Input 0
T
T T
int
wpu
X X Port C2 USB Output Enable X X Port C1 SCI transmit data output X X Port C0 SCI Receive Data Input
X XXPort A7 Timer Output Compare 2 X XXPort A6 Timer Output Compare 1
OD
ana
Main
Function
(after reset)
PP
Alternate Function
*)
*)
7/109
ST7263
Pin n°
Pin Name
SO34
SDIP32
20 21 PA5/ICAP2/IT2 I/O C 21 22 PA4/ICAP 1/IT1 I/O C 22 23 PA3/EXTC LK I/O C 23 24 PA2/SCL I/O C
-- 25 NC -- Not connected 24 26 NC -- Not connected 25 27 NC -- Not connected 26 28 PA1/SDA I/O C 27 29 PA0/MCO I/O C 28 30 V 29 31 USBDP I/O USB bidirectional data (data +) 30 32 USBDM I/O USB bidirectional data (data -) 31 33 USBVCC O USB power supply 32 34 V
SSA
DDA
Level Port / Control
Input Output
Type
Input
Output
float
T T T
25mA X T Port A2 I2C serial clock
T
25mA X T Port A1 I2C serial data
T
T
S Analog ground
S Analog supply voltage
int
wpu
X XXPort A5 Timer Input Captu re 2 X XXPort A4 Timer Input Captu re 1 X X Port A3 Timer External Clock
XXPort A0 Main Clock Output
OD
ana
Main
Function
(after reset)
PP
Alternate Function
*)
*)
*: if the peripheral is present on the device (see Table 1 Device Summary)
Legend / Abbreviations for Figure 2 and Tab le 2:
Type: I = input, O = output, S = supply In/Output lev e l: C
= CMOS 0.3VDD/0.7VDD with input trigger
T
Output level: 10mA = 10mA high sink (on N-buffer only)
25mA = 25mA very high sink (on N-buffer only)
Port and control configuration:
– Input: float = floating, wpu = weak pull-up, int = interrupt, ana = analog
– Output : OD = open drain, PP = push-pull, T = True open drain Refer to “I/O PORTS” on page 25 for more details on the software configuration of the I/O ports. The RESET configuration of each pin is shown in bold. This configuration is kept as long as the device is
under reset state.
8/109
1.3 EXTERNAL CONNECTIONS
ST7263
The following figure shows the recom mended ex­ternal connections for the device.
The V
pin is only used for programming OTP
PP
and EPROM devices and must be tied to ground in user mode.
The 10 nF and 0. 1 µF decoupling capacitors on the power supply lines are a suggested EMC per­formance/cost tradeoff.
Figure 4. Recommended Extern al Connec tions
V
DD
Optional if Low Voltage Detector (LVD) is used
EXTERNAL RESET CIRCUIT
10nF
+
V
DD
0.1µF
0.1µF
The external reset network is intended to protect the device against parasitic resets, especially in noisy environments.
Unused I/Os shoul d be t ied hi gh to av oid any un­necessary power consumption on floating lines. An alternative solution is to program the unused ports as inputs with pull-up.
V
PP
V
4.7K
DD
V
SS
RESET
0.1µF
See Clocks Section
Or configure unused I/O ports by software as input with pull-up
V
10K
DD
OSCIN
OSCOUT
Unused I/O
9/109
ST7263
1.4 REGISTER & MEMORY MAP
As sho wn in Figure 5, the MCU is capable of ad- dressing 64K bytes of memories and I/O registers.
The available memory locations consist of 192 bytes of register location, up to 512 bytes of RAM and up to 16K bytes of user program memory. The RAM space includes up to 64 bytes for the stack from 0100h to 013Fh.
Figure 5. Me m ory Map
0000h
003Fh 0040h
023Fh
0240h
BFFFh C000h
E000h
F000h
FFEFh FFF0h
FFFFh
HW Registers
(see Table 4
256 Bytes RAM*
512 Bytes RAM*
Reserved
Program Memory*
16K Bytes
8K Bytes
4K Bytes
Interrupt & Reset Vectors (see Table 3 on page 10)
The highest address by tes contain the user re set and interrupt vectors.
IMPORTANT: Memory locations noted “Re­served” must neve r be ac cess ed. A cce ssing a re­served area can have unpredictable effects on the device
0040h
00FFh 0100h
013Fh
0040h
00FFh 0100h
013Fh 0140h
023Fh
Short Addressing RAM (192 Bytes)
Stack (64 Bytes)
Short Addressing RAM (192 Bytes)
Stack (64 Bytes)
16-bit Addressing RAM
(256 Bytes)
* Program memory and RAM sizes are product dependent (see Table 1 Device Summary)
Table 3. Interrupt Vector Map
Vector Address Description Masked by Remarks Exit from Halt Mode
FFF0-FFF1h FFF2-FFF3h FFF4-FFF5h FFF6-FFF7h
FFF8-FFF9h FFFA-FFFBh FFFC-FFFDh FFFE-FFFFh
USB End Suspend Mode Interrupt Vector
USB Interrupt Vector SCI Interrupt Vector*
2
C Interrupt Vector*
I
TIMER Interrupt Vector
IT1 to IT8 Interrupt Vector
TRAP (software) Interrupt Vector
RESET Vector
I- bit I- bit I- bit I- bit I- bit
I- bit none none
Internal Interrupt Internal Interrupt Internal Interrupt Internal Interrupt
External Interrupts
Internal Interrupt
CPU Interrupt
No No No
No Yes Yes
No Yes
* If the peripheral is present on the device (see Table 1 Device Summary)
10/109
ST7263
Table 4. Hardware Register Memory Map
Address Block Register Label Register name Reset Status Remarks
0000h 0001h
0002h 0003h
0004h 0005h
0006h 0007h
0008h ITIFRE Interrupt Register 00h R/W 0009h MISCR Miscellaneous Register F0h R/W 000Ah
000Bh 000Ch WDG CR Watchdog Control Register 7Fh R/W 000Dh
0010h 0011h
0012h 0013h 0014h 0015h 0016h 0017h 0018h 0019h 001Ah 001Bh 001Ch 001Dh 001Eh 001Fh
0020h 0021h 0022h 0023h 0024h
ADC
TIM
SCI
1)
PADR PADDR
PBDR PBDDR
PCDR PCDDR
DR CSR
CR2 CR1 SR IC1HR IC1LR OC1HR OC1LR CHR CLR ACHR ACLR IC2HR IC2LR OC2HR OC2LR
SR DR BRR CR1 CR2
Port A Data Register Port A Data Direction Register
Port B Data Register Port B Data Direction Register
Port C Data Register Port C Data Direction Register
Reserved (2 Bytes)
ADC Data Register ADC control Status register
Reserved (4 Bytes)
Timer Control Register 2 Timer Control Register 1 Timer Status Register Timer Input Capture High Register 1 Timer Input Capture Low Register 1 Timer Output Compare High Register 1 Timer Output Compare Low Register 1 Timer Counter High Register Timer Counter Low Register Timer Alternate Counter High Register Timer Alternate Counter Low Register Timer Input Capture High Register 2 Timer Input Capture Low Register 2 Timer Output Compare High Register 2 Timer Output Compare Low Register 2
SCI Status Register SCI Data Register SCI Baud Rate Register SCI Control Register 1 SCI Control Register 2
00h 00h
00h 00h
1111 x000b 1111 x000b
00h 00h
00h 00h 00h xxh xxh 80h 00h FFh FCh FFh FCh xxh xxh 80h 00h
C0h xxh 00xx xxxxb xxh 00h
R/W R/W
R/W R/W
R/W R/W
Read only R/W
R/W R/W Read only Read only Read only R/W R/W Read only R/W Read only R/W Read only Read only R/W R/W
Read only R/W R/W R/W R/W
11/109
ST7263
Address Block Register Label Register name Reset Status Remarks
0025h 0026h 0027h 0028h 0029h 002Ah 002Bh 002Ch 002Dh 002Eh 002Fh 0030h 0031h
0032h 0038h
0039h 003Ah 003Bh 003Ch 003Dh 003Eh 003Fh
USB
2C1)
I
PIDR DMAR IDR ISTR IMR CTLR DADDR EP0RA EP0RB EP1RA EP1RB EP2RA EP2RB
DR
OAR CCR SR2 SR1 CR
USB PID Register USB DMA address Register USB Interrupt/DMA Register USB Interrupt Status Register USB Interrupt Mask Register USB Control Register USB Device Address Register USB Endpoint 0 Register A USB Endpoint 0 Register B USB Endpoint 1 Register A USB Endpoint 1 Register B USB Endpoint 2 Register A USB Endpoint 2 Register B
Reserved (7 Bytes)
2
C Data Register
I Reserved I2C (7 Bits) Slave Address Register
2
C Clock Control Register
I
2
C 2nd Status Register
I
2
C 1st Status Register
I
2
C Control Register
I
xxh xxh xxh 00h 00h xxxx 0110b 00h 0000 xxxxb 80h 0000 xxxxb 0000 xxxxb 0000 xxxxb 0000 xxxxb
00h
­00h 00h 00h 00h 00h
Read only R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W
R/W
R/W R/W Read only Read only R/W
Note 1. If the peripheral is present on the device (see Table 1 Device Summary)
12/109
1.5 EPROM/OTP PROGRAM MEMORY
ST7263
The program memory of the ST72T63 may be pro­grammed using the EPR OM program m ing b oards available from STMicroelectronics (see Table 26).
1.5.1 EPROM ERASURE
ST72Exxx EPROM devices are erased by expo­sure to high intensity UV light admitted through the transparent window. This exposure discharges the floating gate to its initial state through induced photo current.
It is recommended that the ST72Exxx devices be kept out of direct sunlight, since the UV content of sunlight can be sufficient to cause functional fail­ure. Extended exposure t o room level fluorescent lighting may also cause erasure.
An opaque coating (paint, tape, label, etc...) should be placed over the package window if the product is to be operated under these lighting con­ditions. Covering the window also reduces I
DD
in power-saving modes du e to photo-diode leakage currents.
An Ultraviolet source of wave length 2537 Å yield­ing a total integrated dosage of 15 Watt-sec/cm
2
is required to erase the ST72Exxx. The device will be erased in 15 to 30 minutes if such a UV lamp with a 12mW/cm
2
power rating is placed 1 inch from the device window without any interposed fil­ters.
13/109
ST7263
2 CENTRAL PROCE SSI NG UNIT
2.1 INTRODUCTION
This CPU has a full 8-bit architecture and contains six internal registers allowing efficient 8-bit data manipulation.
2.2 MAIN FEATURES
63 basic instructions
Fast 8-bit by 8-bit multiply
17 main addressing modes
Two 8-bit index registers
16-bit stack pointer
Low po wer modes
Maskable hardware interrupts
Non-maskable software interrupt
2.3 CPU REGISTERS
The 6 CPU registers shown in Figure 1 are not present in the memory mapping and are accessed by specific instructions.
Figure 6. CPU Registers
70
RESET VALUE = XXh
70
RESET VALUE = XXh
70
RESET VALUE = XXh
Accumulator (A)
The Accumulator is an 8-bit general purpose reg­ister used to hold operan ds and the results of the arithmetic and logic calculations and to manipulate data.
Index Registers (X and Y)
In indexed addressing modes, these 8-bit registers are used to create either effective addresses or temporary storage areas for data manipulation. (The Cross-Assembler generates a precede in­struction (PRE) to indicate that the following in­struction refers to the Y register.)
The Y register is not affected by the interrupt auto­matic procedures (not pushed to and popped from the stack).
Program Cou nt er (P C )
The program counter is a 16-bit register containing the address of the next instruction to be executed by the CPU. It is made of two 8-bit registers PCL (Program Counter Low which is the LSB) and PCH (Program Counter High which is the MSB).
ACCUMULA T OR
X INDEX REGISTER
Y INDEX REGISTER
15 8
RESET VALUE = RESET VECTOR @ FFFEh-FFFFh
15
RESET VALUE = STACK HIGHER ADDRESS
14/109
PCH
RESET VALUE =
7
70
1C11HI NZ
1X11X1XX 70
8
PCL
0
PROGRAM COUNTER
CONDITION CODE REGISTER
STACK POINTER
X = Undefined Value
CPU REGISTERS (Cont’d) CONDITION CODE REGISTER (CC)
Read/Write Reset Value: 111x1xxx
70
111HINZC
The 8-bit Condition Code register c ontains the in­terrupt mask and four flags represent ative of the result of the instruction just executed. This register can also be handled by the PUSH and POP in­structions.
These bits can be individually tested and/or con­trolled by specific instructions.
because the I bi t is set by hardware at the start of the routine and reset by the IRET instruction at the end of the routine. If the I bit is cleared by software in the interrupt routine, pending interrupts are serviced regardless of the priority level of the cur­rent interrupt routine.
Bit 2 = N
Negative
.
This bit is set and cleared by hardware. It is repre­sentative of the result sign of the last arithmeti c, logical or data manipulation. It is a copy of the 7 bit of the result. 0: The result of the last operation is positive or null. 1: The result of the last operation is negative
(i.e. the most significant bit is a logic 1).
This bit is accessed by the JRMI and JRPL instruc-
Bit 4 = H
Half carry
.
tions.
This bit is set by hardware when a carry occurs be­tween bits 3 and 4 of t he ALU during an ADD or ADC instruction. It is reset by hardware during the same instructions. 0: No half carry has occurred. 1: A half carry has occurred.
This bit is tested using the JRH or JRNH instruc­tion. The H bit is useful in BCD arithmetic subrou­tines .
Bit 1 = Z This bit is set and cleared by hardware. This bit in-
dicates that the result of the last arithmetic, logical or data manipulation is zero. 0: The result of the last operation is different from
zero.
1: The result of the last operation is zero.
Zero
.
This bit is accessed by the JREQ and JRNE test instructions.
Bit 3 = I
Interrupt mask
This bit is set by hardware when entering in inter­rupt or by software to disable all interrup ts except the TRAP software interrupt. This bit is cleared by software. 0: Interrupts are enabled. 1: Interrupts are disabled.
This bit is controlled by the RIM, SIM and IRET in­structions and is tested by the JRM and JRNM in­structions.
Note: Interrupts requested while I is set are latched and can be processed whe n I is cleared.
.
Bit 0 = C
Carry/borrow.
This bit is set and cleared b y hardware and soft­ware. It indicates an overflow or an underflow has occurred during the last arithmetic operation. 0: No overflow or underflow has occurred. 1: An overflow or underflow has occurred.
This bit is driven by the SCF and RCF instructions and tested by the JRC and JRNC instructions. It is also affected by the “bit test and branch”, shift and rotate instructions.
By default an interrupt routine is not in terruptable
ST7263
th
15/109
ST7263
CPU REGISTERS (Cont’d) Stack Pointer (SP)
Read/Write Reset Value: 01 3Fh
15 8
00000001
70
0 0 SP5 SP4 SP3 SP2 SP1
SP0
The Stack Pointer is a 16-bit register which is al­ways pointing to the next free location in the stack. It is then decremented after data has been pushed onto the stack and incremented before data is popped from the stack (see Figure 7).
Since the stack is 64 bytes deep, the 10 most sig­nificant bits are forced by hardw are. Following a n MCU Reset, or after a Reset Stack Pointe r instruc­tion (RSP), the Stack Pointer contains its reset val­ue (SP5 to SP0 bits are set) which is the stack higher address.
The least significant byte of the Stack Pointer (called S) can be directly accessed by a LD in­struction.
Note: When the lower limit is exceeded, the Stack Pointer wraps around to the stack upper limit, wi th­out indicating the s tack overflow. The previously stored information is then o verwritten and there­fore lost. The stack also wraps in case of an under­flow.
The stack is used to save the retu rn address dur­ing a subroutine call and the CPU context during an interrupt. The user may also directly manipulate the stack by means of the PUSH and POP instruc­tions. In the case of an interrupt, the PCL is stored at the first location point ed to by the SP. Then the other registers are stored in the next locations as shown in Figure 7.
– When an interrupt is received, the SP is decre-
mented and the context is pushed on the stack.
– On return from interrupt, the SP is incremented
and the context is popped from the stack.
A subroutine call occupies two locations and an in­terrupt five locat ions i n the sta ck ar ea.
Figure 7. Stack Manipulation Example
@ 0100h
SP
@ 013Fh
CALL
Subroutine
SP
PCH PCL
Stack Higher Address = 013Fh Stack Lower Address =
Interrupt
Event
SP
CC
A
X PCH PCL PCH PCL
0100h
PUSH Y POP Y IRET
SP
Y
CC
A
X PCH PCL PCH
PCL
CC
A
X PCH PCL PCH PCL
SP
PCH
PCL
RET
or RSP
SP
16/109
3 CLOCKS AND RESET
3.1 CLOCK SYSTEM
ST7263
3.1.1 General Description
The MCU accepts either a Crystal or Ceramic res­onator, or an external clock signal to drive the in­ternal oscillator. The internal clock (f rived from the external oscillator frequency (f
CPU
) is de-
OSC
which is divided by 3 (and by 2 or 4 for USB, de­pending on the external clock used).
By setting the CLKDIV bit in the Miscellaneous Register, a 12 MHz external clock can be used giv­ing an internal frequency of 4 MHz while maintain­ing a 6 MHz for USB (refer to Figure 10).
The internal clock signal (f
) is also routed to
CPU
the on-chip peripherals. The CPU clock signal consists of a square wave with a duty cycle of 50%.
The internal oscillat or is designed to operate with an AT-cut parallel resonant quartz or ceramic res­onator in the frequency range specified for f
osc
The circuit shown in Figure 9 is recommended when using a crystal, and Table 5 Re commended
Values for 24 MHz Crystal Resonator lists the rec-
ommended capacitance. The crystal and associat­ed components should be mounted as close as possible to the input pins in order to minimize out­put distortion and start-up stabilisation time.
Figure 8. External Clock Source Connections
),
OSCIN OSCOUT
NC
EXTERNAL
CLOCK
Figure 9. Crystal/Ceramic Resonator
.
OSCOUT
R
P
C
OSCOUT
C
OSCIN
OSCIN
Table 5. Recommended Values for 24 MHz Crystal Resonator
R
SMAX
C
OSCIN
C
OSCOUT
R
P
Note: R crystal (see crystal specification).
SMAX
20
56pF 47pF 22pF 56pF 47pF 22pF
1-10 M
25
1-10 M
70
1-10 M
is the equivalent serial resistor of the
3.1.2 External Clock
An external clock may be applied to the OSCIN in­put with the OSCOUT pin not connected, as shown on F igure 8. The t
specifications does
OXOV
not apply when using an external clock input. The equivalent specification of the external clock source should be used instead of t
OXOV
(see Sec-
tion 6.5 CONTROL TIMING).
Figure 10. Clock block diagram
%3
CLKDIV
1
%2
24 or
12 MHz
Crystal
%2
0
%2
8 or 4 MHz CPU and
peripherals)
6 MHz (USB)
17/109
ST7263
3.2 RESET
The Reset procedure is used to provide an orderly software start-up or to exit low power modes.
Three reset modes are provided: a low voltage (LVD) reset, a watchdog reset and an external re­set at the RESET
pin.
A reset causes the reset vector to be fetched from addresses FFFEh and FFFFh in order to be loaded into the PC and with program execution starting from this point.
An internal circuitry provides a 4096 CPU clock cy­cle delay from the time that the oscillator becomes
During low voltage reset, the RESET thus permitting the MCU to reset other devices.
The Low Voltage Detector can be disabled by set­ting the LVD bit of the Miscellaneous Register.
3.2.2 Watchdog Reset
When a watchdog reset occurs, the RESET pulled low permitting the MCU to reset other devic­es in the same way as t he low voltage reset (Fig-
ure 11).
pin is held low,
pin is
active.
3.2.3 External Reset
3.2.1 Low Voltage Detector (LVD)
Low voltage reset circuitry generates a reset when V
is:
DD
below V
below V
when VDD is rising,
IT+
when VDD is falling.
IT-
The external reset is an active low input signal ap­plied to the RESET pin of the MCU. As shown in Figure 14, the RESET
signal must stay low for a minimum of one and a half CPU clock cycles.
An internal Schmitt trigger at the RESET
pin is pro-
vided to improve noise immunity.
Table 6. List of secti ons affect ed by RESET, WA IT and HAL T (Ref er t o 3.5 for Wait a nd Hal t Modes )
Section RESET WAIT HALT
CPU clock running at 8 MHz X Timer Prescaler reset to zero X Timer Counter set to FFFCh X All Timer enable bit set to 0 (disable) X Data Direction Registers set to 0 (as Inputs) X Set Stack Pointer to 013Fh X Force Internal Address Bus to restart vector FFFEh,FFFFh X Set Interrupt Mask Bit (I-Bit, CCR) to 1 (Interrupt Disable) X Set Interrupt Mask Bit (I-Bit, CCR) to 0 (Interrupt Enable) X X Reset HALT latch X Reset WAIT latch X Disable Oscillator (for 4096 cycles) X X Set Timer Clock to 0 X X Watchdog counter reset X Watchdog register reset X Port data registers reset X Other on-chip peripherals: registers reset X
18/109
ST7263
Figure 11. Low Voltage Detector functional Diagram
RESET
V
DD
LOW VOLTAGE
DETECTOR
FROM
WATCHDOG
RESET
INTERNAL
RESET
Figure 12. Low Voltage Reset Signal Output
V
IT+
V
DD
RESET
Note: Hysteresis (V
Figure 13. Temporization timing diagram after an internal Reset
V
V
DD
Addresses
IT+
temporization (4096 CPU clock cycles)
$FFFE
IT+-VIT-
) = V
hys
V
IT-
Figure 14. Reset Timing Diagram
t
DDR
V
DD
OSCIN
t
OXOV
f
CPU
PC
RESET
WATCHDOG RESET
Note: Refer to Electrical Characteristics for values of t
4096 CPU
CLOCK
CYCLES
, t
DDR
DELAY
OXOV
FFFE
, V
IT+
, V
FFFF
IT-
and V
hys
19/109
ST7263
4 INTERRUPTS AND POWER SAVING MODES
4.1 INTERRUPTS
The ST7 core may be interrupted by one of two dif­ferent methods: maskable hardware interrupts as listed in Table 7 Interrupt Mapping and a non- maskable software interrupt (TRAP). The Interrupt processing flowchart is shown in Figure 15.
The maskable interrupts must be enabled clearing the I bit in order to be serviced. However, disabled interrupts may be latched and processed when they are enabled (see external interrupts subsec ­tion) .
When an interrupt has to be serviced:
– Normal processing is suspended at the end of
the current instruction execution.
– The PC, X, A and CC registers are saved onto
the stack.
– The I bit of the CC register is set to prevent addi-
tional interrupts.
– The PC is then loaded with the interrupt vector of
the interrupt to service and the first instruction of the interrupt service routine is fetched (refer to
Table 7 Interrupt Mapping for vector addresses).
The interrupt service routine should finish with the IRET instruction which c auses the conten ts o f the saved registers to be recovered from the stack.
Note: As a consequence of the IRET instruction, the I bit will be cleared a nd the main pro gram will resume.
Priority management
By default, a servicing interrupt can not be inter­rupted because the I bit is set by hardware enter­ing in interrupt routine.
In the case several interrupts are simultaneously pending, a hardware priority defines which one will be serviced first (see Table 7 Interrupt Mapping).
Non maskable software interrupts
This interrupt is entered when the TRAP instruc­tion is executed regardless of the state of the I bit. It will be serviced according to the flowchart on
Figure 15.
Interrupts a n d Low power mod e
All interrupts allow the processor to leave the Wait low power mode. Only external and specific men­tioned interrupts allow the processor to leave the Halt low power mode (refer to t he “Exit f rom HALT“ column in Table 7 Interrupt Mapping).
External interrupts
The pins ITi/PAk and ITj/P Bk (i=1,2; j= 5,6; k=4,5) can generate an i nterrupt when a rising edge oc­curs on this pin. Conversely, pins ITl/PAn and ITm/ PBn (l=3,4; m= 7,8; n=6,7) can generat e an inter­rupt when a falling edge occurs on this pin.
Interrupt generation will occur if it is enabl ed with the ITiE bit (i=1 to 8) in the ITRFRE register and if the I bit of the CCR is reset.
Peripheral interrupts
Different peripheral interrupt flags in the status register are able to cause an interrupt when they are active if both.
– The I bit of the CC register is cleared. – The corresponding enable bit is set in the control
register.
If any of these two conditions is false, the interrupt is latched and thus remains pending.
Clearing an interrupt request is done by: – writing “0” to the corresponding bit in the status
register or
– an access to the status register while the flag is
set followed by a read or write of an associated register.
Notes:
1. The clearing sequence resets the internal latch. A pending interrupt (i.e. waiting for being enabled) will therefore be lost if the clear sequence is exe­cuted.
2. All interrupts allow the processor to leave the Wait low power mode.
3. Exit from Halt mode may only be triggered by an External Interrupt on one of the ITi ports (PA4-PA7 and PB4-PB7), an end suspend mode Interrupt coming from USB peripheral, or a reset.
20/109
INTERRUPTS (Cont’d) Figure 15. I nt errupt Proces s ing Fl owchart
FROM RESET
ST7263
EXECUTE INSTRUCTION
Table 7. Int errupt Mapp in g
Source
Block
BIT I SET
Y
FETCH NEXT INSTRUCTION
N
RESTORE PC, X, A, CC FROM STACK
THIS CLEARS I BIT BY DEFAULT
IRET
Y
Description
N
Register
Label
N
INTERRUPT
Y
STACK PC, X, A, CC
SET I BIT
LOAD PC FROM INTERRUPT VECTOR
Priority
Order
Exit from
HALT
Vector
Address
RESET Reset
TRAP Software Interrupt no FFFCh-FFFDh
N/A
USB End Suspend Mode ISTR 1 ITi External Interrupts ITRFRE FFF8h-FFF9h 2 TIMER Timer Peripheral Interrupts TIMSR
2
3I
CI
2
C Peripheral Interrupts
I2CSR1 I2CSR2
4 SCI SCI Peripheral Interr upts SCISR FFF2h-FFF3h 5 USB USB Peripheral Interrupts ISTR FFF0h-FFF1h
Highest
Priority
Lowest
Priority
yes FFFEh-FFFFh
yes
FFFAh-FFFBh
FFF6h-FFF7h FFF4h-FFF5h
no
21/109
ST7263
INTERRUPTS (Cont’d)
4.1.1 Interrupt Register INTERRUPTS REGISTER (ITRFRE)
Address: 0008h — Read/Write Reset Value: 0000 0000 (00h)
70
IT8E IT7E IT6E IT5E IT4E IT3E IT2E IT1E
Bit 7:0 = ITiE (i=1 to 8).
Bits
.
Interrupt Enable Control
If an ITiE bit is set, the corresponding interrupt is generated when
– a rising edge occurs on the pin PA4/IT1 or PA5/
IT2 or PB4/IT5 or PB5/IT6 or – a falling edge occurs on the pin PA6/IT3 or PA7/
IT4 or PB6/IT7 or PB7/IT8 No interrupt is generated elsewhere. Note: Analog input must be disabled for interrupts
coming from port B.
22/109
4.2 POWER SAVI NG MO DE S
ST7263
4.2.1 Introd uct i on
To give a large measure of flexibility to the applica­tion in terms of power consumption, two main pow­er saving modes are implemented in the ST7.
After a RESET the normal operating mode is se­lected by default (RUN mode). This mode drives the device (CPU and embedded peripherals) by means of a master clock which is based on the main oscillator frequency divided by 3 (f
CPU
).
From Run mode, the different power saving modes may be selected by setting the relevant register bits or by calling the specific ST7 software instruction whose action depends on the oscillator status.
4.2.2 HALT mode
The HALT mode is the MCU lowest power con­sumption mode. The HALT mode is entered by ex­ecuting the HALT instruction. The internal oscilla­tor is then turned off, causing all internal process­ing to be stopped, including the operation of the on-chip peripherals.
When entering HALT mode, the I bit in the Condi­tion Code Register is cleared. Thus, any of the ex­ternal interrupts (ITi or US B end suspend mode), are allowed and if an interrupt occurs, the CPU clock becomes active.
The MCU can exit HALT m ode on reception of ei­ther an external interrupt on ITi, an end suspend mode interrupt coming from USB peripheral, or a reset. The oscillat or is t hen t urned on and a stabi­lization time is provided before rele asing CPU op­eration. The stabilization time is 4096 CPU clock cycles. After the start up delay, the CPU continues opera­tion by servicing the interrupt which wakes it up or by fetching the reset vector if a reset wakes it up.
Figure 16. HAL T Mode Flow C hart
HALT INSTRUCTION
OSCILLATOR PERIPH. CLOCK CPU CLOCK
I-BIT
N
RESET
N
EXTERNAL
INTERRUPT*
Y
OSCILLATOR PERIPH. CLOCK CPU CLOCK I-BIT
4096 CPU CLOCK
CYCLES DELAY
FETCH RESET VECTOR
OR SERVICE INTERRUPT
OFF
OFF
OFF CLEARED
Y
ON
ON
ON SET
Note: Before servicing an interrupt, the CC register is pushed on the stac k. T he I -Bit i s se t du ring the inter­rupt routine and cleared when the CC register is popped.
23/109
ST7263
POWER SAVING MODES (Cont’d)
4.2.3 WAIT mode
Figure 17. WAIT Mode Flow Chart
WAIT mode places the MCU in a low power con­sumption mode by stopping the CPU. This pow er s av in g mode is s elected b y ca llin g the “WFI” ST7 software instruction. All peripherals remain active. During WAIT mode, the I bit of the CC register is forced to 0, to enable all interrupts. All other registers and mem ory re­main unchanged. The MCU remains in WAIT mode until an interrupt or Reset occu rs, where up­on the Program Counter branc hes to the starting address of the interrupt or Reset service routine. The MCU will r e main in W AIT mod e unt il a Rese t or an Interrupt occurs, causing it to wake up.
Refer to Figure 17.
N
INTERRUPT
Y
WFI INSTRUCTION
OSCILLATOR PERIPH. CLOCK CPU CLOCK
I-BIT
N
RESET
OSCILLATOR PERIPH. CLOCK
CPU CLOCK
I-BIT
ON
ON
OFF CLEARED
Y
ON
ON
ON SET
24/109
IF RESET
4096 CPU CLOCK
CYCLES DELAY
FETCH RESET VECTOR
OR SERVICE INTERRUPT
Note: Before servicing an interrupt, the CC register is pushed on the sta ck. The I-Bit is s et d uring the inte r­rupt routine and cleared when the CC register is popped.
5 ON-CHIP PERIPHERALS
5.1 I/O PORTS
ST7263
5.1.1 Introd uct i on
The I/O ports offer different functional modes:
– transfer of data through digital inputs and outputs and for specific pins: – analog signal input (ADC) – alternate signal input/output for the on-chip pe-
ripherals. – external interrupt generation An I/O port i s com pos ed of up to 8 pins. E ach pin
can be programmed independently as digital input (with or without interrupt generation) or digital out­put.
5.1.2 Functi onal descri ption
Each port is associated to 2 main registers: – Data Register (DR) – Data Direction Register (DDR) Each I/O pin may be programmed using the corre-
sponding register bits in DDR register: bit X corre­sponding to pin X of the port. The same corre­spondence is used for the DR register.
Table 8. I/O Pin Functi ons
DDR MODE
0 Input 1 Output
Inpu t Mode s
The input configuration is sele cted by clearing the corresponding DDR register bit.
In this case, reading the DR register returns the digital value applied to the external I/O pin.
Note 1: All the inputs are triggered by a Schmitt trigg er. Note 2: When switching from input mode to output mode, the DR register should be written first to output the correct value as soon as the port is con­figured as an output.
Interrupt function
When an I/O is configured in Input with Interrupt, an event on this I/O can generate an external In-
terrupt request to the CPU. The interrupt sensitivi­ty is given independently according to the descrip­tion mentioned in the ITRFRE interrupt register.
Each pin can independently generate an Interrupt request.
Each external interrupt vector is linked t o a dedi­cated group of I/O port pins (see Interrupts sec­tion). If more than one input pin is selected simul­taneously as interrupt source, this is logically ORed. For this reason if one of the interrupt pins is tied low, it masks the other ones.
Output Mode
The pin is configured in output mode by setting the corresponding DDR register bit (see Table 7).
In this mode, writing “0” or “1” to the DR register applies this digital value to the I/O pin through the latch. Then reading the DR register returns the previously stored value.
Note: In this mode, the interrupt function is disa­bled.
Digital Alternate Func ti on
When an on-chip peripheral is configured to use a pin, the alternate function is au tomatically select­ed. This alternate function takes priority over standard I/O programming. When the signal is coming from an on-chip peripheral, the I/O pin is automatically configured in output mode (push-pull or open drain according to the peripheral).
When the signal is goi ng to an on-chip peripheral, the I/O pin ha s to be configured in i nput mode. In this case, the pin’s state is a lso digitally readable by addressing the DR register.
Notes:
1. Input pull-up configuration can cause an unex ­pected value at the input of the alternate peripher­al input.
2. When the on-chip peripheral uses a pin as input and output, this pin must be configured as an input (DDR = 0).
Warning
: The alternate func tion m us t not be a cti-
vated as long as the pin is configured as input with interrupt, in order to avoid generating spurious in­terrupts.
25/109
ST7263
I/O PORTS (Cont’d) Analog Alternate Function
When the pin is used as an ADC input the I/O must be configured as input, floating. The analog multi­plexer (controlled by the ADC registers) switches the analog voltage present o n the selected pin to the common ana log rail which i s c onnect ed to the ADC input.
It is recommended not to change the voltage level or loading on any port pin while conversion is in progress. Furthermore it i s recommended not to
have clocking pins locat ed close t o a selected an­alog pin.
Warning
within the limits stat ed in the A bsolute Max imum Ratings.
5.1.3 I/O Port Implementation
The hardware implementation on each I/O port de­pends on the settings in the DDR register and spe­cific feature of the I/O port such as ADC Input or true open drain.
: The analog input voltage level must be
26/109
I/O PORTS (Cont’d)
5.1.4 Port A Table 9. Port A0, A3, A4, A5, A6, A7 Description
ST7263
PORT A
Input* Output Signal Condition
I / O Alternate Function
PA0 with pull-up push-pull MCO (Main Clock Output) MCO = 1 (MISCR)
PA3 with pull-up push-pull Timer EXTCLK
PA4 with pull-up
PA5 with pull-up
PA6 with pull-up
PA7 with pull-up
push-pull
push-pull
push-pull
push-pull
Timer ICAP1 IT1 Schmitt triggered input IT1E = 1 (ITIFRE) Timer ICAP2 IT2 Schmitt triggered input IT2E = 1 (ITIFRE) Timer OCMP1 OC1E = 1 IT3 Schmitt triggered input IT3E = 1 (ITIFRE) Timer OCMP2 OC2E = 1 IT4 Schmitt triggered input IT4E = 1 (ITIFRE)
CC1 =1 CC0 = 1 (Timer CR2)
*Reset State
Figure 18. PA0, PA3, PA4, PA5, PA6, PA7 Configuration
ALTERNATE ENABLE ALTERNATE OUTPUT
1
0
V
DD
P-BUFFER
DATA BUS
DR SEL
ALTERNATE INPUT
DR
LATCH
DDR
LATCH
DDR SEL
V
PULL-UP
ALTERNATE ENABLE
N-BUFFER
1
0
ALTERNATE ENABLE
CMOS SCHMITT TRIGGER
V
SS
DD
PAD
DIODES
27/109
ST7263
I/O PORTS (Cont’d)
Table 10. PA1, PA2 Description
PORT A
Input* Output Signal Condition
I / O Alternate Function
PA1 without pull-up Very High Current open drain SDA (I2C data) I2C enable PA2 without pull-up Very High Current open drain SCL (I2C clock) I2C enable *Reset State
Figure 19. PA1, PA2 Configuration
ALTERNATE ENABLE
ALTERNATE OUTPUT
DR
LATCH
DDR
LATCH
DATA BUS
DDR SEL
1
0
PAD
DR SEL
N-BUFFER
1
0
ALTERNATE ENABLE
CMOS SCHMITT TRIGGER
V
SS
28/109
ST7263
I/O PORTS (Cont’d)
5.1.5 Port B Table 11. Port B Description
PORT B I/O Alternate Function
Input* Output Signal Condition
PB0 without pull-up push-pull Analog input (ADC) CH[2:0] = 000 (ADCCSR) PB1 without pull-up push-pull Analog input (ADC) CH[2:0] = 001 (ADCCSR) PB2 without pull-up push-pull Analog input (ADC) CH[2:0]= 010 (ADCCSR) PB3 without pull-up push-pull Analog input (ADC) CH[2:0]= 011 (ADCCSR)
PB4 without pull-up push-pull
PB5 without pull-up push-pull
PB6 without pull-up push-pull
PB7 without pull-up push-pull
*Reset State
Figure 20. Port B C onfi guration
ALTERNAT E EN ABL E
ALTERNATE OUTPUT
DR
LATCH
DDR
COMMON ANALOG RAIL
DATA BUS
LATCH
1
0
ANALOG ENABLE (ADC)
Analog input (ADC) CH[2:0]= 100 (ADCCS R) IT5 Schmitt triggered input IT4E = 1 (ITIFRE) Analog input (ADC) CH[2:0]= 101 (ADCCS R) IT6 Schmitt triggered input IT5E = 1 (ITIFRE) Analog input (ADC) CH[2:0]= 110 (ADCCS R) IT7 Schmitt triggered input IT6E = 1 (ITIFRE) Analog input (ADC) CH[2:0]= 111 (ADCCS R) IT8 Schmitt triggered input IT7E = 1 (ITIFRE)
V
DD
P-BUFF ER
ALTERNATE EN ABLE
V
DD
PAD
ALTER N A T E INP U T
DDR SEL
DR SEL
ANALOG SWITCH
N-BUFFER
1
0
DIGITA L EN ABL E
ALTERNATE EN ABLE
V
SS
DIODES
29/109
ST7263
I/O PORTS (Cont’d)
5.1.6 Port C Table 12. Port C Description
PORT C
I / O Alternate Function
Input* Output Signal Condition
PC0 with pull-up push-pull RDI (SCI input) PC1 with pull-up push-pull TDO (SCI output) SCI enable
PC2 with pull-up push-pull
USBOE (USB output ena­ble)
USBOE =1 (MISCR)
*Reset State
Figure 21. P ort C Conf i gu ra ti on
ALTER N AT E ENABLE ALTERNATE OUTPUT
DR LATCH
DATA BUS
DDR LATCH
1
0
PULL-UP
ALTERNAT E EN ABL E
V
DD
P-BUFFER
V
DD
PAD
ALTERNATE INPUT
30/109
DDR SEL
DR SEL
N-BUFFER
1
0
ALTERNATE ENABLE
CMOS SCHMITT TRIGGER
V
SS
DIODES
I/O PORTS (Cont’d)
5.1.7 Register Description DATA REGISTERS (PxDR)
Port A Data Register (PADR): 0000h Port B Data Register (PBDR): 0002h Port C Data Register (PCDR): 0004h Read/Write Reset Value Port A: 0000 0000 (00h) Reset Value Port B: 0000 0000 (00h) Reset Value Port C: 1111 x000 (FXh)
Note: f or Port C, unused bits (7-3) are not acces-
DATA DIRECTION REGISTER (PxDDR)
Port A Data Direction Register (PADDR): 0001h Port B Data Direction Register (PBDDR): 0003h Port C Data Direction Register (PCDDR): 0005h Read/Write Reset Value Port A: 0000 0000 (00h) Reset Value Port B: 0000 0000 (00h) Reset Value Port C: 1111 x000 (FXh) Note: for Port C, unused bits (7-3) are not acces-
sible
sible.
70
70
D7 D6 D5 D4 D 3 D2 D1 D0
DD7 DD6 DD 5 DD4 DD3 DD2 DD1 DD0
ST7263
Bit 7:0 = DD7-DD0
Data Direction Register 8 bits.
The DDR register gives the input /output direction
Bit 7:0 = D7-D0
Data Register 8 bits.
The DR register has a specific behaviour accord­ing to the selected input/output configuration. Writ­ing the DR register is always taken in account
configuration of the pins. Each bits is set and cleared by software.
0: Input mode 1: Output mode
even if the pin is configured as an input. Reading the DR register returns ei ther the DR register latch content (pin configured as output) or the digital val­ue applied to the I/O pin (pin configured as input).
Table 13. I/O Ports Register Map
Address
(Hex.)
00 PADR MSB LSB 01 PADDR MSB LSB 02 PBDR MSB LSB 03 PBDDR MSB LSB 04 PCDR MSB LSB 05 PCDDR MSB LSB
Register
Label
76543210
31/109
ST7263
5.2 MISCELLANEOUS REGISTER
Bit 2 = CLKDIV
Address: 0009h — Read/Write Reset Value: 1111 0000 (F0h)
70
----LVDCLKDIVUSBOEMCO
Bit 7:4 = Reserved
This bit is set by software and only cleared by hard­ware after a reset. If this bit is set, it enables the use of a 12 MHz external os cillator (refer to Figure 10
on page 17).
0: 24 MHz external oscillator 1: 12 MHz external oscillator.
Bit 1 = USBOE
Clock Divider
USB enable.
If this bit is set, the port PC2 outputs the USB out-
Bit 3 = LVD
Low Voltage Detector.
This bit is set by software and only cleared by hard­ware after a reset.
put enable signal (at “1” when the ST7 USB is transmitting data).
Unused bits 7-4 are set.
0: LVD enabled 1: LVD disabled
Bit 0 = MCO
Main Clock Out selection
This bit enables the MCO alternate function on the PA0 I/O port. It is set and cleared by software. 0: MCO alternate function disabled (I/O pin free for
general-purpose I/O)
1: MCO alternate function enabled (f
port)
.
on I/O
CPU
32/109
5.3 WATCHDOG TIMER (WDG)
ST7263
5.3.1 Introd uction
The Watchdog tim er is used to detect t he occur­rence of a software fault, usually generated by ex­ternal interference or by unforeseen logi cal condi­tions, which causes the application program to abandon its normal seque nce. The W atchdog cir­cuit generates an MCU reset o n expiry of a pro­grammed time period, unless the program refresh-
es the counter’s contents before the T6 bit be­comes cleared.
Figure 22. Watc hdog Block Diagram
RESET
WATCHDOG CONTROL REGISTER (CR)
T5
WDGA
T6 T0
T4
7-BIT DOWNCOUNTER
5.3.2 Main Features
Programmable timer (64 increments of 49152
CPU cycles)
Programmable reset
Reset (if watchdog activated) when the T6 bit
reaches zero
T1
T2
T3
f
CPU
CLOCK DIVIDER
49152
÷
33/109
ST7263
WATCHD OG TI M E R (Cont’d)
5.3.3 Functional Description
The counter value stored in the CR register (bits T6:T0), is decremented every 49,152 machine cy­cles, and the length of the timeout period can b e programmed by the user in 64 increments.
If the watchdog is activated (the W DGA bit is s et) and when the 7-bit timer (bits T6:T0) rolls over from 40h to 3Fh (T6 becom es cleared), it initiates a reset cycle pu lling lo w t he rese t pi n fo r typical ly 500ns.
The application program must write in the CR reg­ister at regular intervals during normal operation to prevent an MCU reset. The value to b e stored in the CR register must be between FFh and C0h (see Table 14 . Watchdog Timing (fCPU = 8
MHz)):
– The WDGA bit is set (watchdog enabled) – The T6 bit is set to prevent generating an imme-
diate reset
– The T5:T0 bits contain the number of increments
which represents the time delay before the watchdog produces a reset.
Table 14. Watchdog Timing (f
CR Register
initial value
Max FFh 393.216
Min C0h 6.144
= 8 MHz)
CPU
WDG timeout period
(ms)
reset immediately after waking up the microcon­troller.
– When using an external interrupt to wake up the
microcontroller, reinitialize the corresponding I/O as “Input Pull-up with Interrupt” before executing the HALT instruction. The main reason for this is that the I/O may be wrongly configured due to ex­ternal interference or by an unforeseen logical condition.
– For the same reason, reinitialize the level sensi-
tiveness of each external interrupt as a precau­tionary measure.
– The opcode for the HALT instruction is 0x8E. To
avoid an unexpected HALT instruction due to a program counter failure, it is advised to clear all occurrences of the data value 0x8E from memo­ry. For example, avoid defining a constant in ROM with the value 0x8E.
– As the HALT instruction clears the I bit in the CC
register to allow interrupts, the user may choose to clear all pending interrupt bits before execut­ing the HALT instruction. This avoids entering other peripheral interrupt routines after executing the external interrupt routine corresponding to the wake-up event (reset or external interrupt).
5.3.4 Interrupts
None.
Notes: Following a reset, the watchdog is disa­bled. Once activated it cannot be disabled, except by a reset.
The T6 bit can be used to generat e a sof t ware re­set (the WDGA bit is set and the T6 bit is cleared).
5.3.3.1 Using Halt Mode with the WDG
The HALT instruction stops the oscillator. When the oscillator is stopped, the WDG stop s counting and is no longer able to generate a reset u ntil the microcontroller receives an external interrupt or a reset.
If an external interrupt is received, the WDG re­starts counting after 4096 CPU clocks. If a reset is generated, the WDG is disabled (reset state).
Recommendations
– Mak e sure that an external event is available to
wake up the microcontroller from Halt mode.
– Before ex ecuting the HALT instruction, refresh
the WDG counter, to avoid an unexpected WDG
34/109
5.3.5 Register Description CONTROL REGISTER (CR)
Read/Write Reset Value: 0111 1111 (7Fh)
70
WDGA T6 T5 T4 T3 T2 T1 T0
Bit 7 = WDGA
Activation bit
. This bit is set by software and only cleared by hardware after a reset. When WDGA = 1, the watchdog can generate a reset. 0: Watchdog disabled 1: Watchdog enabled
Bit 6:0 = T[6:0]
7-bit timer (MSB to LSB).
These bits contain the decremented value. A reset is produced when it rolls over from 40h to 3Fh (T6 becomes cleared).
WATCHD OG TI M E R (Cont’d) Table 15. Watchdog Time r Register Map and Rese t Values
Address
(Hex.)
0C
Register
Label
WDGCR
Reset Value
76543210
WDGA
0
T6
T5
1
1
T4
1
T3
ST7263
T2
1
1
T1
T0
1
1
35/109
ST7263
5.4 16-BIT TIMER
5.4.1 Introd uction
The timer consists of a 16-bit free-running counter driven by a programmable prescaler.
It may be used for a variety of purposes, including measuring the pulse lengths of up to two input sig­nals (
input capture
waveforms (
) or generating up to two output
output compare
and
PWM
).
Pulse lengths and waveform perio ds c an be m od­ulated from a few microseconds to several milli­seconds using the timer prescaler and the CPU clock prescaler.
Some ST7 devices have two on-chip 16-bit timers. They are completely independent, and do not share any resources. They are synchronized a fter a MCU reset as long as the timer clock frequen­cies are not modified.
This description covers one or two 16-bit timers. In ST7 devices with two timers, regi ster names are prefixed with TA (Timer A) or TB (Timer B).
5.4.2 Main Features
Programmable prescaler: f
Overflow status flag and maskable interrupt
External clock inpu t (must be at le ast 4 times
slower than the CPU
clock speed) with the choice
divided by 2, 4 or 8.
CPU
of active edge
Output compare functions with:
– 2 dedicated 16-bit registers – 2 dedicated programmable signals – 2 dedicated status flags – 1 dedicated maskable interrupt
Input capture functions with:
– 2 dedicated 16-bit registers – 2 dedicated active edge selection signals – 2 dedicated status flags – 1 dedicated maskable interrupt
Pulse Width Modulation mode (PWM)
One Pulse mode
5 alternate functions on I/O ports (ICAP1, ICAP2,
OCMP1, OCMP2, EXTCLK)*
5.4.3 Functional Description
5.4.3.1 Counter
The main block of the Programmab le Timer is a 16-bit free running upcounter and its associated 16-bit registers. The 16-bit registers are made up of two 8-bit registers called high & low.
Counter Register (CR):
– Counter High Register (CHR) is the most sig-
nific a nt byte (MS B y te ) .
– Counter Low Register (CLR) is the least sig-
nificant byte (LS Byte).
Alternate Counter Register (ACR)
– Alternate Count er Hi gh Regi ster ( ACHR) is th e
most significant byte (MS Byte).
– Alternate Counter Low Register (ACLR) is the
least significant byt e (LS Byte).
These two read-only 16-bit registers contain the same value but with the difference that reading the ACLR register does not clear the TOF bit (Timer overflow flag), located in the Stat us register (SR). (See note at the end of paragraph titled 16-bit read sequence).
Writing in the CLR register or ACLR register resets the free running counter to the FFFCh value. Both counters have a reset value of FFFCh (this is the only value which is reloaded in the 16-bit tim­er). The reset value of both counters is also FFFCh in One Pulse mode and PWM mode.
The timer clock depends on the cloc k control bits of the CR2 register, as illustrated in T able 1. The value in the counter register repeats every
131.072, 262.144 or 524.288 CPU clock cycles depending on the CC[1:0] bits. The timer frequency c an be f
CPU
/2, f
CPU
/4, f
CPU
/8
or an external frequency.
The Block Diagram is shown in Figure 1. *Note: Some timer pins m ay not be av ai lable (not
bonded) in some ST7 devices. Refer to the device pin out description. When reading an input signal on a non-bonded pin, the value will always be ‘1’.
36/109
16-BIT TIMER (Cont’d) Figure 23. Timer Block Diagram
f
CPU
ST7263
ST7 INTERNAL BUS
MCU-PERIPHERAL INTERFACE
EXTCLK
pin
EXEDG
1/2 1/4
1/8
CC[1:0]
8 high
COUNTER
REGISTER
ALTERNATE
COUNTER
REGISTER
OVERFLOW
DETECT
CIRCUIT
8 low
8-bit
buffer
high
16
OUTPUT
COMPARE
REGISTER
16
TIMER INTERNAL BUS
OUTPUT COMPARE
CIRCUIT
low
1
16 16
6
8
low
high
OUTPUT COMPARE REGISTER
2
88 8
high
INPUT
CAPTURE
REGISTER
EDGE DETECT
CIRCUIT1
EDGE DETECT
CIRCUIT2
8
8 8 8
low
1
16
high
low
INPUT
CAPTURE
REGISTER
2
16
ICAP1
pin
ICAP2
pin
(See note)
TIMER INTERRUPT
ICF2ICF1 000OCF2OCF1 TOF
(Status Register) SR
(Control Register 1) CR1
LATCH1
LATCH2
OC2E
PWMOC1E
OPMFOLV2ICIE OLVL1IEDG1OLVL2FOLV1OCIETOIE
EXEDG
IEDG2CC0CC1
(Control Register 2) CR2
Note: If IC, OC and TO interrupt requests have separate vectors then the last O R is not presen t (See device In t errupt Vector Table)
OCMP1
pin
OCMP2
pin
37/109
ST7263
16-BIT TIMER (Cont’d) 16-bit Read Sequence: (from either the Counter
Register or the Alternate Counter Register).
Beginning of the sequence
Read
At t0
MS Byte
Other
instructions
Read
At t0 +t
LS Byte
Sequence completed
The user must read the MS Byte f irst, then the LS Byte value is buffered automatically.
This buffered value rem ains unchanged until the 16-bit read sequence is completed, even if the user reads the MS Byte several times.
After a complete reading sequence, if only the CLR register or ACLR register are read, they re­turn the LS Byte of the count value at the time of the read.
Whatever the timer mode used (input capture, out­put compare, One Pulse mo de or P WM m ode) an overflow occurs when the counter rolls over from FFFFh to 0000h then:
– The TOF bit of the SR register is set. – A timer interrupt is generated if:
– TOIE bit of the CR1 register is set and – I bit of the CC register is cleared.
If one of these cond itions is false, the interrupt re­mains pending to be issued as soon as they are both true.
LS Byte
is buffered
Returns the buffered
LS Byte value at t0
Clearing the overflow interrupt request is done in two steps:
1.Reading the SR register while the TOF bit is set.
2.An access (read or write) to the CLR register. Note: The TOF bit is not cleared by accessing the
ACLR register. The advantage of accessing the ACLR register rather than the CLR register is that it allows simultaneous use of the overflow function and reading the free running counter at random times (for example, to measure elapsed time) with­out the risk of clearing the TOF bit erroneously.
The timer is not affected by WAIT mode. In HALT mode, the counter stops counting until the
mode is exited. Count ing then resumes from the previous count (MCU awakened by an interrupt) or from the reset count (MCU awakened by a Reset).
5.4.3.2 External Clock
The external clock (wh ere available) is selected if CC0=1 and CC1=1 in the CR2 register.
The status of the EXEDG bit in the CR2 register determines the type of level transition on the exter­nal clock pin EXTCLK that will trigger the free run­ning counter.
The counter is synchronised with t he falling edge of the internal CPU clock.
A minimum of four falling edges of the CPU clock must occur between two consecutive active edges of the external clock; thus the external clock fre­quency must be less than a quarter of the CPU clock frequency.
38/109
16-BIT TIMER (Cont’d) Figure 24. Counter Timing Diagram, internal clock divided by 2
CPU CLOCK
INTERNAL RESET
TIMER CLOCK
ST7263
COUNTER REGISTER
TIMER OVERFL OW FLAG (TOF)
FFFD FFFE FFFF 0000 0001 0002 0003
Figure 25. Counter Timing Diagram, internal clock divided by 4
CPU CLOCK
INTERNAL RESET
TIMER CLOCK
COUNTER REGI STER
TIMER OVERFLOW FLAG (TOF)
FFFC FFF D 0000 0001
Figure 26. Counter Timing Diagram, internal clock divided by 8
CPU CLOCK
INTERNAL RESET
TIMER CLOCK
COUNTER REGISTER
TIMER OVERFLOW FLAG (TOF)
FFFC FFFD
0000
Note: The MCU is in reset state when the internal reset signal is high. When it is low, the MCU is running.
39/109
ST7263
16-BIT TIMER (Cont’d)
5.4.3.3 Input Capture
i
In this section, the index, there are 2 input capture functions in the 16-bit timer.
The two input capture 16-bit registers (IC1R and IC2R) are used to latch the valu e of the free run­ning counter after a transition is detected by the ICAP
i
pin (see figure 5).
MS Byte LS Byte
ICiR IC
The IC
i
R register is a read-only register.
The active transition is software programmable
i
through the IEDG Timing resolution is one count of the free running
counter: (
Procedure:
To use the input capture function, select the fol­lowing in the CR2 register:
– Select the timer clock (CC[1:0]) (see Table 1). – Select the edge of the active transition on the
ICAP2 pin with the IEDG2 bit (the ICAP2 pin
must be configured as a floating input). And select the following in the CR1 register: – Set the ICI E bit to ge nerat e an in terrupt after an
input capture com ing from e ither the ICAP1 pin
or the ICAP2 pin – Select the edge of the active transition on the
ICAP1 pin with the IEDG1 bit (the ICAP1pin must
be configured as a floating input).
f
CPU
bit of Control Registers (CRi).
/CC[1:0]).
, may be 1 or 2 because
i
HR ICiLR
When an input capture occurs: – The ICF – The IC
running counter on the active transition on the ICAP
– A timer interrupt is generated if the ICIE bit i s s e t
and the I bit is cleared in the CC register. Other­wise, the interrupt remains pending until both conditions become true.
Clearing the Input Capture in terrupt request (i.e. clearing the ICF
1. Reading the SR register while the ICF
2. An access (read or write) to the IC
Notes:
1. After reading the IC input capture data is inhibited and ICF never be set until the IC read.
2. The IC counter value which corresponds to the most recent input capture.
3. The 2 input capture functions can be used together even if the timer also uses the 2 output compare functions.
4. In One Pulse mode and PWM mode only the input capture 2 function can be used.
5. The alternate inputs (ICAP1 & ICAP2) are always directly connecte d to the timer. So any transitions on these pins activate the input cap­ture function. Moreover if one of th e ICAP as an input and the s econd one as an output, an interrupt can be generated if the user tog­gles the output pin and if the ICIE bit is set. This can be avoided if the in put capture func­tion
1).
6. The TOF bit can be used with an interrupt in order to measure events that exce ed the timer range (FFFFh).
i
bit is set.
i
R register contains t he val ue of the free
i
pin (see Figure 6).
i
bit) is done in two steps:
i
bit is set.
iLR
register.
i
HR register, the transfer of
i
will
i
LR register is also
i
R register contains the free running
i
pin is configured
i
is disabled by reading the ICiHR (see note
40/109
16-BIT TIMER (Cont’d) Figure 27. Input Capture Block Diagram
ST7263
ICAP1
pin
ICAP2
pin
EDGE DETECT
CIRCUIT2
IC2R Register
16-BIT
EDGE DETECT
CIRCUIT1
IC1R Register
16-BIT FREE RUNNING
COUNTER
Figure 28. Input Capture Timing Diagram
TIMER CLOCK
ICIE
(Control Register 1) CR1
IEDG1
(Status Register) SR
ICF2ICF1 000
(Control Register 2) CR2
IEDG2
CC0
CC1
COUNTER REGISTER
ICAPi PIN
ICAPi FLAG
ICAPi REGISTER
Note: Active edge is rising edge.
FF01 FF02 FF03
FF03
41/109
ST7263
16-BIT TIMER (Cont’d)
5.4.3.4 Output Compare
i
In this section, the index, there are 2 output compare functions in the 16-bit timer .
This function can be used to control an output waveform or indicate when a period of time has elapsed.
When a match is found bet ween the Output Com­pare register and the free running counter, the out­put compare function:
– Assigns pins with a programmable value if the
OCIE bit is set – Sets a flag in the status register – Generates an interrupt if enabled
Two 16-bit registers Output Compare Register 1 (OC1R) and Output Compare Register 2 (OC2R) contain the value to be com pared to the counter register each timer clock cycle.
MS Byte LS Byte
i
ROC
OC
These registers are readable and writable and are not affected by the timer hardware. A reset event changes the OC
i
R value to 8000h.
Timing resolution is one count of the free running counter: (
f
CPU/
CC[1:0]
Procedure:
To use the output compare function, select the fol­lowing in the CR2 register:
– Set the OC
OCMP
i
E bit if an output is needed then the
i
pin is dedicated to the output com pare
signal. – Select the timer clock (CC[1:0]) (see Table 1). And select the following in the CR1 register: – Select the OLVL
i
bit to applied to the OCMPi pins
after the match occurs. – Set the OC IE bit to generate an interrupt if it is
needed. When a match is found between OCRi register
and CR register: – OCF
i
bit is set.
, may be 1 or 2 because
i
HR OCiLR
).
– The OCMP
i
pin takes OLVLi bit value (OCMPi
pin latch is forced low during reset).
– A timer interrupt is generated if the OCIE bit is
set in the CR2 register and the I bit is cleared in the CC register (CC).
i
The OC
R register value required for a specific tim­ing application can be c alcul ated using the follow­ing f ormula:
t * f
OC
i
R =
CPU
PRESC
Where:
t = Output compare period (in seconds)
f
= CPU clock frequency (in hertz)
CPU
PRESC
= Timer prescaler factor (2, 4 or 8 de-
pending on CC[1:0] bits, see Table 1)
If the timer clock is an external clock, the formula is:
OC
i
R = ∆t
* fEXT
Where:
t = Output compare period (in seconds)
= External timer clock frequency (in hertz)
f
EXT
Clearing the output compare interrupt request (i.e. clearing the OCF
1. Reading the SR register while the OCF
i
set.
2. An access (read or write) to the OC The following procedure is recommended to pre-
vent the OCF it is read and the write to the OC
– Write to the OC
are inhibited).
– Read the SR register (first step of the clearance
of the OCF
– Write to the OC
compare function and clears the OCF
i
bit) is done by:
i
i
bit from being set between the time
i
R register:
i
HR register (further compares
i
bit, which may be already set).
i
LR register (enables the output
i
bit is
LR register.
i
bit).
42/109
16-BIT TIMER (Cont’d) Notes:
1. After a process or write cycle to t he O C
iHR
reg-
ister, the output compare function is inhibited
iLR
until the OC
2. If the OC general I/O port and the OLVL
register is also written.
i
E bit is not set, the OCMPi pin is a
i
bit will not appear when a match is f ound but an interrupt could be generated if the OCIE bit is set.
3. When the timer clock is f OCMP
i
are set while the counter value equals
i
the OC
R register value (see Figure 8). This
/2, OCFi and
CPU
behaviour is the same in OPM or PWM mode. When the timer clock is f external clock mode, O CF while the counter value equals the OC
/4, f
CPU
i
and OCMPi are set
CPU
/8 or in
i
R regis-
ter value plus 1 (see Figure 9).
4. The output compare functions can be used both for generating external events on the OCMP pins even if the input capture mode is also used.
5. The value in the 16-bit OC
i
bit should be changed after each suc-
OLV
i
R register and the
cessful comparison in order to control an output waveform or establish a new elapsed timeout.
Forced Compare Output capabili ty
i
When the FOLV
bit is set by software, the OLVL bit is copied to the OCMPi pin. Th e OLVi bit has to be toggled in ord er to t oggle th e OCMP it is enabled (OC
i
E bit=1). The OCFi bit is then not set by hardware, and thus no interrupt request is generated.
FOLVL
i
bits have no effect in either One-Pulse
mode or PWM mode.
i
ST7263
i
pin when
i
Figure 29. Output Compare Block Diagram
16 BIT FREE RUNNING
COUNTER
16-bit
OUTPUT COMPARE
CIRCUIT
16-bit
OC1R Register
16-bit
OC2R Register
OC1E CC0CC1
OC2E
(Control Register 2) CR2
(Control Register 1) CR1
FOLV2 FOLV1
(Status Register) SR
OLVL1OLVL2OCIE
000OCF2OCF1
Latch
1
Latch
2
OCMP1
Pin
OCMP2
Pin
43/109
ST7263
16-BIT TIMER (Cont’d) Figure 30. Output Compare Timing Diagram, f
INTERNAL CPU CLOC K
TIMER CLOCK
TIMER
=f
CPU
/2
COUNTER REGISTER
OUTPUT COMPARE REGISTER
OUTPUT COMPARE FLAG
i
OCMP
i
(OCRi)
i
(OCFi)
PIN (OLVLi=1)
Figure 31. Output Compare Timing Diagram, f
INTERNAL CPU CLOC K
TIMER CLOCK
COUNTER REGISTER
OUTPUT COMPARE REGISTER
COMPARE REGISTER
OUTPUT COMPARE FLAG
i
(OCRi)
i
LATCH
i
(OCFi)
2ED0 2ED1 2ED2
=f
TIMER
CPU
2ED0 2ED 1 2ED 2
/4
2ED3
2ED3
2ED3
2ED3
2ED42ECF
2ED42ECF
44/109
OCMPi PIN (OLVLi=1)
16-BIT TIMER (Cont’d)
5.4.3.5 One Pulse Mode
One Pulse mode enables the generation of a pulse when an external event occurs. This mode is selected via the OPM bit in the CR2 register.
The One Pulse mode uses the Input Capture1 function and the Output Compare1 function.
Procedure:
To use One Pulse mode:
1. Load the OC1R register with the value corre­sponding to the length of the pulse (see the for­mula in the opposite column).
2. Select the following in the CR1 register: – Using the OLVL1 bit, select the level to be ap-
plied to the OCMP1 pin after the pulse.
– Using the OLVL2 bit, select the level to be ap-
plied to the OCMP1 pin during the pulse.
– Select the edge of the a ctive trans ition o n th e
ICAP1 pin with the IEDG1 bit
(the ICAP1 pin
must be configured as floating input).
3. Select the following in the CR2 register: – Set the OC1E bit, the OCMP1 pin is then ded-
icated to the Output Compare 1 function. – Set the OPM bit. – Select the timer clock CC[1:0] (see Table 1).
ST7263
Clearing the Input Capture in terrupt request (i.e. clearing the ICF
1. Reading the SR register while the ICF
2. An access (read or write) to the IC The OC1R register value required for a specific
timing application can be calculated usi ng the fol­lowing formula:
OC
Where: t = Pulse period (in seconds)
= CPU clock frequency (in hertz)
f
CPU
PRESC
= Timer prescaler factor (2, 4 or 8 depend-
If the timer clock is an external clock the formula is:
Wher e: t = Pulse period (in seconds) f
= External timer clock frequency (in hertz)
EXT
When the value of the counter is equal to the value of the contents of t he OC1R register, the OLV L1 bit is output on the OCMP1 pin (see Figure 10).
i
bit) is done in two steps:
i
bit is set.
iLR
register.
t
f
*
i
R Value =
CPU
PRESC
- 5
ing on the CC[1:0] bits, see Table 1)
OCiR = t
* fEXT
-5
One Pulse mode cycle
When
event occurs
on ICAP1
OCMP1 = OLVL2
Counter is reset
to FFFCh
ICF1 bit is set
When Counter = OC1R
OCMP1 = OLVL1
Then, on a valid event on the ICAP1 pin, the coun­ter is initialized to FFFCh and the OLVL2 bit is loaded on the OCMP1 pin, th e ICF1 bit is set and the value FFFDh is loaded in the IC1R register.
Because the ICF1 bit is set when an active edge occurs, an interrupt can be generated if the ICIE bit is set.
Notes:
1. The OCF1 bit cannot be set by hardware in One Pulse mode but the OCF2 bit can generate an Output Compare interrupt.
2. When the Pulse Width Modulation (PWM ) and One Pulse mode (OPM) bits are both set, the PWM mode is the only active one.
3. If OLVL1=OLVL2 a continuous signal will be seen on the OCMP1 pin.
4. The ICAP1 pin can not be used to perform input capture. The ICAP2 pin can be used t o perfo rm input capture (ICF2 can be set and IC2R can be loaded) but the user must take care that the counter is reset each time a valid edge o ccurs on the ICAP1 pin and ICF1 can also generates interrupt if ICIE is set.
5. When One Pulse m ode is used OC1R is dedi­cated to this mode. Nevertheless OC2R and OCF2 can be used to indicate that a period of time has elapsed but cannot generate an output waveform because the OLVL2 level is dedi­cated to One Pulse mode.
45/109
ST7263
16-BIT TIMER (Cont’d) Figure 32. One Pulse Mode Timing Example
COUNTER
ICAP1
OCMP1
FFFC FFFD FFFE 2ED0 2ED1 2ED2
OLVL2
compare1
Note: IEDG1=1, OC1R=2ED 0h, OLV L1=0, OLVL2=1
Figure 33. P ul se Wi dt h M odulation Mode Timing Example
COUNTER
OCMP1
FFFC FFFD FFFE
34E2
OLVL2
2ED0 2ED1 2ED2
compare2 compare1 compare2
FFFC FFFD
2ED3
OLVL2OLVL1
34E2 FFFC
OLVL2OLVL1
Note: OC1R=2ED0h, OC2R=34E2, OLVL1=0, OLVL2= 1
46/109
16-BIT TIMER (Cont’d)
5.4.3.6 Pulse Width Modulation Mode
Pulse Width Modulation (PWM) mode enables the generation of a signal wi th a frequency a nd pul se length determined by the value of the OC1R and OC2R registers.
The Pulse Width Modulation mode uses the com ­plete Output Compare 1 funct ion plus the OC2R register, and so these functions cannot be used when the PWM mode is activated.
Procedure
To use Pulse Width Modulation mode:
1. Load the OC2R register with the value corre­sponding to the period of the signal using the formula in the opposite column.
2. Load the OC1R register with the value corre­sponding to the period of the p ulse i f OLVL1= 0 and OLVL2=1, using the formula in the oppo­site column.
3. Select the following in the CR1 register: – Using the OLVL1 bit, select the level to be ap-
plied to the OCMP1 pin after a successful comparison with OC1R register.
– Using the OLVL2 bit, select the level to be ap-
plied to the OCMP1 pin after a successful comparison with OC2R register.
4. Select the following in the CR2 register: – Set OC1E bit: the OCMP1 pin is then dedicat-
ed to the output compare 1 function. – Set the PWM bit. – Select the timer clock (CC[1:0]) (see Table 1).
If OLVL1=1 and O LVL2=0, t he length of t he pos i­tive pulse is the difference between the OC2R and OC1R registers.
If OLVL1=OLVL2 a c ontinuous s ign al will be seen on the OCMP1 pin.
Pulse Width Modulation cycle
When
Counter
OCMP1 = OLVL1
= OC1R
When
Counter = OC2R
OCMP1 = OLVL 2
Counter is reset
to FFFCh
ST7263
The OC ing application can be c alcul ated using the follow­ing f ormula:
Where: t = Signal or pulse period (in seconds)
f
CPU
PRESC
If the timer clock is an external clock the formula is:
Wher e: t = Signal or pulse period (in seconds) f
EXT
The Output Compare 2 event causes the counter to be initialized to FFFCh (See Figure 11)
Notes:
1. After a write instruction to the OC
2. The OCF1 and OCF2 bits cannot be set by
3. The ICF1 bit is set by hardware when the coun-
4. In PWM mod e the ICAP1 pin can not be used
5. When the Pulse Width Modulation (PWM ) and
i
R register value required for a specific tim-
t
f
*
OC
i
R Value =
CPU
PRESC
- 5
= CPU clock frequency (in hertz)
= Timer prescaler factor (2, 4 or 8 depend-
ing on CC[1:0] bits, see Table 1)
OCiR = t
* fEXT
-5
= External timer clock frequency (in hertz)
i
HR register,
the output compare function is inhibited until the
i
LR register is also written.
OC
hardware in PWM mode, therefore the Output Compare interrupt is inhibited.
ter reaches the OC2R value and can produce a timer interrupt if the ICIE bit is set and the I bit is cleared.
to perform input capture because it is discon­nected from the timer. The ICAP2 pin can be used to perform input capture (ICF2 can be set and IC2R can be loaded) but the user must take care that the counter is reset after each period and ICF1 can also ge nerate an interrupt if ICIE is set.
One Pulse mode (OPM) bits are both set, the PWM mode is the only active one.
ICF1 bit is set
47/109
ST7263
16-BIT TIMER (Cont’d)
5.4.4 Low Power Modes
Mode Description
WAIT
HALT
5.4.5 Interrupts
Input Capture 1 event/Counter reset in PWM mode ICF1 Input Capture 2 event ICF2 Yes No Output Compare 1 event (not available in PWM mode) OCF1 Output Compare 2 event (not available in PWM mode) OCF2 Yes No Timer Overflow event TOF TOIE Yes No
No effect on 16-bit Timer. Timer interrupts cause the device to exit from WAIT mode.
16-bit Timer registers are frozen. In HALT mode, the counter stops counting until Halt mode is exited. Counting resumes from the previous
count when the MCU is woken up by an interrupt with “exit from HALT mode” capability or from the counter reset value when the MCU is woken up by a RESET.
If an input capture event occurs on the ICAP ly, when the MCU is woken up by an interrupt with “exit from HALT mode” capability, the ICF the counter value present when exiting from HALT mode is captured into the IC
Interrupt Event
i
pin, the input capture detection circuitry is armed. Consequent-
i
bit is set, and
i
R register.
Event
Flag
Enable
Control
Bit
ICIE
OCIE
Exit
from
Wait
Yes No
Yes No
Exit
from
Halt
Note: The 16-bit Timer interrupt ev ents are co nnecte d to the same inte rrupt vector (see In terrupts chap-
ter). These events generate an interrupt if the correspo nding Enable Control Bit is set and the interrupt mask in the CC register is reset (RIM instruction).
5.4.6 Summary of Timer modes
MODES
Input Capture (1 and/or 2) Yes Yes Yes Yes Output Compare (1 and/or 2) Yes Yes Yes Yes One Pulse mode No Not Recommended PWM Mode No Not Recommended
1)
See note 4 in Section 0.1.3.5 One Puls e Mode
2)
See note 5 in Section 0.1.3.5 One Puls e Mode
3)
See note 4 in Section 0.1.3.6 Pulse Wi dth Modula tion Mode
Input Capture 1 Input Capture 2 Output Compare 1 Output Compare 2
AVAILABLE RESO URC ES
1)
3)
No Partially No No
2)
48/109
16-BIT TIMER (Cont’d)
5.4.7 Register Description
Each Timer is associated with three control and status registers, and with six pairs of data registers (16-bit values) relating to the two input captures, the two output compares, the count er and the a l­ternate counter.
ST7263
Bit 4 = FOLV2 This bit is set and cleared by software. 0: No effect on the OCMP2 pin. 1:Forces the OLVL2 bit to be copied to the
OCMP2 pin, if the OC 2E bit is set and even if there is no successful compariso n.
Forced Output Compare 2.
CONTROL REGISTER 1 (CR1)
Read/Write Reset Value: 0000 0000 (00h)
70
ICIE OCIE TOIE FOLV2 FOLV1 OLVL2 IEDG1 OLVL1
Bit 3 = FOLV1 This bit is set and cleared by software. 0: No effect on the OCMP1 pin. 1: Forces OLVL1 to be copied to the OCMP1 pin, if
the OC1E bit is set and e ven if there i s no suc­cessful comparison.
Bit 2 = OLVL2
Bit 7 = ICIE
Input Capture Interrupt Enable.
0: Interrupt is inhibited. 1: A timer interrupt is generated whenever the
ICF1 or ICF2 bit of the SR register is set.
This bit is copied to the OCMP2 pin whenev er a successful compa rison occurs with t h e OC2R reg ­ister and OCxE is set in the CR2 register. This val­ue is copied to the OCMP1 pin in One Pulse mode and Pulse Width Modulation mode.
Bit 1 = IEDG1
Bit 6 = OCIE 0: Interrupt is inhibited. 1: A timer interrupt is generated whenever the
OCF1 or OCF2 bit of the SR register is set.
Bit 5 = TOIE 0: Interrupt is inhibited. 1: A timer interrupt is enabled whenever the TOF
bit of the SR register is set.
Output Compare Interrupt Enable.
Timer Overflow Interrupt Enable.
This bit determines wh ich type of level transition on the ICAP1 pin will trigger the capture. 0: A falling edge triggers the capture. 1: A rising edge triggers the capture.
Bit 0 = OLVL1 The OLVL1 bi t is c opied to t he OCMP1 pin when­ever a successful comparison occurs with the OC1R register and the OC 1E bit is s et in the CR2
Forced Output Compare 1.
Output Level 2.
Input Edge 1.
Output Level 1.
register.
49/109
ST7263
16-BIT TIMER (Cont’d) CONTROL REGISTER 2 (CR2)
Read/Write Reset Value: 0000 0000 (00h)
70
OC1E OC2E OPM PWM CC1 CC0 IEDG2 EXEDG
Bit 4 = PWM 0: PWM mode is not active. 1: PWM mode is active, the OCMP 1 pin outputs a
programmable cyclic signal; the length of the pulse depends on the value of OC1R register; the period depends on the value of OC2R regis­ter.
Pulse Width Modulation.
Bit 7 = OC1E
Output Compare 1 Pin Enable.
This bit is used only to outp ut the signal from the timer on the OCMP1 pin (OLV1 in Output Com­pare mode, both OLV1 and OLV2 in PWM and one-pulse mode). Whatever the value of the OC1E bit, the internal Output Compare 1 function of the timer remains active. 0: OCMP1 pin alternate f unction disa bled (I/O pin
free for general-purpose I/O).
1: OCMP1 pin alternate function enabled.
Bit 6 = OC2E
Output Compare 2 Pin Enable.
This bit is used only to outp ut the signal from the timer on the OCMP2 pin (OLV2 in Output Com­pare mode). Whatever the value of the OC2E bit, the internal Output Compare 2 function of the timer remains active. 0: OCMP2 pin alternate f unction disa bled (I/O pin
free for general-purpose I/O).
1: OCMP2 pin alternate function enabled.
Bit 5 = OPM
One Pulse mode.
0: One Pulse mode is not active. 1: One Pulse mode is active, the ICAP1 pin can be
used to trigger one pulse on the OCMP1 pin; the active transition is g iven by the I EDG1 bit. Th e length of the generated pulse depends on the contents of the OC1R register.
Bits 3:2 = CC[1:0]
Clock Control.
The timer clock mode depends on these bits:
Table 16. Clock Control Bits
Timer Clock CC1 CC 0
f
/ 4 0 0
CPU
f
/ 2 0 1
CPU
f
/ 8 1 0
CPU
External Clock (where
available)
11
Note: If the external clock pin is not available, pro­gramming the external clock configuration stops the counter.
Bit 1 = IEDG2
Input Edge 2.
This bit determines wh ich type of level transition on the ICAP2 pin will trigger the capture. 0: A falling edge triggers the capture. 1: A rising edge triggers the capture.
Bit 0 = EXEDG
External Clock Edge.
This bit determines wh ich type of level transition on the external clock pin (EXTCLK) will trigger the counter register. 0: A falling edge triggers the counter register. 1: A rising edge triggers the counter register.
50/109
16-BIT TIMER (Cont’d) STATUS REGISTER (SR)
Read Only Reset Value: 0000 0000 (00h) The three least significant bits are not used.
70
ICF1 OCF1 TOF ICF2 OCF2 0 0 0
INPUT CAPTURE 1 HIGH REGISTER (IC1HR)
Read Only Reset Value: Undefined
This is an 8-bit read only register that contains the high part of the counter value (transferred by the input capture 1 event).
70
ST7263
Bit 7 = ICF1
Input Capture Flag 1.
0: No input capture (reset value). 1: An input capture has occurred on the ICAP1 pin
or the counter has reached th e OC2R value in PWM mode. To clear this bit, first read the SR register, then read or write the lo w byte of the IC1R (IC1LR) register.
Bit 6 = OCF1
Output Compare Flag 1.
0: No match (reset value). 1: The content of the free running counter matches
the content of the OC1R regis ter. To clear this bit, first read the SR register, then re ad or write the low byte of the OC1R (OC1LR) register.
Bit 5 = TOF
Timer Overflow Flag.
0: No timer overflow (reset value). 1: The free running counter has rolled over from
FFFFh to 0000h. To clear this bit, first read the SR register, then read or write t he low byte of the CR (CLR) register.
Note: Reading or writing the ACLR register does not clear TOF.
Bit 4 = ICF2
Input Capture Flag 2.
0: No input capture (reset value). 1: An input capture has occurred on the ICAP2
pin. To clear this bit, first read the SR register, then read or write the low byte of the IC2R (IC2LR) register.
Bit 3 = OCF2
Output Compare Flag 2.
0: No match (reset value). 1: The content of the free running counter matches
the content of the OC2R regis ter. To clear this bit, first read the SR register, then re ad or write the low byte of the OC2R (OC2LR) register.
Bit 2-0 = Reserved, forced by hardware to 0.
MSB LSB
INPUT CAPTURE 1 LOW REGISTER (IC1LR)
Read Only Reset Value: Undefined
This is an 8-bit read only register that contains the low part of the counter value (transferred by the in­put capture 1 event).
70
MSB LSB
OUTPUT COMPARE 1 HIGH REGISTER (OC1HR)
Read/Write Reset Value: 1000 0000 (80h)
This is an 8-bit re gister tha t co ntains t he hi gh part of the value to be compared to the CHR register.
70
MSB LSB
OUTPUT COMPARE 1 LOW REGISTER (OC1LR)
Read/Write Reset Value: 0000 0000 (00h)
This is an 8-bit register that contains the low part of the value to be compared to the CLR register.
70
MSB LSB
51/109
ST7263
16-BIT TIMER (Cont’d) OUTPUT COMPARE 2 HIGH REGISTER
(OC2HR)
Read/Write Reset Value: 1000 0000 (80h)
This is an 8-bit register that cont ains the high part of the value to be compared to the CHR register.
ALTERNATE COUNTER HIGH REGISTER (ACHR)
Read Only Reset Value: 1111 1111 (FFh)
This is an 8-bit re gister tha t co ntains t he hi gh part of the counter value.
70
MSB LSB
OUTPUT COMPARE 2 LOW REGISTER (OC2LR)
Read/Write Reset Value: 0000 0000 (00h)
This is an 8-bit register that contains the low part of the value to be compared to the CLR register.
70
70
MSB LSB
ALTERNATE COUNTER LOW REGISTER (ACLR)
Read Only Reset Value: 1111 1100 (FCh)
This is an 8-bit register that contains the low part of the counter value. A write to this register resets the counter. An access to this register after an access to SR register does no t clear the TOF bit i n SR register.
MSB LSB
COUNTER HIGH REGISTER (CHR)
70
MSB LSB
Read Only Reset Value: 1111 1111 (FFh)
This is an 8-bit register that cont ains the high part of the counter value.
70
INPUT CAPTURE 2 HIGH REGISTER (IC2HR) Read Only
Reset Value: Undefined This is an 8-bit read only register that contains the
high part of the counter value (transferred by the
MSB LSB
Input Capture 2 event).
70
COUNTER LOW REGISTER (CLR)
MSB LSB
Read Only Reset Value: 1111 1100 (FCh)
This is an 8-bit register that contains the low part of the counter value. A write to this register resets the counter. An access to this register after accessing the SR register clears the TOF bit.
70
INPUT CAPTURE 2 LOW REGISTER (IC2LR)
Read Only Reset Value: Undefined
This is an 8-bit read only register that contains the low part of the counter value (transferred by the In­put Capture 2 event).
MSB LSB
52/109
70
MSB LSB
16-BIT TIMER (Cont’d) Table 17. 16-Bit Timer Register Map and Reset Values
Address
(Hex.)
11
12
13
14
15
16
17
18
19
1A
1B
1C
1D
1E
1F
Register
Label
CR2
Reset Value
CR1
Reset Value
SR
Reset Value
IC1HR
Reset Value
IC1LR
Reset Value
OC1HR
Reset Value
OC1LR
Reset Value
CHR
Reset Value
CLR
Reset Value
ACHR
Reset Value
ACLR
Reset Value
IC2HR
Reset Value
IC2LR
Reset Value
OC2HR
Reset Value
OC2LR
Reset Value
76543210
OC1E0OC2E
0
ICIE
0
ICF1
0
MSB LSB
MSB LSB MSB
1
MSB
0
MSB
1
MSB
1
MSB
1
MSB
1
MSB LSB
MSB LSB MSB
1
MSB
0
OCIE
0
OCF1
0
-
0
-
0
-
1
-
1
-
1
-
1
-
0
-
0
OPM
0
TOIE0FOLV20FOLV10OLVL20IEDG10OLVL1
TOF
0
-
0
-
0
-
1
-
1
-
1
-
1
-
0
-
0
PWM
0
ICF2
0
-
0
-
0
-
1
-
1
-
1
-
1
-
0
-
0
CC1
0
OCF2
0
-
0
-
0
-
1
-
1
-
1
-
1
-
0
-
0
CC0
0
0 0
-
0
-
0
-
1
-
1
-
1
-
1
-
0
-
0
ST7263
IEDG20EXEDG
0
0 0 0
-
0
-
0
-
1
-
0
-
1
-
0
-
0
-
0
0
0
LSB
0
LSB
0
LSB
1
LSB
0
LSB
1
LSB
0
LSB
0
LSB
0
53/109
ST7263
5.5 SERIAL COMMUNICATIONS INTERFACE (SCI)
5.5.1 Introd uction
The Serial Communications Interface (SCI) offers a flexible means of full-duplex data exchange with external equipment requiring an indust ry stand ard NRZ asynchronous serial data format.
5.5.2 Main Features
Full duplex, asynchronous communi cations
NRZ standard format (Mark/Space)
Independently programmable transmit and
receive baud rates up to 250K baud.
Programmable data word length (8 or 9 bits)
Receive buffer full, Transmit buffer empty and
End of Transmission flags
Two receiver wake-up modes:
– Address bit (MSB) – Idle line
Muting function for multiprocessor configurations
Separate enable bits for Transmitter and
Receiver
Three error detection flags:
– Overrun error – Noise error – Frame error
Five interrupt sources with flags:
– Transmit data register empty – Transmission complete – Receive data register full – Idle line received – Overrun error detected
5.5.3 General Description
The interface is externally connected to another device by two pins (see Figure 1):
– TDO: Transmit Data Output. When the transmit-
ter is disabled, the output pin returns to its I/O port configuration. When the transmitter is ena­bled and nothing is to be transmitted, the TDO pin is at high level.
– RDI: Receive Data Input is the serial data input.
Oversampling techniques are used for data re­covery by discriminating between valid incoming data and noise.
Through this pins, serial data is transmitted and re­ceived as frames comprising:
– An Idle Line prior to transmission or reception – A start bit – A data word (8 or 9 bits) least significant bit first – A Stop bit indicating that the frame is complete.
54/109
SERIAL COMMUNICATIONS INTERFACE (Cont’d) Figure 34. SCI Block Diagram
ST7263
TDO
RDI
Write
Transmit Data Register (TDR)
Transmit Shift Register
TRANSMIT
CONTROL
CR2
R8
WAKE
UP
UNIT
SBKRWURETEILIERIETCIETIE
Read
Received Data Register (RDR)
Received Shift Register
T8 - M
(Data Register) DR
-
WAKE
RECEIVER
CONTROL
TDRE TC RDRF
IDLE OR NF FE -
CR1
--
RECEIVER
CLOCK
SR
f
CPU
SCI
INTERRUPT
CONTROL
TRANSMITTER
CLOCK
/2
/16
/PR
Transmitter Rate
Control
SCP1
SCT2
SCP0
BAUD RATE GENER ATOR
BRR
SCT1SCT0SCR2SCR1SCR0
Receiver Rate Control
55/109
ST7263
SERIAL COMMUNICATIONS INTERFACE (Cont’d)
5.5.4 Functional Description
The block diagram of the S erial Control Interface, is shown in Figure 1. It contains 4 dedicated regis­ters:
– Two control registers (CR1 & CR2) – A status register (SR) – A baud rate register (BRR) Refer to the register descriptions in Section 0.1.7
for the definitions of each bit.
5.5.4.1 Serial Data Format
Word length may be selected as being either 8 or 9 bits by programming the M bit in the CR1 register (see Figure 1).
Figure 35. Word Length Programming
The TDO pin is in low state during the start bit. The TDO pin is in high state during the stop bit. An Idle character is interpreted as an entire frame
of “1”s followed by t he start bit of the n ext frame which contains data.
A Break character is interpreted on receiving “0”s for some multiple of the frame period. At the end of the last break frame the transm itter inserts an ex­tra “1” bit to acknowledge the start bit.
Transmission and reception are driven by their own baud rate generator.
9-bit Word length (M bit is set)
Data Frame
Start
Bit
Bit0
Bit1
Bit2
Bit3
Idle Frame
Break Frame
8-bit Word length (M bit is reset)
Data Frame
Start
Bit
Bit0
Bit1
Bit2
Bit3
Idle Frame
Break Fr ame
Bit4
Bit4
Bit5
Bit5 Bit6
Bit6
Possible
Parity
Bit7
Possible
Parity
Bit
Bit7
Bit
Bit8
Stop
Bit
Next Data Frame
Next Start
Stop
Bit
Bit
Start
Bit
Extra
’1’
Next Data Frame
Next Start
Bit
Start
Bit
Start
Extra
’1’
Bit
Start
Bit
56/109
SERIAL COMMUNICATIONS INTERFACE (Cont’d)
5.5.4.2 Transmitter
The transmitter can send data words of either 8 or 9 bits depending on the M bit status. W hen the M bit is set, word length is 9 bits and the 9th bit (the MSB) has to be stored in the T8 bit in the CR1 reg­ister.
Character Transmission
During an SCI transmission, data shifts out least significant bit first on t he TDO pin. In this m ode, the DR register consists of a buffer (TDR) between the internal bus and the transmit shift register (see Figure 1).
Procedure
– Sele ct the M bit to define the word length. – Select the desired baud rate using the BRR reg-
ister.
– Set the TE bit to assign the TDO pin to the alter-
nate function and to send a idle frame as first transmission.
– Acc ess the SR register and write the data to
send in the DR register (this sequence clears the TDRE bit). Repeat this sequence for each data to be transmitted.
The following software sequence is always to clear the TDRE bit:
1. An access to the SR register
2. A write to the DR register The TDRE bit is set by hardware and it indicates
that: – The TDR register is empty. – The dat a transfer is beginning. – The next data can be written in the DR register
without overwriting the previous data.
This flag generates an interrupt if the TIE bit is set and the I bit is cleared in the CC register.
When a transmission is taking place, a write in­struction to the DR register stores the data in the TDR register which is copied in the shift register at the end of the current transmission.
When no transmission is ta king place, a write in­struction to the DR register places the data directly in the shift register, the data transmission starts, and the TDRE bit is immediately set.
ST7263
When a frame trans mission is com plete (after the stop bit or after the break frame) the TC bit is set and an interrupt is generated if the TCIE is set and the I bit is cleared in the CC register.
The following software sequence is always to clear the TC bit:
1. An access to the SR register
2. A write to the DR register Note: The TDRE and TC bits are cleared by the
same software sequence.
Break Characters
Setting the SBK bit loads the shift register with a break character. The break frame length depends on the M bit (see Figure 2).
As long as the SBK bit is set, the SCI sends break frames to the T DO pin. After clearing this bit by software, the SCI inserts a logic 1 bit at the end of the last break frame to guarantee the recognition of the start bit of the next frame.
Idle Characters
Setting the TE bit drives the SCI t o send an idle frame before the first data frame.
Clearing and then setting the TE bit during a trans­mission sends an idle frame after the current word.
Note: Resetting and setting t he TE bit causes t he data in the TDR register to be lost . Therefore the best time to toggle the TE bit is when the TDRE bit is set, i.e. before writing the next byte in the DR.
57/109
ST7263
SERIAL COMMUNICATIONS INTERFACE (Cont’d)
5.5.4.3 Receiver
The SCI can receive data words of either 8 or 9 bits. When the M bit i s set, word length is 9 bits and the MSB is stored in the R8 bit in the CR1 reg­ister.
Character reception
During a SCI reception, data shifts in least signifi­cant bit first through the RDI pin. In this mode, the DR register consists of a buffer (RDR) between the internal bus and the received shift register (see Figure 1).
Procedure
– Sele ct the M bit to define the word length. – Select the desired baud rate using the BRR reg-
ister.
– Set the RE bit to enable the receiverto begin
searching for a start bit. When a character is received: – The RDRF bit is set. It indicates that the content
of the shift register is transferred to the RDR. – An interrupt is generated if the RIE bit is set and
the I bit is cleared in the CC register. – The error flags can be set if a frame error, noise
or an overrun error has been detected during re-
ception. Clearing the RDRF bit is performed by the following
software sequence done by:
1. An access to the SR register
2. A read to the DR register. The RDRF bit must be cleared before the end of t he
reception of the next character to avoid an overrun error.
Break Character
When a break charact er is rec eived, t he S CI han­dles it as a framing error.
Idle Character
When a idle frame is detected, there is the same procedure as a data received character plus an in­terrupt if the ILIE bit is set and the I bit is cleared in the CC register.
Overrun Error
An overrun error occurs when a character is re­ceived when RDRF has not been reset. Data can not be transferred from the shift register to the TDR register as long as the RDRF bit is not cleared.
When a overrun error occurs: – The OR bit is set. – The RDR content will not be lost. – The shift register will be overwritten. – An interrupt is generated if the RIE bit is set and
the I bit is cleared in the CC register.
The OR bit is reset by an access to the SR register followed by a DR register read operation.
Noise Error
Oversampling techniques are used for data recov­ery by discriminating between v alid inc oming dat a and noise.
When noise is detected in a frame: – The NF is set at the rising edge of the RDRF bit. – Data is transferred from the Shift register to the
DR register.
– No interrupt is generated. However this bit rises
at the same time as the RDRF bit which itself generates an interrupt.
The NF bit is reset by a SR register read operation followed by a DR register read operation.
Framing E rror
A framing error is detected when: – The stop bit is not recognized on reception at the
expected time, following either a de-synchroni-
zation or excessive noise. – A break is received. When the framing error is detected: – The FE bit is set by hardware – Data is transferred from the Shift register to the
DR register. – No interrupt is generated. However this bit rises
at the same time as the RDRF bit which itself
generates an interrupt. The FE bit is reset by a SR register read operation
followed by a DR register read operation.
58/109
SERIAL COMMUNICATIONS INTERFACE (Cont’d)
5.5.4.4 Baud Rate Generation
The baud rates for the receiver and transmitter (Rx and Tx) are set independent ly and calculated as follo ws:
(32
f
CPU
PR)*RR
*
Tx =
(32
f
CPU
PR)*TR
*
Rx =
with: PR = 1, 3, 4 or 13 (see SCP0 & SCP1 bits) TR = 1, 2, 4, 8, 16, 32, 64,128 (see SCT0, SCT1 & SCT2 bit s ) RR = 1, 2, 4, 8, 16, 32, 64,128 (see SCR0,SCR1 & SCR2 bits) All these bits are in the BRR register. Example: If f
is 8 MHz and if PR=13 and
CPU
TR=RR=1, the transmit and receive baud rates are 19200 bauds.
Note: The baud rate registers MUST NOT be changed while the transmitter or the receiver is en­abled.
5.5.4.5 Receiver Muting and Wake-up Feature
In multiprocessor configurations it is often desira­ble that only the intended message recipient
ST7263
should actively receive the f ull me ssag e cont ents, thus reducing redundant SCI service overhead for all non addressed receivers.
The non addressed devices may be placed in sleep mode by means of the muting function.
Setting the RWU b it by software puts the SCI in sleep mode:
All the reception status bits can not be set. All the receive interrupt are inhibited. A muted receiver may be awakened by one of the
following two ways: – by Idle Line detection if the WAKE bit is reset, – by Address Mark detection if the WAKE bit is set. The Receiver wakes-up by Idle Line detection
when the Receive line has recognised an Idle Frame. Then the RWU bit is reset by hardware but the IDLE bit is not set.
The Receiver wakes-up by Address Mark detec­tion when it received a “1” as the most significant bit of a word, thus indicating that the mess age is an address. The reception of this particular word wakes up the receiver, resets the RWU bit and sets the RDRF bit, which allows the receiver to re­ceive this word normally and to use it as an ad­dress word.
59/109
ST7263
SERIAL COMMUNICATIONS INTERFACE (Cont’d)
5.5.5 Low Power Modes Mode Description
WAIT
HALT
5.5.6 Interrupts
Transmit Data Register Empty TDRE TIE Yes No Transmission Complete TC TCIE Yes No Received Data Ready to be Read RDRF Overrrun Error Detected OR Yes No Idle Line Detected IDLE ILIE Yes No
No effect on SCI. SCI interrupts exit from Wait mode.
SCI registers are frozen.
In Halt mode, the SCI stops transmitting/receiving until Halt mode is exited.
Enable
Control
Bit
RIE
Interrupt Event
Event
Flag
Exit
from
Wait
Exit
from
Halt
The SCI interrupt events are connected to the same interrupt vector (see Interrupts chapter).
These events generate an interrupt if the corre­sponding Enable Control Bit is set and the inter-
rupt mask in the CC register is reset (RIM instruc­tion).
60/109
SERIAL COMMUNICATIONS INTERFACE (Cont’d)
5.5.7 Register Description
STATUS REGISTER (SR)
Read Only
Note: T he IDLE bit will not be set again unt il the RDRF bit has been set itself (i.e. a new idle line oc­curs). This bit is not set by an idle line when the re­ceiver wakes up from wake-up mode.
Reset Value: 1100 0000 (C0h)
70
TDRE TC RDRF IDLE O R NF FE
0
Bit 3 = OR This bit is set by hardware when the word currently being received in the s hift register is ready to be transferred into the RDR register while RDRF=1.
Overrun error.
An interrupt is generate d i f RIE=1 in th e CR2 reg-
Bit 7 = TDRE
Transmit data register empty.
This bit is set by hardware when the content of the TDR register has been transferred into the shift register. An interrupt is generated if TIE =1 in the CR2 register. It is cleared by a software sequence
ister. It is cleared by hardware when RE=0 by a software sequence (an access to the SR register followed by a read to the DR register). 0: No Overrun error 1: Overrun error is detected
(an access to the SR register followed by a write to the DR register). 0: Data is not transferred to the shift register 1: Data is transferred to the shift register
Note: data will not be transferred to the shift regis­ter as long as the TDRE bit is not reset.
Note: When this bit is set the RDR register content will not be lost but the shift register will be overwrit­ten.
Bit 2 = NF
Noise flag.
This bit is set by hardware when noise is detected on a received frame. It is cleared by hardware
Bit 6 = TC
Transmission complete.
This bit is set by hardware when transmission of a frame containing Data, a Preamble or a Break is complete. An interrupt is generat ed if TCIE=1 in the CR2 register. It is cleared by a software se­quence (an access to the SR register followed by a write to the DR register). 0: Transmission is not complete
when RE=0 by a software sequence (an access to the SR register followed by a read to the DR regis­ter). 0: No noise is detected 1: Noise is detected
Note: This bit does not generate interrupt as it ap­pears at the same time as the RDRF bit which it­self generates an interrupt.
1: Transmission is complete
Bit 5 = R DRF
Received data ready flag.
This bit is set by hardware when the content of the RDR register has been transferred into the DR register. An interrupt is generated if RIE=1 in the CR2 register. It is cleared by hardware when RE=0 or by a software sequence (an access to the SR register followed by a read to the DR register). 0: Data is not received 1: Received data is ready to be read
Bit 1 = FE This bit is set by hardware when a de-synchroniza­tion, excessive noise or a b reak character is de­tected. It is cleared by hardware when RE=0 by a software sequence (an access to the SR register followed by a read to the DR register). 0: No Framing error is detected 1: Framing error or break character is detected
Note: This bit does not generate interrupt as it ap­pears at the same time as the RDRF bit which it-
Framing error.
self generates an interrupt. If the word currently
Bit 4 = IDLE This bit is set by hardware when an Idle Line is de­tected. An interrupt is generated if ILIE=1 in the
Idle line detect.
being transferred causes both frame error and overrun error, it will be transferred and only the OR bit will be se t.
CR2 register. It is cleared by hardware when RE=0 by a software sequence (an access to the SR register followed by a read to the DR register).
Bit 0 = Reserved, forced by hardware to 0. 0: No Idle Line is detected 1: Idle Line is detected
ST7263
61/109
ST7263
SERIAL COMMUNICATIONS INTERFACE (Cont’d) CONTROL REGISTER 1 (CR1)
Read/Write Reset Value: Undefined
0: interrupt is inhibited
1: An SCI interrupt is generated whenever TC=1 in
the SR register
70
Bit 5 = RIE
Receiver interrupt enable
This bit is set and cleared by software.
R8 T8 0 M WAKE 0 0
0
0: interrupt is inhibited
1: An SCI interrupt is generated whenever OR=1
or RDRF=1 in the SR register
Bit 7 = R8 This bit is used t o store the 9t h bit o f the rec ei ved word when M=1.
Receive data bit 8.
Bit 4 = ILIE
Idle line interrupt enable.
This bit is set and cleared by software.
0: interrupt is inhibited Bit 6 = T8
Transmit data bit 8.
This bit is used to store the 9th bit of the transmit-
1: An SCI interrupt is generated whenever IDLE=1
in the SR register.
ted word when M=1.
Transmitter enable.
Bit 5 = Reserved, forced by hardware to 0.
Bit 3 = TE
This bit enables the transmitter and assigns the
TDO pin to the alternate function. It is set and
cleared by software. Bit 4 = M
Word length.
This bit determines the data length. It is set or cleared by software. 0: 1 Start bit, 8 Data bits, 1 Stop bit 1: 1 Start bit, 9 Data bits, 1 Stop bit
0: Transmitter is disabled, the TDO pin is back to
the I/O port configuration.
1: Transmitter is enabled
Note: During transmission, a “0” pulse on the TE
bit (“0” followed by “1”) sends a preamble after the
current word. Bit 3 = WAKE
This bit determines the SCI Wake-Up method, it is set or cleared by software. 0: Idle Line 1: Address Mark
Wake-Up method.
Bit 2 = RE
Receiver enable.
This bit enables the receiver. It is set and cleared
by software.
0: Receiver is disabled, it resets the RDRF, IDLE,
OR, NF and FE bits of the SR register.
Bits 2:0 = Reserved, forced by hardware to 0.
1: Receiver is enabled and begins searching for a
start bit.
.
CONTROL REGISTER 2 (CR2)
Read/Write Reset Value: 0000 0000 (00h)
70
Bit 1 = RWU
This bit determines if the SCI is in mut e mode or
not. It is set and cleared by so ftware and can be
cleared by hardware when a wake-up sequence is
recognized.
0: Receiver in active mode
Receiver wake-up.
1: Receiver in mute mode
TIE TCIE RIE ILIE TE RE RWU SBK
Send break.
Bit 7 = TIE
Transmitter interrupt enable
. This bit is set and cleared by software. 0: interrupt is inhibited 1: An SCI interrupt is generated whenever
TDRE=1 in the SR register.
Bit 0 = SBK This bit set is used to se nd break characters. It is set and cleared by software. 0: No break character is transmitted 1: Break characters are transmitted
Note: If the SBK bit is set to “1” and then to “0”, the transmitter will send a BREAK word at the end of
Bit 6 = TCIE
Transmission complete interrupt ena-
the current word.
ble
This bit is set and cleared by software.
62/109
SERIAL COMMUNICATIONS INTERFACE (Cont’d) DATA REGISTER (DR)
Read/Write Reset Value: Undefined Contains the Received or Transmitted dat a char-
acter, depending on whether it is read from or writ­ten to.
70
DR7 DR6 DR5 DR4 DR3 DR2 DR1 DR0
The Data register performs a double function (read and write) since it is composed of two reg isters, one for transmission (T DR) and one for recep tion (RDR). The TDR register provides the parallel interface
Bits 5:3 = SCT[2:0] These 3 bits, in conjunction with the SCP1 & SCP0
bits, define the total division applied to the bus clock to yield the transmit rate clock in convention­al Baud Rate Generator mode.
TR Dividing Factor SCT2 SCT1 SCT0
1 000 2 001 4 010
8 011 16 100 32 101 64 110
128 1 1 1
SCI Transmitter rate divisor
between the internal bus and the out put shift reg­ister (see Figure 1). The RDR register provides the parallel interface between the input shift register and the internal bus (see Figure 1).
BAUD RATE REGISTER (BRR)
Read/Write Reset Value: 00xx xxxx (XXh)
70
SCP1 SCP0 SCT2 SCT1 SCT0 SCR2 SCR1 SCR0
Bits 7:6= SCP[1:0]
First SCI Prescaler
These 2 prescaling bits allow several standard clock division ranges:
PR Prescaling Factor SCP1 SCP0
100 301 410
13 1 1
Bits 2:0 = SCR[2:0] These 3 bits, in conjunction with the SCP1 & SCP0
bits, define the total division applied to the bus clock to yield the receive rate clock in conventional Baud Rate Generator mode.
RR Dividing Factor SCR2 SCR1 SCR0
1 000
2 001
4 010
8 011 16 100 32 101 64 110
128 1 1 1
SCI Receiver rate divisor.
ST7263
63/109
ST7263
SERIAL COMMUNICATIONS INTERFACE (Cont’d) Table 18. SCI Register Map and Reset Values
Address
(Hex.)
20 SR
21 DR
22 BRR
23 CR1
24 CR2
Register
Label
Reset Value
Reset Value
Reset Value
Reset Value
Reset Value
76543210
TDRE
1
DR7
x
SCP1
0
R8
x
TIE
0
TC
1
DR6
x
SCP00SCT2xSCT1
T8
x
TCIE
0
RDRF0IDLE
0
DR5
x
0 0
RIE
0
DR4
x
x
M
x
ILIE
0
OR
0
DR3
x
SCT0xSCR2xSCR1xSCR0
WAKE
x
TE
0
NF
0
DR2
x
0 0
RE
0
FE
0
DR1
x
0 0
RWU
0
0 0
DR0
x
x
0 0
SBK
0
64/109
5.6 USB INTERFACE (USB)
ST7263
5.6.1 Introd uction
The USB Interface implements a low-speed func­tion interface between the USB and the ST7 mi­crocontroller. It is a highly integrated circuit whi ch includes the transceiver, 3.3 voltage regulator, SIE and DMA. No external components are needed apart from the external pull-up on USBDM for low speed recognition by the USB host. The use of DMA architecture allows the endpoint definition to be completely flexible. Endpoints can be config­ured by software as in or out.
5.6.2 Main Features
USB Specification Version 1.1 Compliant
Supports Low-Speed USB Protocol
Two or Three Endpoints (i ncludin g default one)
depending on the device (see device feature list and register map)
CRC generation/checking, NRZI encoding/
decoding and bit-stuffing
USB Suspend/Resume operations
DMA Data transfers
On-Chip 3.3V Regulator
On-Chip USB Transceiver
5.6.3 Functional Description
The block diagram in Fig ure 1 , gives an overview of the USB interface hardware.
For general information on the USB, refer to the
“Universal Serial Bus Specifications” document available at http//:www.usb.org.
Serial Interface Engine
The SIE (Serial Interface Engine) interfaces with the USB, via the transceiver.
The SIE processes tokens, handles data transmis­sion/reception, and handshaking as required by the USB standard. It also perf orms frame format­ting, including CRC generation and checking.
Endpoints
The Endpoint registers indicate if the microcontrol­ler is ready to transmit/receive, and how many bytes need to be transmitted.
DMA
When a token for a valid Endpoint is recognized by the USB interface, the related data transfer takes place, using DMA. At the end of the transaction, an interrupt is generated.
Interrupts
By reading the Interrupt S tatus register, applica­tion software can know which USB event has oc­curred.
Figure 36. USB Block Diagram
USBDM
Transceiver
USBDP
3.3V
USBVCC
Voltage Regulator
USBGND
SIE
6 MHz
ENDPOINT
REGISTERS
DMA
INTERRUPT REGISTERS
CPU
Address, data buses and interrupts
MEMORY
65/109
ST7263
USB INTERFACE (Cont’d)
5.6.4 Register Description DMA ADDRESS REGISTER (DMAR)
Read / Write Reset Value: Undefined
70
DA15 DA14 DA13 DA12 DA11 DA10 DA9 DA8
Bits 7:0=DA[15:8] Software must write the start address of the DMA memory area whose most significant bits are given by DA15-DA6. The remaining 6 address bits are set by hardware. See the description of the I DR register and Figure 2.
DMA address bits 15-8.
INTERRUPT/DMA REGISTER (IDR)
Read / Write Reset Value: xxxx 0000 (x0h)
70
DA7 DA6 EP1 EP0 CNT3 CNT2 CNT1 CNT0
Bits 7:6 = DA[7:6] Software must reset these bits. See the descrip­tion of the DMAR register and Figure 2.
Bits 5:4 = EP[1:0] These bits identify the endpoint which required at­tention. 00: Endpoint 0 01: Endpoint 1 10: Endpoint 2
When a CTR interrupt occurs (see register ISTR) the software should read the EP bits to identify the endpoint which has sent or received a packet.
DMA address bits 7-6.
Endpoint numb er
(read-only).
Figure 37. DMA Buffers
DA15-6,000000
Bits 3:0 = CNT[3:0] This field shows how man y data bytes have b een received during the last data reception.
Note: Not valid for data transmission.
Byte count
(read only).
101111
Endpoint 2 TX
101000 100111
Endpoint 2 RX
100000 011111
Endpoint 1 TX
011000 010111
Endpoint 1 RX
010000 001111
Endpoint 0 TX
001000 000111
Endpoint 0 RX
000000
66/109
USB INTERFACE (Cont’d) PID REGISTER (PIDR)
Read only Reset Value: xx00 0000 (x0h)
ST7263
INTERRUPT STATUS REGISTER (ISTR)
Read / Write Reset Value: 0000 0000 (00h)
70
TP3TP2000
RX_ SEZ
RXD 0
70
SUSP DOVR CTR ERR IOVR ESUSP RESET SOF
When an interrupt occurs these bits are set by
Bits 7:6 = TP[3:2] USB token PIDs are encoded in four bits. TP[3:2] correspond to the variable token PID bits 3 & 2.
Token PID bits 3 & 2
.
hardware. Software must read them to determine the interrupt type and clear them after servicing.
Note : These bits cannot be set by software.
Note: PID bits 1 & 0 have a fixed value of 01.
When a CTR interrupt occurs (see register ISTR) the software should read the TP 3 and TP2 bits to retrieve the PID name of the token received. The USB standard defines TP bits as:
TP3 TP 2 PID Name
00 OUT 10 IN 1 1 SETUP
Bit 7 = SUSP
Suspend mode request
This bit is set by hardware when a constant idle state is present on the bus line for more than 3 ms, indicating a suspend m ode reques t from the U SB bus. The suspend request check is active immedi­ately after each USB reset event and its disabled by hardware when suspend mode is forced (FSUSP bit of CTLR register) until the end of resume sequence.
Bits 5:3 Reserved. Forced by hardware to 0.
DMA over/underrun
Bit 2 = R X_SEZ
Received single-ended zero
This bit indicates the status of the RX_SEZ trans­ceiver output. 0: No SE0 (single-ended zero) state
Bit 6 = DOVR This bit is set by hardware i f the ST7 processor can’t answer a DMA request in time. 0: No over/underrun detected 1: Over/underrun detected
1: USB lines are in SE0 (single-ended zero) state
Bit 1 = RXD
Received data
0: No K-state 1: USB lines are in K-state
This bit indicates the status of the RXD transceiver output (differential receiver output).
Note: If the environment is noisy, the RX_SEZ and RXD bits can be used to secure the application. By interpreting the status, software c an distinguish a valid End Suspend event from a spurious wake-up due to noise on the external USB line. A valid End Suspend is followed by a Resume or Reset se­quence. A Resume is indicated by RXD=1, a Re­set is indicated by RX_SEZ=1.
Bit 5 = CTR hardware when a correct transfer operation is per­formed. The type of transfer can be determined by looking at bits TP3-TP2 in register PIDR. The End­point on which the transfer was made is identified by bits EP1-EP0 in register IDR. 0: No Correct Transfer detected 1: Correct Transfer detected
Note: A transfer where the device sent a NA K or STALL handshake i s considered not correct (the host only sends ACK handshak es). A transfer is considered correct if there are no errors in the PID and CRC fields, if the DATA0/DATA1 PI D is sent as expected, if there were no data overruns, bit stuffing or framing errors.
Correct Transfer.
.
.
This bit is set by
Bit 0 = Reserved. Forced by hardware to 0.
Error.
Bit 4 = ERR This bit is set by hardware whenever one of the er­rors listed below has occurred: 0: No error detected 1: Timeout, CRC, bit stuffing or nonstandard
framing error detected
67/109
ST7263
USB INTERFACE (Cont’d)
Bit 3 = IOVR This bit is set when hardware tries t o set ERR, or SOF before they have been cleared by software. 0: No overrun detected 1: Overrun detected
Bit 2 = ESUSP This bit is set by hardware when, during suspend mode, activity is detected that wakes the USB i n­terface up from suspend mode.
This interrupt is serviced by a specific vector, in or­der to wake up the ST7 from HALT mode. 0: No End Suspend detected 1: End Suspend detected
Interrupt overrun.
End suspend mode
.
of each bit, please refer t o the corresponding bit description in ISTR.
CONTROL REGISTER (CTLR)
Read / Write Reset Value: 0000 0110 (06h)
70
0 0 0 0 RESUME PDWN FSUSP FRES
Bits 7:4 = Reserved. Forced by hardware to 0.
Bit 1 = R ESET
USB reset.
This bit is set by hardware when the USB reset se­quence is detected on the bus. 0: No USB reset signal detected 1: USB reset signal detected
Note: The DADDR, EP0RA, EP0RB, EP1RA, EP1RB, EP2RA and EP2RB registers are reset by a USB reset.
Bit 0 = SOF
Start of frame.
This bit is set by hardware when a low-speed SOF indication (keep-alive strobe) is seen o n the USB bus. It is also issued at the end of a resume se­quence. 0: No SOF signal detected 1: SOF signal detected
Note: To avoid spurious clearing of some bits, it is recommended to clear them using a load instruc­tion where all bits which must not be altered are set, and all bits to be cleared are reset. Avoid read­modify-write instructions like AND , XOR..
INTERRUPT MASK REGISTER (IMR)
Read / Write Reset Value: 0000 0000 (00h)
Bit 3 = RESUME
Resume
. This bit is set by software to wake-up the Host when the ST7 is in suspend mode. 0: Resume signal not forced 1: Resume signal forced on the USB bus.
Software should clear this bit after the appropriate delay.
Bit 2 = PDWN
Power down
. This bit is set by software to turn off the 3.3V on­chip voltage regulator that supplies the external pull-up resistor and the transceiver. 0: Voltage regulator on 1: Voltage regulator off
Note: After turning on the voltage regulator, soft­ware should allow at le ast 3 µs for s tabilisation of the power supply before using the USB interface.
Bit 1 = FSUSP
Force suspend mode
. This bit is set by software to enter Suspend mode. The ST7 should also be halted al lowing at least 600 ns before issuing the HALT instruction. 0: Suspend mode inactive 1: Suspend mode active
When the hardware detec ts USB a ctivity, it res ets this bit (it can also be reset by software).
70
SUSPMDOVRMCTRMERRMIOVRMESU
SPM
RES ETM
SOF
M
Bit 0 = FRES This bit is set by software to force a reset of the USB interface, just as if a RESET sequence came from the USB.
Force reset.
0: Reset not forced
Bits 7:0 = These bits are mask bits for a ll interrupt condition bits included in the ISTR. Whenever one of the IMR bits is set, if the corresponding ISTR bit is set, and the I bit in the CC register is cleared, an
1: USB interface reset forced. The USB is held in RESET state until software
clears this bit, at which point a “USB-RES ET” in­terrupt will be generated if enabled.
interrupt request is generated. For an explanation
68/109
USB INTERFACE (Cont’d) DEVICE ADDRESS REGISTER (DADDR)
Read / Write Reset Value: 0000 0000 (00h)
70
0 ADD6 ADD5 ADD4 ADD3 ADD2 ADD1 ADD0
Bit 6 = DTOG_TX
transfers.
It contains the required value of the toggle bit (0=DATA0, 1=DATA1) for the next transmitted data packet. This bit is set by hardware at the re­ception of a SETUP P ID. DTOG_TX toggle s only when the transmitter has received the ACK signal
Data Toggle, for tr ansmission
from the USB host. DTOG_TX and also
Bit 7 = Reserved. Forced by hardware to 0.
DTOG_RX (see E PnRB ) are n ormal ly up date d by hardware, at the receipt of a relevant PID. They can be also written by software.
Bits 6:0 = ADD[6:0] Software must write into this register the address
sent by the host during enumeration. Note: This register is also reset when a USB reset
is received from the USB bus or forced through bit FRES in the CTLR register.
ENDPOINT n REGISTER A (EPnRA)
Read / Write Reset Value: 0000 xxxx (0xh)
70
ST_
DTOG
OUT
_TX
Device address, 7 bits.
STAT
STAT
TBC3TBC2TBC1TBC
_TX1
_TX0
Bits 5:4 = STAT_TX[1:0]
Status bits, for transmis-
sion transfers.
These bits contain the information about the end­point status, which are listed below:
STAT_TX1 STAT_TX0 Meaning
00
01
10
0
11
DISABLED: transmission transfers cannot be executed.
STALL: the endpoint is stalled and all transmission requests result in a STALL handshake.
NAK: the endpoint is naked and all transmission requests result in a NAK handshake.
VALID: this endpoint is ena­bled for transmission.
ST7263
These registers (EP0RA, EP1RA and EP2RA) are used for controlling data transmission. They are also reset by the USB bus reset.
Note: Endpoint 2 an d the EP2RA register are not available on some devices (see device f eature list and register map).
Bit 7 = ST_OUT
Status out.
This bit is set by software to indicate that a status out packet is expec ted: in this case, al l nonzero OUT data transfers on the endpoint are STALLe d instead of being ACKed. When ST _OUT is reset, OUT transactions can have any number of bytes, as needed.
These bits are written by software. Hardware sets the STAT_TX bits to NAK when a correct transfer has occurred (CTR=1) related to a IN or SETUP transaction addressed to this endpoint; this allows the software to prepare the next set of data to be transmitted.
Bits 3:0 = TBC[3:0]
point n.
Transmit byte count for E nd-
Before tr ansmis sion, af ter fillin g the trans mit buf f­er, software must write in the TBC field the trans­mit packet size expressed in bytes (in the range 0-
8).
69/109
ST7263
USB INTERFACE (Cont’d) ENDPOINT n REGISTER B (EPnRB)
Read / Write Reset Value: 0000 xxxx (0xh)
70
CTRL
DTOG
_RX
STAT _RX1
STAT
EA3 EA2 EA1 EA0
_RX0
These registers (EP1RB and EP2RB) are used for controlling data reception on Endpoints 1 and 2. They are also reset by the USB bus reset.
Note: Endpoint 2 an d the EP2RB register are not available on some devices (see device f eature list and register map).
Bit 7 = CTRL
Control.
This bit should be 0. Note: If this bit is 1, the Endpoint is a con trol e nd-
point. (Endpoint 0 is always a control Endpoint, but it is possible to have more than one control End­point).
Bit 6 = DTOG_RX
fers
.
Data toggle, for reception trans-
It contains the expected value of the toggle bit (0=DATA0, 1=DATA1) for the next data packet. This bit is cleared by hardware in the first stage (Setup Stage) of a control transfer (SETUP trans­actions start always with DATA0 PID). The receiv­er toggles DTOG_RX o nly if it receives a correct data packet and the packet’s data PID matches the receiver sequence bit.
STAT_RX1 STAT_RX0 Meaning
NAK: the endpoint is na-
10
ked and all reception re­quests result in a NAK handshake.
11
VALID: this endpoint is enabled for reception.
These bits are written by software. Hardware sets the STAT_RX bits to NAK wh en a c orrect transfer has occurred (CTR=1) related to an OUT or SET­UP transaction addressed to this endpoint, so the software has the time to elaborate the received data before acknowledging a new transaction.
Bits 3:0 = EA[3:0]
Endpoint address
Software must write in this field the 4-bit address used to identify the transactions directed to this endpoint. Usually EP1RB contains “0001” and EP2RB contains “0010”.
ENDPOINT 0 REGISTER B (EP0RB)
Read / Write Reset Value: 1000 0000 (80h)
70
DTOGRXSTAT
1
RX1
STAT
RX0
0000
This register is used for controlling data reception on Endpoint 0. It is also reset b y the USB bus re­set.
.
Bits 5:4 = STAT_RX [1:0]
Status bi ts , fo r r ecept ion
transfers.
These bits contain the informat ion abo ut the e nd­point status, which are listed below:
STAT_RX1 STAT_RX0 Meaning
DISABLED: reception
00
transfers cannot be exe­cuted.
STALL: the endpoint is
01
stalled and all reception requests result in a STALL handshake.
70/109
Bit 7 = Forced by hardware to 1.
Bits 6:4 = Refer to the EPnRB register for a de­scription of these bits.
Bits 3:0 = Forced by hardware to 0.
USB INTERFACE (Cont’d)
5.6.5 Programming Considerations
The interaction between the USB interface and the application program is described below. Apart from system reset, action is always initiated by the USB interface, driven by one of the USB events associated with the Interrupt Status Register (IS­TR) bits.
5.6.5.1 Initializing the Registers
At system reset, t he software must initia lize all reg­isters to enable the USB interface to properly gen­erate interrupts and DMA requests.
1. Initialize the DMAR, IDR, and IMR registers (choice of enabled interrupts, address of DMA buffers). Refer the paragraph titled initializing the DMA Buffers.
2. Initialize the EP0RA and EP0RB registers to enable accesses to address 0 and endp oint 0 to support USB enumeration. Refer to the para­graph titled Endpoint Initialization.
3. When addresses are received through this channel, update the content of the DADDR.
4. If needed, write the endpoint numbers in the EA fields in the EP1RB and EP2RB register.
5.6.5.2 Initializing DMA buffers
The DMA buffers are a contiguous zone of memo­ry whose maximum size is 48 bytes. They can be placed anywhere in the memory space t o enable the reception of messages. The 10 most signifi­cant bits of the start of this memory area are spec­ified by bits DA15-DA6 in registers DMAR and IDR, the remaining bits are 0. The memory map is shown in Figure 2.
Each buffer is filled starting from the bottom (last 3 address bits=000) up.
5.6.5.3 Endpoint Initialization
To be ready to receive: Set STAT_RX to VALID (11b) in EP0RB to enable
reception. To be ready to transmit:
1. Write the data in the DMA transmit buffer.
2. In register EPnRA, specify the num ber of bytes to be transmitted in the TBC field
3. Enable the endpoint by setting the STAT_TX bits to VALID (11b) in EPnRA.
Note: Once transmission and/or reception are en­abled, registers EPnRA and/or EPnRB (respec­tively) must not be modified by software, as the hardware can change their value on the fly.
ST7263
When the operation is completed, they can be ac­cessed again to enable a new operation.
5.6.5.4 Interrupt Handling Start of Frame (SOF)
The interrupt service routine may monitor the SOF events for a 1 ms synchronization event to the USB bus. This interrupt is ge nerated at the end of a resume sequence and can also be used to de­tect this event.
USB Reset (RESET)
When this event occurs, the DADDR register is re­set, and communication is disabled i n all en dpoint registers (the USB interface will not respond to any packet). Software is responsible for reenabling endpoint 0 within 10 ms of the end of reset . To do this, set the STAT_RX bits in the EP0RB register to VALID.
Suspend (SUSP)
The CPU is warned abou t the lack of bus activity for more than 3 ms, which i s a suspend request. The software should set the USB interface to sus­pend mode and execute an S T 7 HA LT i ns truction to meet the USB-specified power constraints.
End Suspend (ESUSP)
The CPU is alerted by ac tivity on the US B, which causes an ESUSP interrupt. The ST7 automatical­ly terminates HALT mode.
Correct Transfer (CTR)
1. When this event occurs, the hardware automat­ically sets the STAT _ TX or STAT_ RX to NAK. Note: Every valid endpoint is NAKed until soft­ware clears the CTR bit in the ISTR register, independently of the endpoint number addressed by the tr ansfer which generated t he CTR interrupt. Note: If the event triggering the CTR interrupt is a SETUP transaction, both STAT_TX and STAT_RX are set to NAK.
2. Read the PIDR to obtain the token and t he I DR to get the endpo int number related to t he last transfer. Note: When a CTR i nterrupt occurs, the TP3­TP2 bits in the P IDR register and EP1-EP0 bi ts in the IDR register stay unchanged until the CTR bit in the ISTR register is cleared.
3. Clear the CTR bit in the ISTR register.
71/109
ST7263
USB INTERFACE (Cont’d)
Table 19. USB Register Map and Reset Values
Address
(Hex.)
25
26
27
28
29
2A
2B
2C
2D
2E
2F
30
31
Register
Name
PIDR Reset Value DMAR Reset Value IDR Reset Value ISTR Reset Value IMR Reset Value CTLR Reset Value DADDR Reset Value EP0RA Reset Value EP0RB Reset Value EP1RA Reset Value EP1RB Reset Value EP2RA Reset Value EP2RB Reset Value
7 6 5 4 3210
TP3
x
DA15
x
DA7
x
SUSP
0
SUSPM0DOVRM
0 0 0 0
ST_OUT
0 1 1
ST_OUT0DTOG_TX0STAT_TX10STAT_TX00TBC3
CTRL0DTOG_RX0STAT_RX10STAT_RX00EA3
ST_OUT0DTOG_TX0STAT_TX10STAT_TX00TBC3
CTRL0DTOG_RX0STAT_RX10STAT_RX00EA3
TP2
x
DA14
x
DA6
x
DOVR
0
0 0 0
ADD6
0
DTOG_TX
0
DTOG_RX0STAT_RX10STAT_RX0
0 0
DA13
EP1
CTR
0
CTRM
0 0 0
ADD5
0
STAT_TX10STAT_TX00TBC3
0
0
DA12
x
x
x
EP0
x
ERR
0
ERRM
0
0
0
ADD4
0
0
0
RX_SEZ0RXD
0
DA11
x
CNT3
0
IOVR0ESUSP0RESET
IOVRM0ESUSPM0RESETM0SOFM
RESUME0PDWN1FSUSP1FRES
ADD3
0
x
0
0
x
x
x
x
DA10
x
CNT2
0
ADD2
0
TBC2
x
0
0
TBC2
x
EA2
x
TBC2
x
EA2
x
0
DA9
x
CNT1
0
0
ADD1
0
TBC1
x
0
0
TBC1
x
EA1
x
TBC1
x
EA1
x
0
0
DA8
x
CNT0
0
SOF
0
0
0
ADD0
0
TBC0
x
0
0
TBC0
x
EA0
x
TBC0
x
EA0
x
72/109
5.7 I²C BUS INTERFACE (I²C)
ST7263
5.7.1 Introd uction
The I²C Bus Interface serves as an in terface be­tween the microcontroller and the serial I²C bus. It provides both multimaster and slave functions, and controls all I²C bus-specific sequencing, pro­tocol, arbitration and timing. It supports fast I²C mode (400kHz).
5.7.2 Main Features
Parallel-bus/I²C protocol converter
Multi-master capability
7-bit Addressing
Transmitter/Receiver flag
End-of-byte transmission flag
Transfer problem detection
I²C Master Features:
Clock generation
I²C bus busy flag
Arbitration Lost Flag
End of byte transmission flag
Transmitter/Receiver Flag
Start bit detection flag
Start and Stop generation
I²C Slave Features:
Stop bit detection
I²C bus busy flag
Detection of misplaced start or stop condition
Programmable I²C Address detection
Transfer problem detection
End-of-byte transmission flag
Transmitter/Receiver flag
5.7.3 General Description
In addition to receiving and transmitting data, this interface converts it from serial to parallel format and vice versa, using either an interrupt or polled
handshake. The interrupts are enabled or disabled by software. The interface is connected to the I²C bus by a data pin (SDAI) and by a clock pin (SCLI). It can be connected b oth with a standard I²C bus and a Fast I²C bus. This selection is made by soft­ware.
Mode Selection
The interface can operate in the four following modes:
– Slave transmitter/receiver – Master transmitter/receiver By default, it operates in slave mode. The interface automatically switches from slave to
master after it generates a START condition and from master to slave in case of arbitration loss or a STOP generation, this allows Multi-Master capa­bility.
Communicati on Flow
In Master mode, it initiates a data transfer and generates the clock signal. A serial data tran sfer always begins with a start condition and ends with a stop condition. Both start and stop conditions are generated in master mode by software.
In Slave mode, the interface is capable of recog­nising its own address (7-bit), and the General Call address. The General Call address d etection may be enabled or disabled by software.
Data and addresses are transferred as 8-bit bytes, MSB first. The first byte following the start condi­tion is the address byte; it is al ways transm itted in Master mode.
A 9th clock pulse follows the 8 clock cycles of a byte transfer, during which the receiver must send an acknowledge bit to the transmitter. Refer to Fig -
ure 1.
Figure 38. I²C BUS Protocol
SDA
SCL
START
CONDITION
MSB
ACK
12 89
STOP
CONDITION
VR02119B
73/109
ST7263
I²C BUS INTERFACE (Cont’d) The Acknowledge function may be enabled and
disabled by software. The I²C interface address and/or general call ad-
dress can be selected by software. The speed of the I²C interface may be selected be-
tween Standard (0-100 kHz) and Fast I²C (100­400 kHz).
SDA/SCL Line Control
Transmitter mode: the interface holds the clock line low before transmission to wait for the micro­controller to write the byte in the Data Register.
Receiver mode: the interface holds the clock line low after reception to wait for the microcontroller to read the byte in the Data Register.
Figure 39. I²C Interface Block Diagram
The SCL frequency (F
) is controlled by a pro-
SCL
grammable clock divider which depends on the I²C bus mode.
When the I²C cell is enabled, the SDA and SCL ports must be configured as floating open-drain output or floating input . In this case, the val ue of the external pull-up resistor used depends on t he application.
When the I²C cell is disabled, the SDA and SC L ports revert to being standard I /O port pins.
DATA REG ISTER (DR)
SDA
SCL
SDAI
SCLI
DATA CON TROL
CLOCK CONTROL
CLOCK CONTROL REGISTER (CCR )
CONTRO L REGISTE R (CR)
STATUS REGISTER 1 (SR1)
STATUS REGISTER 2 (SR2)
DATA SHIFT REGISTER
COMPARATOR
OWN ADDRESS REGISTER (OAR)
CONTROL LOGIC
74/109
INTERRUPT
I²C BUS INTERFACE (Cont’d)
5.7.4 Functional Description
Refer to the CR, SR1 and SR2 registers in Section
0.1.7. for the bit definitions.
By default the I²C interface operates in Slave mode (M/SL bit is cleared) except when it initiates a transmit or receive sequence.
5.7.4.1 Slave Mode
As soon as a start condition is detected, the address is received from the S DA line and s ent to the shift register; then it is compared with the address of the interface or the General Call address (if selected by software).
Address not matched: the interface ignores it and waits for another Start condition.
Address matched: the interface generates in se­quence:
– An A ckno wledge pul se is generated if the ACK
bit is set.
– EVF and ADSL bits are set with an interrupt i f the
ITE bit is set.
Then the interface waits for a read of the SR1 reg­ister, holding the SCL line low (see Figure 3 Transfer sequencing EV1). Next, software must read the DR register to deter­mine from the least significant bit if the slave must enter Receiver or Transmitter mode.
Slave Receiver
Following the address reception and after SR1 register has been read, the slave receives bytes from the SDA line into the DR register via the inter­nal shift register. After each byte the interface gen­erates in sequence:
– An A ckno wledge pul se is generated if the ACK
bit is set
– EVF and BTF bits are set with an interrupt if the
ITE bit is set.
Then the interface waits for a read of the SR1 reg­ister followed by a read of the DR register, holding the SC L li ne low (see Figure 3 Transfer sequenc- ing EV2).
ST7263
The slave waits for a read of the SR1 register fol­lowed by a write in the DR register, holding the SCL line low (see Figure 3 Transfer sequencing EV3).
When the acknowledge pulse is received: – The EVF and BTF bits are set by hardware with
an interrupt if the ITE bit is set.
Closing Slave Communication
After the last data byte is trans ferred a Sto p Con­dition is generated by the master. The interface detects this condition and sets:
– EVF and STOPF bits with an interrupt if the ITE
bit is set.
Then the interface waits for a read of the SR2 reg­ister (see Figure 3 Transfer sequencing EV4).
Error Cases
BERR: Detection of a Stop or a Start condition
during a byte transfer. In this case, the EVF and BERR bits are set with an interrupt if the ITE bit is set. If it is a Stop condition, then the interface dis­cards the data, released the lines and waits for another Start condition. If it is a Start condition, then the interface dis­cards the data and waits for the next slave ad­dress on the bus.
AF: Detection of a non-acknowledge bit. In this
case, the EVF and AF bits are set with an inter­rupt if the ITE bit is set.
Note: In both cases, the SCL line is not held low; however, the SDA line can remain low due to pos­sible “0” bits transmitted last. It is then necessary to release both lines by software.
How to Release the SDA / SCL lines
Set and subsequently clear the STOP bit while BTF is set. The SDA/SC L lines are release d after the transfer of the current byte.
Slave Transmitter
Following the address reception and after the SR1 register has been read, the slave sends bytes from the DR regi ster to the SDA li ne via the internal shift register.
75/109
ST7263
I²C BUS INTERFACE (Cont’d)
5.7.4.2 Master Mode
To switch from default Slave mode to Master mode, a Start condition generation is needed.
Start Condition and Transmit Slave Address
Setting the START bit while the BUSY bit is cleared causes the interface to switch to Master mode (M/SL bit set) and generates a Start condi­tion.
Once the Start condition is sent: – The EVF and SB bits are set by hardware with
an interrupt if the ITE bit is set.
Then the master waits for a read of the SR1 regis­ter followed by a write in the DR register with the Slave address byte, holding the SCL line low (see Figure 3 Transfer sequencing EV5).
Then the slave address byte is sent to the S DA line via the internal shift register.
After completion of this transfer (and acknowledge from the slave if the ACK bit is set):
– The EVF bit is set by hardware with interrupt
generation if the ITE bit is set.
Then the master waits for a read of the SR1 regis­ter followed by a write in t he CR register (f or exam­ple set PE bit), holding the SCL line low (see Fig-
ure 3 Transfer sequencing EV6).
Next the master must enter Rec eiver or Transm it­ter mode.
Master Receiver Following the address transmission and after the
SR1 and CR registers have be en accessed, the master receives bytes from the S DA line into the DR register via the internal shift register. After each byte the interface generates in sequence:
– An Acknowledge pulse is generated if if the ACK
bit is set
– EVF and BTF bits are set by hardware with an in-
terrupt if the ITE bit is set.
Then the interface waits for a read of the SR1 reg­ister followed by a read of the DR register, holding the SC L li ne low (see Figure 3 Transfer sequenc- ing EV7).
To close the communication: before reading the last byte from the DR register, set the STOP bit to generate the Stop condition . The interfa ce returns automatically to slave mode (M/SL bit cleared).
Note: In order to generate the non-acknowledge pulse after the last received data byte, the ACK bit must be cleared just before reading the second last data byte.
Master Transmitter
Following the address transmission and after SR1 register has been read, the master sends bytes from the DR register to the SDA line via the inter­nal shift register.
The master waits for a read of the SR1 register fol­lowed by a write in the DR register, holding the SCL line low (see Figure 3 Transfer sequencing EV8).
When the acknowledge bit is received, the interface sets:
– EVF and BTF bits with an interrupt if the ITE bit
is set.
To close the communication: after writing the last byte to the DR register, set the STOP bit to gener­ate the Stop c ondition. The interfac e goes auto­matically back to slave mode (M/SL bit cleared).
Error Cases
BERR: Detection of a Stop or a Start condition
during a byte transfer. In this case, the EVF and BERR bits are set by hardware with an interrupt if the ITE bit is set.
AF: Detection of a non-acknowledge bit. In this
case, the EVF and AF bits are set by hardware with a n in terru p t i f th e ITE bi t i s se t. To resume , set the START or STOP bit.
ARLO: Detection of an arbitration lost condition.
In this case the ARLO bit is set by hardware (with an interrupt if the ITE bit is set and the interface goes automatically back to slave mode (the M/SL bit is cleared).
Note: In all these cases, the SCL line is not held low; however, the SDA line can remain low due to possible “0” bits transmitted last. It is then neces­sary to release both lines by software.
76/109
I²C BUS INTERFACE (Cont’d)
Sl
Figure 40. Transfer Sequencing
ave Receiver
S Address A Data1 A Data2 A
EV1 EV2 EV2 EV2 EV4
DataN A P
.....
Slave Transmitter
S Address A Data1 A Data2 A
EV1 EV3 EV3 EV3 EV3-1 EV4
DataN NA P
.....
Master Receiver
S Address A Data1 A Data2 A
EV5 EV6 EV7 EV7 EV7
DataN NA P
.....
Master Trans mitter
S Address A Data1 A Data2 A
EV5 EV6 EV8 EV8 EV8 EV8
DataN A P
.....
ST7263
Legend:
S=Start, P=Stop, A=Acknowledge, NA=Non-acknowledge EVx=Event (with interrupt if ITE=1)
EV1: EVF=1, ADSL=1, cleared by reading the SR1 register. EV2: EVF=1, BTF=1, cleared by reading the SR1 register followed by reading the DR register. EV3: EVF=1, BTF=1, cleared by reading the SR1 register followed by writing the DR register.
EV3-1: EVF=1, AF=1, BTF=1; AF is cleared by reading the SR1 register. The BTF is cleared
by releasing the lines (STOP=1, STOP=0) or by writing the DR register (DR=FFh).
Note: If lines are released by STOP=1, STOP=0, the subsequent EV4 is not seen. EV4: EVF=1, STOPF=1, cleared by reading the SR2 register. EV5: EVF=1, SB=1, cleared by reading the SR1 register followed by writing the DR register. EV6: EVF=1, cleared by reading the SR1 register followed by writing the CR register
(for example PE=1).
EV7: EVF=1, BTF=1, cleared by reading the SR1 register followed by reading the DR register. EV8: EVF=1, BTF=1, cleared by reading the SR1 register followed by writing the DR register.
77/109
ST7263
I²C BUS INTERFACE (Cont’d)
5.7.5 Low Power Modes Mode Description
WAIT
HALT
5.7.6 Interrupts
Figure 41. Event Flags and Interrupt Generation
No effect on I²C interface. I²C interrupts exit from Wait mode.
I²C registers are frozen.
In Halt mode, the I ²C in terface is inact ive and does not ack nowled ge da ta on the bus. The I²C interface resumes operation when the MCU is woken up by an interrupt with “exit from Halt mode” capability.
BTF
ADSL
SB
AF
STOPF
ARLO BERR
ITE
INTERRUPT
EVF
*
*
EVF can also be set by EV6 or an error from the SR2 register.
Interrupt Event
End of Byte Transfer Event BTF Address Matched Event (Slave mode) ADSEL Yes No Start Bit Generation Event (Master mode) SB Yes No Acknowledge Failure Event AF Yes No Stop Detection Event (Slave mode) STOPF Yes No Arbitration Lost Event (Multimaster configuration) ARLO Yes No Bus Error Event BERR Yes No
The I²C interrupt events are connected to the same interrupt vector (see Interrupts chapter).
They generate an interrupt if the corresponding Enable Control Bit is set and the I-bit in the CC
Event
Flag
Enable
Control
Bit
ITE
Exit
from
Wait
Exit
from
Halt
register is reset (RIM instruction).
78/109
I²C BUS INTERFACE (Cont’d)
5.7.7 Register Description
I²C CONTROL REGISTER (CR)
Read / Write Reset Value: 0000 0000 (00h)
70
Bit 2 = ACK This bit is set and cleared by software. It is also cleared by hardware when the interface is disa­bled (PE=0). 0: No acknowledge returned
Acknowledge enable.
1: Acknowledge returned after an address byte or
0 0 PE ENGC START ACK STOP ITE
a data byte is received
ST7263
Bits 7:6 = Reserved. Forced to 0 by hardware. Bit 5 = PE
Peripheral enable.
This bit is set and cleared by software. 0: Peripheral disabled 1: Master/Slave capability Notes:
– W hen PE= 0, all the bits of the CR register and
the SR register except the Stop bit are reset. All outputs are released while PE=0
– W hen PE= 1, the correspond ing I/O pins are se-
lected by hardware as alternate functions.
– To enable the I²C interface, write the CR register
TWICE with PE=1 as the first write only activates the interface (only PE is set).
Bit 4 = ENGC
Enable General Call.
This bit is set and cleared by software. It is also cleared by hardware when the interface is disa­bled (PE=0). The 00h General Call address is ac­knowledged (01h ignored). 0: General Call disabled 1: General Call enabled
Bit 3 = START
Generation of a Start condition
This bit is set and cleared by software. It is also cleared by hardware when the interface is disa­bled (PE=0) or when the Start condition is sent (with interrupt generation if ITE=1).
– In master mode :
0: No start generation 1: Repeated start generation
– In slave mode :
0: No start generation 1: Start generation when the bus is free
Bit 1 = STOP
Generation of a Stop condition
This bit is set and cleared by software. It is also cleared by hardware in master mode. Note: This bit is not cleared when the interface is disabled (PE=0).
– In Master mode:
0: No stop generation 1: Stop generation after the current byte transfer or after the current Start condition is sent. The STOP bit is cleared by hardware when the Stop condition is sent.
– In Slave mode:
0: No stop generation 1: Release the SCL and SDA lines after the cur­rent byte transfer (BTF=1). In this mode the STOP bit has to be cleared by software.
Bit 0 = ITE
Interrupt enable.
This bit is set and cleared by software and cleared by hardware when the interface is disabled (PE=0). 0: Interrupts disabled 1: Interrupts enabled
Refer to Figure 4 for the relationship between the events and the interrupt.
.
SCL is held low when the SB, BTF or ADS L flags or an EV6 event (See Figure 3) is detected.
.
79/109
ST7263
I²C BUS INTERFACE (Cont’d) I²C STATUS REGISTER 1 (SR1)
Read Only Reset Value: 0000 0000 (00h)
70
EVF 0 TRA BUSY BTF ADSL M/SL SB
Bit 3 = BTF This bit is set by hardware as soon as a byte is cor­rectly received or transmitted with interrupt gener­ation if ITE=1. It is cleared by software reading SR1 register followed by a read or write of DR reg­ister. It is also cleared by hardware when the inter­face is disabled (PE=0).
– Following a byte transmission, this bit is set after
Bit 7 = EVF
Event flag.
This bit is set by hardware as soon as an event oc­curs. It is cleared by software reading SR2 register in case of error event or as described in Figure 3. It is also cleared by hardware when the interface is disabled (PE=0). 0: No event 1: One of the following events has occurred:
– BTF=1 (Byte received or transmitted) – ADSL=1 (Address matched in Slave mode
while ACK=1 )
– SB=1 (Start condition generated in Master
reception of the acknowledge clock pulse. In case an address byte is sent, this bit is set only after the EV6 event (See Figure 3). BTF is cleared by reading SR1 register followed by writ­ing the next byte in DR register.
– Following a byte reception, this bit is set after
transmission of the acknowledge clock pulse if ACK=1. BTF is cleared by reading SR1 register
followed by reading the byte from DR register. The SCL line is held low while BTF=1. 0: Byte transfer not done
1: Byte transfer succeeded
mode)
– AF=1 (No acknowledge received after byte
transmission)
– STOPF=1 (Stop condition detected in Slave
mode) – ARLO=1 (Arbitration lost in Master mode) – BERR=1 (Bus error, misplaced Start or Stop
condition detected) – Address byte successfully transmitted in Mas-
ter mode.
Bit 2 = ADSL This bit is set by hardware as soon as the received slave address matched with the OAR register con­tent or a general call is recognized. A n in terrupt is generated if ITE=1. It is c leared by sof tware read­ing SR1 register or by hardware when t he inter­face is disabled (PE=0).
The SCL line is held low while ADSL=1. 0: Address mismatched or not received
1: Received address matched
Byte transfer finished.
Address matched (Slave mode).
Bit 6 = Reserved. Forced to 0 by hardware.
Bit 5 = TRA
Transmitter/Receiver.
When BTF is set, TRA=1 if a dat a byte has been transmitted. It is cleared automatically when BTF is cleared. It is also cleared by hardware after de­tection of Stop condition (STOPF=1), loss of bus arbitration (ARLO=1) or when the interface is disa­bled (PE=0). 0: Data byte received (if BTF=1) 1: Data byte transmitted
Bit 4 = BUSY
Bus busy
. This bit is set by hardware on de tection of a S tart condition and cleared by hardware on detection of a Stop condition. I t indicates a communi cation in progress on the bus. This information is still updat­ed when the interface is disabled (PE=0). 0: No communication on the bus 1: Communication ongoing on the bus
80/109
Bit 1 = M/SL
Master/Slave.
This bit is set by hardware as soon as the interface is in Master mode (writing START=1). It is cleared by hardware after detecting a Stop condition on the bus or a loss of arbitration (ARLO=1). It is also cleared when the interface is disabled (PE=0). 0: Slave mode 1: Master mode
Bit 0 = SB
Start bit (Master mode).
This bit is set by hardware as soon as the Start condition is generated (following a write START=1). An interrupt is generated if ITE=1. It is cleared by software reading SR1 register followed by writing the address byte in DR register. It is al so cleared by hardware when the interface is disa­bled (PE=0). 0: No Start condition 1: Start condition generated
I²C BUS INTERFACE (Cont’d) I²C STATUS REGISTER 2 (SR2)
Read Only Reset Value: 0000 0000 (00h)
70
es the arbitration of the bus to another master. An interrupt is generated if ITE=1. It is cleared by soft­ware reading SR2 register or by hardware when the interface is disabled (PE=0).
After an ARLO event the interface switches back
0 0 0 AF STOPF ARLO BERR GCAL
automatically to Slave mode (M/SL=0). The SCL line is not held low while ARLO=1. 0: No arbitration lost detected
Bits 7:5 = Reserved. Forced to 0 by hardware.
1: Arbitration lost detected
ST7263
Bit 4 = AF
Acknowledge failure
. This bit is set by hardware when no acknowledg e is returned. An interrupt is generated if ITE=1. It is cleared by software reading SR2 register or by hardware when the interface is disabled (PE=0).
The SCL line is not held low while AF=1. 0: No acknowledge failure
1: Acknowledge failure
Bit 3 = STOPF
Stop detection (Slave mode).
This bit is set by hardware when a St op condition is detected on the bus after an acknowledge (if ACK=1). An interrupt is generated if ITE=1. It is cleared by software reading SR2 register or by hardware when the interface is disabled (PE=0).
The SCL line is not held low while STOPF=1. 0: No Stop condition detected
1: Stop condition detected
Bit 2 = ARLO
Arbitration lost
.
This bit is set by hardware when the interface los-
Bit 1 = BERR
Bus error.
This bit is set by hardware when the interface de­tects a misplaced Start or Stop condition. An inter­rupt is generated if ITE=1. It is cleared by software reading SR2 register or by hardware when the in­terface is disabled (PE=0).
The SCL line is not held low while BERR=1. 0: No misplaced Start or Stop condition
1: Misplaced Start or Stop condition
Bit 0 = GCAL
General Call (Slave mode).
This bit is set by hardware when a general call ad­dress is detected on the bu s while ENGC= 1. It is cleared by hardware detecting a Stop condition (STOPF=1) or when the interface is disabled (PE=0).
0: No general call address detected on bus 1: general call address detected on bus
81/109
ST7263
I²C BUS INTERFACE (Cont’d) I²C CLOCK CONTROL REGISTER (CCR)
Read / Write Reset Value: 0000 0000 (00h)
I²C OWN ADDRESS REGISTER (OAR)
Read / Write Reset Value: 0000 0000 (00h)
70
FM/SM CC6 CC5 CC4 CC3 CC2 CC1 CC0
Bit 7 = FM/SM
Fast/Standard I²C mode.
This bit is set and cleared by software. It is not cleared when the interface is disabled (PE=0).
0: Standard I²C mode 1: Fast I²C mode
Bits 6:0 = CC6-CC0 These bits select the s peed of t he bus (F
7-bit clock divider.
) de-
SCL
pending on the I²C mode. They are not cleared when the interface is disabled (PE=0).
– St andard m ode (FM /SM=0): F
F
= f
SCL
– Fas t mode (FM /SM =1): F
F
= f
SCL
Note: The programmed F
/(2x([CC6..CC0]+ 2))
CPU
SCL
/(3x([CC6..CC0]+ 2))
CPU
SCL
<= 100kHz
SCL
> 100kHz
assumes no load on
70
ADD7 ADD6 ADD5 ADD4 ADD3 ADD2 ADD1 ADD0
Bits 7:1 = ADD7-ADD1
Interface address
These bits define the I²C bus add ress o f the in ter­face. They a re not cleared when the interface is disabled (PE=0).
Bit 0 = ADD0
Address direction bit.
This bit is don’t care, the interface ack nowledges either 0 or 1. It is not cleared when the interface is disabled (PE=0).
Note: Address 01h is always ignored.
SCL and SDA lines.
I²C DATA REGISTER (DR) Read / Write
Reset Value: 0000 0000 (00h)
.
70
D7 D6 D5 D4 D3 D2 D1 D0
Bits 7:0 = D7-D0
8-bit Data Register.
These bits contains the byte to be received or transmitted on the bus.
– Tr ansmi tter mode: Byte transmiss ion start auto-
matically when the software writes in the DR reg­ister.
– Receiver mode: the first data byte is received au-
tomatically in the DR register using the least sig­nificant bit of the address. Then, the next data bytes are received one by one after reading the DR register.
82/109
Table 20. I2C Register Map
Address
(Hex.)
39 DR DR7 .. DR0 3B OAR ADD7 .. ADD0 3C CCR FM/SM CC6 .. CC0 3D SR2 AF STOPF ARLO BERR GCAL 3E SR1 EVF TRA BUSY BTF ADSL M/SL SB 3F CR PE ENGC START ACK STOP ITE
Register
Name
76543210
ST7263
83/109
ST7263
5.8 8-BIT A/D CONVERTER (ADC)
5.8.1 Introd uction
The on-chip Analog to Digital Converter ( ADC) pe­ripheral is a 8-bit, successive approximation con­verter with internal sample and hold circuitry. This peripheral has up to 8 multiplexed analog input channels (refer to device pin out description) that allow the peripheral to convert the analog vol tage levels from up to 8 different sources.
The result of the conversion is stored in a 8-bit Data Register. The A/D converter is controlled through a Control/Status Register.
Figure 42. ADC Block Diagram
AIN0 AIN1
AIN2 AIN3 AIN4 AIN5 AIN6 AIN7
ANALOG
MUX
SAMPLE
&
HOLD
5.8.2 Main Features
8-bit conversion
Up to 8 channels with multiplexed input
Linear successive approximation
Data register (DR) which contains the results
Conversion complete status flag
On/Off bit (to reduce consumption)
The block diagram is shown in Figure 42.
COCO
0CH0CH1CH2--ADON
(Control Status Register) CSR
ANALOG TO DIGITAL CONVERTER
84/109
f
CPU
AD7
AD4 AD0AD1AD2AD3AD6 AD5
(Data Register) DR
8-BIT A/D CONVERTER (ADC) (Cont’d)
5.8.3 Functional Description
The high level reference voltage V connected externally to the V reference voltage V nally to the V
pin. In some devices (refer to de-
SS
must be connected exter-
SSA
pin. The low level
DD
must be
DDA
vice pin out description) high and low level refer­ence voltages are internally c onnected to the V and VSS pins.
DD
Conversion accuracy may therefore be degraded by voltage drops and noise in the event of hea vily loaded or badly decoupled power supply lines.
Figure 43. Recommended Ext. Connections
V
DD
0.1µF
V V
DDA
SSA
ST7
R
AIN
V
AIN
Px.x/AINx
Characteristics:
The conversion is monotonic, meaning the result never decreases if the analog input does not an d never increases if the analog input does not.
If input voltage is greater than or equal to V
DD
(voltage reference high) then results = FFh (full scale) without overflow indication.
If input voltage V
(vol tage refe renc e l ow) then
SS
the results = 00h. The conversion time is 64 CPU clock cycles in-
cluding a sampling time of 31.5 CPU clock cycles.
is the maximum recommended impedance
R
AIN
for an analog input signal. If the impedance is too high, this will result in a loss of accuracy due to leakage and sampling not being completed in the alloted time.
The A/D converter is linear and the digital result of the conversion is given by the formula:
ST7263
The accuracy of the conversion is described in the Electrical Characteristics Section.
Procedure:
Refer to the CSR and DR register description sec­tion for the bit definitions.
Each analog input pin must be configured as input, no pull-up, no interrupt. Refer to the “I/O Ports” chapter. Using these p ins as analog inputs does not affect the ability of the port to be r ead as a logic input.
In the CSR register:
– Select the CH2 to CH0 bits to assign the ana-
log channel to convert. Refer to Table 21
Channel Selection.
– Set the ADON bi t. Then the A /D converter is
enabled after a stabilization time (typically 30 µs). It then performs a c ontinuou s conv ersion of the selected channel.
When a conversion is complete
– The COCO bit is set by hardware. – No interrupt is generated. – The result is in the DR register.
A write to the CSR register aborts the current con­version, resets the COCO bit and starts a new conversion.
5.8.4 Low Power Modes Note: The A/D converter may be disabled by re-
setting the ADON bit. This feature allows reduced power consumption when no conversion is need­ed.
Mode Description
WAIT No effect on A/D Converter
A/D Converter disabled. After wakeup from Halt mode, the A/D
HALT
Converter requires a stabilisation time before accurate conversions can be performed.
Digital res ult =
255 x Input Voltage Reference Voltage
Where Reference Voltage is V
DD
5.8.5 Interrupts
None.
- VSS.
85/109
ST7263
8-BIT A/D CONVERTER (ADC) (Cont’d)
5.8.6 Register Description CONTROL/STATUS REGISTER (CSR)
Read/Write Reset Value: 0000 0000 (00h)
70
COCO - ADON 0 - CH2 CH1 CH0
Bit 7 = COCO
Conversion Complete
This bit is set by hardware. It is cleared by soft­ware reading the result in the DR register or writing to the CSR register. 0: Conversion is not complete. 1: Conversion can be read from the DR register.
Table 21. Channel Selection
Pin* CH2 CH1 CH0
AIN0 000 AIN1 001 AIN2 010 AIN3 011 AIN4 100 AIN5 101 AIN6 110 AIN7 111
*IMPORTANT NOTE:
The number of pins AND the channel selection vary according to the device. REFER TO THE DEVICE PINOUT).
Bit 6 = R eserved . Must always be cleared.
Bit 5 = ADON
A/D converter On
This bit is set and cleared by software. 0: A/D converter is switched off. 1: A/D converter is switched on.
Note: A typical 30 µs delay time is necessary for the ADC to stabilize when the ADO N b it is set.
Bit 4 = R eserved . Forced by hardware to 0.
Bit 3 = R eserved . Must always be cleared.
Bits 2:0: CH[2:0]
Channel Selection
These bits are set and cleared by software. They select the analog input to convert.
DATA REGISTER (DR)
Read Only Reset Value: 0000 0000 (00h)
70
AD7AD6AD5AD4AD3AD2AD1AD0
Bit 7:0 = AD[7:0]
Analog Converted Value
This register contains the converted analog value in the range 00h to FFh.
Reading this register resets the COCO flag.
86/109
6 INSTRUCTION SET
ST7263
6.1 ST7 ADDRESSING MODES
The ST7 Core features 17 different addressing modes which can be classified in 7 main groups:
Addressing Mode Example
Inherent nop Immediate ld A,#$55 Direct ld A,$55 Indexed ld A,($55,X) Indirect ld A,([$55],X) Relative jrne loop Bit operation bset byte,#5
so, most of the ad dressing modes may be subdi­vided in two sub-modes called long and short:
– Long addressing mode is more powerful be-
cause it can use the full 64 Kbyte address space, however it uses more bytes and more CPU cy­cles.
– Short addressing mode is less powerful because
it can generally only access page zero (0000h ­00FFh range), but the instruction size is more compact, and faster. All memory to memory in­structions use short addressing modes only (CLR, CPL, NEG, BSET, BRES, BTJT, BTJF, INC, DEC, RLC, RRC, SLL, SRL, SRA, SWAP)
The ST7 Assembler optimizes the use of long and short addressing modes.
The ST7 Instruction set is designed to minimize the number of bytes required per instruction: To do
Table 22. ST7 Addressing Mode Overview
Mode Syntax
Inherent nop + 0 Immediate ld A,#$55 + 1 Short Direct ld A,$10 00..FF + 1 Long Direct ld A,$1000 0000..FFFF + 2
No Offset Direct Indexed ld A,(X) 00..FF Short Direct Indexed ld A,($10,X) 00..1FE + 1
Long Direct Indexed ld A,($1000,X) 0000..FFFF + 2 Short Indirect ld A,[$10] 00..FF 00..FF byte + 2 Long Indirect ld A,[$10.w] 0000..FFFF 00..FF word + 2 Short Indirect Indexed ld A,([$10],X) 00..1FE 00..FF byte + 2 Long Indirect Indexed ld A,([$10.w],X) 0000..FFFF 00..FF word + 2 Relative D irect jrne loop PC-128/PC+1 27 Relative I ndire ct jrne [$10] PC -128 /PC+1 27 Bit Direct bset $10,#7 00..FF + 1 Bit Indirect bset [$10],#7 00..FF 00..FF byte + 2 Bit Direct Relative btjt $10,#7,skip 00..FF + 2 Bit Indirect Relative btjt [$10],#7,skip 00..FF 00..FF byte + 3
Destination/
Source
Pointer
Address
(Hex.)
1)
1)
00..FF byte + 2
Pointer
Size
(Hex.)
Length
(Bytes)
+ 0 (with X register) + 1 (with Y register)
+ 1
Note 1. At the time the instruction is executed, the Program Counter (PC) points to the instruction follow­ing JRxx.
87/109
ST7263
ST7 ADDRESSING MODES (Cont’d)
6.1.1 Inherent
All Inherent instructions consist of a single byte. The opcode fully specifies all the required informa­tion for the CPU to process the operation.
Inherent Instruction Function
NOP No operation TRAP S/W Interrupt
WFI
HALT RET Sub-routine Return
IRET Interrupt Sub-routine Return SIM Set Interrupt Mask RIM Reset Interrupt Mask SCF Set Carry Flag RCF Reset Carry Flag RSP Reset Stack Pointer LD Load CLR Clear PUSH/POP Push/Pop to/from the stack INC/DEC Increment/Decrement TNZ Test Negative or Zero CPL, NEG 1 or 2 Complement MUL Byte Multip licatio n SLL, SRL, SRA, RLC,
RRC SWAP Swap Nibbles
6.1.2 Immediate
Immediate instructions have two bytes, the first byte contains the opcode, the second byte con­tains the operand value.
Immediate Instruction Function
LD Load CP Compare BCP Bit Compare AND, OR, XOR Logical Operations ADC, ADD, SUB, SBC Arithmetic Operations
Wait For Interrupt (Low Power Mode)
Halt Oscillator (Lowest Power Mode)
Shift and Rotate Operations
6.1.3 Direct
In Direct instructions, the operands are referenced by their memory address.
The direct addressing m ode consists of two sub­modes:
Direct (short)
The address is a byte, thus requires only one byte after the opcode, but only allows 00 - FF address­ing space.
Direct (lon g)
The address is a word, thus allowing 64 Kbyte ad­dressing space, but requires 2 bytes after the op­code.
6.1.4 Indexed (No Offset, Short, Long)
In this mode, the operand is referenced by its memory address, which is defined by the unsigned addition of an index register (X or Y) with an offset.
The indirect addressing mode consists of three sub-modes:
Indexed (No Offset)
There is no offset, (no extra byte after the opcode), and allows 00 - FF addressing space.
Indexed (Short)
The offset is a byte, thus requires only one byte af­ter the opcode and allows 00 - 1FE addressing space.
Indexed (long)
The offset is a word, thus allowing 64 Kbyte ad­dressing space and requires 2 byt es after the op­code.
6.1.5 Indirect (Short, Long)
The required data byte to do the operation is found by its memory address, located in memory (point­er).
The pointer address follows th e op co de. Th e i ndi­rect addressing mode consists of two sub-modes:
Indirect (short)
The pointer address is a byte, the pointer size is a byte, thus allowing 00 - FF addressing space, and requires 1 byte after the opcode.
Indirect (lon g)
The pointer address is a byte, the pointer size is a word, thus allowing 64 Kbyte addressing space, and requires 1 byte after the opcode.
88/109
ST7 ADDRESSING MODES (Cont’d)
6.1.6 Indi re ct In dexed (Shor t, Long)
This is a combination of indirect and short indexed addressing modes. The operand is referenced by its memory address, which is defined by the un­signed addition of an index register value (X or Y) with a pointer value located in memory. The point­er address follows the opcode.
The indirect indexed addressing mode consists of two sub-modes:
Indirect Indexed (Short)
The pointer address is a byte, the pointer size is a byte, thus allowing 00 - 1FE addressing space, and requires 1 byte after the opcode.
Indirect Inde xed (Long)
The pointer address is a byte, the pointer size is a word, thus allowing 64 Kbyte addressing space, and requires 1 byte after the opcode.
Table 23. Instructions Supporting Direct, Indexed, Indirect and Indirect Indexed Addressing Modes
ST7263
SWAP Swap Nibbles CALL, JP Call or Jump subroutine
6.1.7 Relative Mode (Direct, Indirect)
This addressing mode is used to m odify the PC register value by adding an 8-bit signed offset to it.
Available Relative Direct/
Indirect Instructions
JRxx Conditional Jump CALLR Call Relative
The relative addressing mode consists of two sub­modes:
Relative (Direct)
The offset follows the opcode.
Relative (Indirect)
The offset is defined in memory, of which t he ad­dress follows the opcode.
Function
Long and Short
Instructions
LD Load CP Compare AND, OR, XOR Logical Operations
ADC, ADD, SUB, SBC BCP Bit Compare
Short Instructions Only Function
CLR Clear INC, DEC Increment/Decrement TNZ Test Negative or Zero CPL, NEG 1 or 2 Complement BSET, BRES Bit Operations
BTJT, BTJF SLL, SRL, SRA, RLC,
RRC
Arithmetic Addition/subtrac­tion operations
Bit Test and Jump Opera­tions
Shift and Rotate Operations
Function
89/109
ST7263
6.2 INSTRUCTION GROUPS
The ST7 family devices use an Instruction Set consisting of 63 instructions. The instructions may
Load and Transfer LD CLR Stack operation PUSH POP RSP Increment/Decrement INC DEC Compare and Tests CP TNZ BCP Logical operations AND OR XOR CPL NEG Bit Operation BSET BRES Conditional Bit Test and Branch BTJT BTJF Arithmetic operations ADC ADD SUB SBC MUL Shift and Rotates SLL SRL SRA RLC RRC SWAP SLA Unconditional Jump or Call JRA JRT JRF JP CALL CALLR NOP RET Conditional Branch JRxx Interruption management TRAP WFI HALT IRET Code Condition Flag modification SIM RIM SCF RCF
be subdivided into 13 main groups as illustrated in the following table:
Using a pre-b y te
The instructions are described with one to four bytes.
In order to extend the number of available op­codes for an 8-bit CPU (256 opcodes), three differ­ent prebyte opcodes a re defined . These prebytes modify the meaning of the instruction they pre­cede.
The whole instruction becomes:
PC-2 End of previous instruction PC-1 Prebyte PC Opcode PC+1 A dditional word (0 to 2) according to the
number of bytes required to compute the effective address
These prebytes enable instruction in Y as well as indirect addressing modes to be implemented. They precede the opcode of the instruction in X or the instruction using direct addres sing mode . The prebytes are:
PDY 90 Replace an X based instruction using
immediate, direct, indexed, or inherent addressing mode by a Y one.
PIX 92 Replace an instruction using direct, di-
rect bit, or direct relative addressing mode to an instruction using the corre­sponding indirect addressing mode. It also changes an instruction using X indexed addressing mode to an instruc­tion using indirect X indexed addressing mode.
PIY 91 Repla ce an instruction using X indirect
indexed addressing mode by a Y one.
90/109
ST7263
INSTRUCTION GROUPS (Cont’d)
Mnemo Description Function/Example Dst Src H I N Z C
ADC Add with Carry A = A + M + C A M H N Z C ADD Addition A = A + M A M H N Z C AND Logical And A = A . M A M N Z BCP Bit compare A, Memory tst (A . M) A M N Z BRES Bit Reset bres Byte, #3 M BSET Bit Set bset Byte, #3 M BTJF Jump if bit is false (0) btjf Byte, #3, Jmp1 M C BTJT Jump if bit is true (1) btjt Byte, #3, Jmp1 M C CALL Call subroutine CALLR Call subroutine relative CLR Clear reg, M 0 1 CP Arithmetic Compare tst(Reg - M) reg M N Z C CPL One Complement A = FFH-A reg, M N Z 1 DEC Decrement dec Y reg, M N Z HALT Halt 0 IRET Interrupt routine return Pop CC, A, X, PC H I N Z C INC Increment inc X reg, M N Z JP Abs olute Jump jp [TBL.w] JRA Jump relative always JRT Jump relative JRF Never jump jrf * JRIH Jump if ext. interrupt = 1 JRIL Jump if ext. interrupt = 0 JRH Jump if H = 1 H = 1 ? JRNH Jump if H = 0 H = 0 ? JRM Jump if I = 1 I = 1 ? JRNM Jump if I = 0 I = 0 ? JRMI Jump if N = 1 (minus) N = 1 ? JRPL Jump if N = 0 (plus) N = 0 ? JREQ Jump if Z = 1 (equal) Z = 1 ? JRNE Jump if Z = 0 (not equal) Z = 0 ? JRC Jump if C = 1 C = 1 ? JRNC Jump if C = 0 C = 0 ? JRULT Jump if C = 1 Unsigned < JRUGE Jump if C = 0 Jmp if unsigned >= JRUGT Jump if (C + Z = 0) Unsigned >
91/109
ST7263
INSTRUCTION GROUPS (Cont’d)
Mnemo Description Function/Example Dst Src H I N Z C
JRULE Jump if (C + Z = 1) Unsigned <= LD Load dst <= src reg, M M, reg N Z MUL Multiply X,A = X * A A, X, Y X, Y, A 0 0 NEG Negate (2’s compl) neg $10 reg, M N Z C NOP No Operation OR OR operation A = A + M A M N Z POP Pop from the Stack pop reg reg M
pop CC CC M H I N Z C PUSH Push onto the Stack push Y M reg, CC RCF Reset carry flag C = 0 0 RET Subroutine Return RIM Enable Interrupts I = 0 0 RLC Rotate left true C C <= Dst <= C reg, M N Z C RRC Rotate right true C C => Dst => C reg, M N Z C RSP Reset Stack Pointer S = Max allowed SBC Subtract with Carry A = A - M - C A M N Z C SCF Set carry flag C = 1 1 SIM Disable Interrupts I = 1 1 SLA Shift left Arithmetic C <= Dst <= 0 reg, M N Z C SLL Shift left Logic C <= Dst <= 0 reg, M N Z C SRL Shift right Logic 0 => Dst => C reg, M 0 Z C SRA Shift right Arithmetic Dst7 => Dst => C reg, M N Z C SUB Subtraction A = A - M A M N Z C SWAP SWAP nibbles Dst[7..4] <=> Dst[3..0] reg, M N Z TNZ Test for Neg & Zero tnz lbl1 N Z TRAP S/W trap S/W interrupt 1 WFI Wait for Interrupt 0 XOR Exclusive OR A = A XOR M A M N Z
92/109
7 ELECTRIC AL CHARACTERI STICS
7.1 ABSOLUTE MAXIMUM RATINGS
ST7263
Devices of the ST72 family contain circuitry to pro­tect the inputs against damage due to high static voltage or electric fields. Nevertheless, it is recom­mended that normal precautions be observed in order to avoid subjecting this high-impedance cir­cuit to voltages above t hose quoted in the Abs o­lute Maximum Ratings. For proper operation, it is recommended that the input voltage V
be con-
IN
strained within the range:
- 0.3V) ≤ VIN (V
(V
SS
DD
+ 0.3V)
connect them to an appropriate logi c voltage level such as V connect (same remark for
or VDD. it is also recommended to
SS
V
DDA
and V
V
together on application.
DD
and VSS).
SSA
All the voltage in the following tables are refer­enced to V
SS
.
Stresses above those listed as “Absolute Maxi­mum Ratings” may c ause permanent damage to the device. Functional operation of the device at these conditions is no t impl ied. E xposure t o m ax i­mum rating condit ions for extended periods m ay
To enhance reliability of operation, it is recom-
affect device reliab i lity.
mended to configure unused I/Os as inputs and to
Table 24.
Absolute Maximum Ratings (Voltage Referenced to V
Symbol Ratin gs Value Un it
V
DD
V
DDA
- VDD| Max. variations on Power Line 50 mV
|V
DDA
- VSS| Max. variations on Ground Line 50 mV
|V
SSA
- I
I
VDD
VSS
V
IN
V
OUT
T
A
T
STG
T
J
PD Power Dissipation 350 mW
ESD ESD susceptibility 2000 V
Recommended Supply Voltage - 0.3 to +6.0 V Analog Reference Voltage - 0.3 to +6.0 V
Total current into VDD/V Input Voltage VSS - 0.3 to VDD + 0.3 V Output Voltage VSS - 0.3 to VDD + 0.3 V
Ambient Temperature Range
Storage Temperature Range -65 to +150 °C Junction Temperature 150 °C
SS
)
SS
80/80 mA
T
to T
L
H
0 to + 70
°C
93/109
ST7263
7.2 THERMAL CHARACTERISTICS
The average chip-junction temperature, T grees Celsius, may be calculated using the follow-
, in de-
J
An approximate relationship between P (if P
is neglected) is given by:
I/O
ing equation:
P
= K÷ (TJ + 273°C) (2)
= TA + (PD x θJA) (1)*
T
J
D
Therefore:
Where:
– T
is the Ambient Temperature in °C,
A
θJ
is the Package Junction-to-Ambient Thermal
A
Resistance, in °C/W,
is the sum of P
– P
D
is the product of I
– P
INT
and P
INT
DD and VDD
,
I/O
, expressed in
Watts. This is the Chip Internal Power
represents the Power Dissipation on Input
– P
I/O
and Output Pins; User Determined.
For most applications P glected. P
may be significant if the device is con-
I/O
I/O<PINT
and may be ne-
K = P
x (TA + 273°C) + θJA x P
D
Where:
– K is a constant for the particular part, which may
be determined from equation (3) by measuring P
(at equilibrium) for a known TA. Using this val-
D
ue of K, the values of P
and TJ may be obtained
D
by solving equations (1) and (2) iteratively for any value of T
.
A
figured to drive Darlington bases or sink LED Loads.
Table 25. Thermal Characteristics
Symbol Package Typical Value Unit
J
θ
A
SO34 70
PSDIP32 50
D
D
2
°C/W
and T
(3)
J
(*): Maximum chip dissipation can directly be obtained from T
(max), θJA and TA parameters.
j
94/109
ST7263
7.3 OPERATING CONDITIONS General Operating Conditions
(T
= 0 to +70°C unless otherwise specified)
A
Symbol Parameter Conditions Min Max Unit
f
= 4 MHz ; USB not guaranteed 3.00 4.00 V
CPU
= 8 MHz ; USB not guaranteed V
f
V
f
OSC
DD
CPU
Supply voltage
1)
f
= 8 MHz or 4 MHz
CPU
USB guaranteed f
= 8 MHz or 4 MHz
CPU
USB not guaranteed
External clock frequency 12 24 MHz
IT+
4.0 5.25
5.25 5.50
Note 1: USB 1.1 specifies that the power supply must be between 4.0 0 and 5.25 Volts. The USB cell is therefore guaranteed only in that range.
4.00
V
95/109
ST7263
7.4 POWER CONSUMPTION
(T
= 0 to +70°C unless otherwise specified)
A
GENERAL
Symbol Parameter Conditions Min Typ. Max Unit
RUN & WAIT mode
Operating Supply Voltage
Analog Reference Voltage 4 5 5.5 V
V
V
DD
DDA
CPU RUN mode (see Note 1)
I
DD
CPU WAIT mode (See Note 2) 8 12 mA
CPU HALT mode (see Note 3) 100
USB Suspend mode (see Note 4) 350 450
Note 1: All peripherals running. Note 2: Oscillator, 16-bit Timer (free running counter) and watchdog running.
All others peripherals (including EPROM/RAM memories) disabled.
Note 3: CPU in HALT mode, USB Transceiver disabled, Low Voltage Reset function enabled. Note 4: Low voltage reset function enabled.
CPU in HALT mode. USB in suspend mode. External pull-up (1.5Kohms to USBVCC) and pull-down (15Kohms to V connected on drivers.
Note 5: V
= 5.5 V except in USB Suspend mode where VDD = 5.25 V
DD
f
= 24 MHz
OSC
= 8 MHz
f
CPU
I/O in input mode
f
= 8 MHz,
CPU
= 20°C
T
A
(For V
: see Note 5)
DD
4 5 5.5 V
14 20 mA
SSA
A
µ
A
µ
)
96/109
ST7263
7.5 I/O PORT CHARACTERISTICS
(T
= 0 to +70°C unless otherwise specified)
A
STANDARD I/O PORT PINS
Symbol Parameter Conditions Min Typ M ax Unit
Output Low Level Voltage Port A1,
Port A2 (High Current open drain)
V
OL
Output Low Level Voltage Port A0,
Port A(3:7), Port C(0:2), Push Pull
Output Low Level Voltage Port B (0:7),
Push Pull
V
OH
V
OH
V
IH
V
IL
R
PU
CIO I/O Pin Capacitance
t
f(IO)out
t
r(IO)out
t
r(IO)out
Output High Level Voltage Port A0,
Port A(3:7), Port C(0:2) Push Pull
Output High Level Voltage Port B (0:7)
Push Pull
Input High Level Voltage
PA(0:7),PB(0:7),PC(0:2),RESET
Input Low Voltage PA(0-7),
PB(0-7), PC(0-2), RESET
Pull-up resistor VDD = 5V 80 100 120 k
1)
Output High to Low Level Fall Time
All I/O ports
Output Low to High Level Rise Time
I/O ports in Push Pull mode
External Interrupt pulse time
1)
All voltages are referred to VSS unless otherwise specified.
Note 1: Guaranteed by design, not tested in production. Note 2: Data based on characterization results, not tested in production.
I
= -25mA VDD=5V - - 1.5 V
OL
= -1.6mA VDD=5V - - 0.4 V
I
OL
= -10mA VDD=5V - - 1.3 V
I
OL
I
= 1.6mA VDD-0.8 - - V
OH
I
= 10mA VDD-1.3 - - V
OH
Leading Edge 0.7xV
Trailing Edge V
SS
DD
0.3xV
5pF
2)
CL=50pF
Between 10% and 90%
25
25
2)
1t
V
DD
DD
V
V
ns
ns
CPU
97/109
ST7263
7.6 LOW VOLTAGE DETECTOR (LVD) CHARACTERISTICS
LOW VOLTAGE RESET Electrical Specifications
Symbol Parameter Conditions Min Typ Max Unit
V
IT+
V
IT-
V
hys
Low Voltage Reset Threshold
rising
V
DD
Low Voltage Reset Threshold
falling
V
DD
Hysteresis (V
IT+
- V
) 200 250 mV
IT-
7.7 CONTROL TIMING CHARACTERISTICS
Max. Variation
V
DD
50mV/µs
Max. Variation
V
DD
50mV/µs
3.6 3.75 4.0 V
3.2 3.5 3.7 V
(Operating conditions T
= 0 to +70°C unless otherwise specified)
A
CONTROL TIMINGS
Symbol Parameter Conditions
f
OSC
f
CPU
t
t
PORL
T
DOGL
t
DOG
t
OXOV
t
DDR
Note 1: The minimum period t
C
Oscillator Frequency 24 MHz Operating Frequency 8 MHz External RESET
RL
Input pulse Width Internal Power Reset Duration 4096 t Watchdog & Low Voltage Reset
Output Pulse Width Watchdog Time-out
= 8MHz
f
cpu
Crystal Oscillator Start-up Time
Power up rise time from VDD = 0 to 4V 100 ms
should not be less than the number of cycle times it takes to execute the
ILIL
interrupt service routine plus 21 cycles.
Value
Min Typ. Max
1.5 t
200 ns
49152
6
3145728
384
50 ms
Unit
CPU
CPU
t
CPU
ms
98/109
7.8 COMMUNICATION INTERFACE CHARACTERISTICS
The values given in the specifications of dedicated functions are generally not applicable for chips. Therefore, only the limits listed below are val id f or
the product. T = 0... +70°C, V otherwise specified
.
- VSS = 5 V unless
DD
7.8.1 USB - Universal Bus Interface
(Operating conditions T
USB DC Electrical Characteristics
Parameter Symbol Conditions Min. Max. Unit
Input Levels:
Differential Input Sensitivity VDI I(D+, D-) 0.2 V Differential Common Mode Range VCM Includes VDI range 0.8 2.5 V Single Ended Receiver Threshold VSE 0.8 2.0 V
Output Levels
Static Output Low VOL RL of 1.5K ohms to 3.6v 0.3 V
Static Output High VOH RL of 15K ohm to V
USBVCC: voltage level USBV V
= 0 to +70°C, VDD = 4.0 to 5.25V unless otherwise specified)
A
SS
=5v 3.00 3.60 V
DD
2.8 3.6 V
Note 1: RL is the load connected on the USB drivers. Note 2: All the voltages are measured from the local ground potential.
ST7263
99/109
ST7263
COMMUNICATION INTERFACE CHARACTERISTICS (Cont’d) Figure 44. USB: Data signal Rise and fall time
Differential
Data Li nes
VCRS
V
SS
Crossover
points
tf
USB: Low speed electrical characteristics
Parameter Symbol Conditions Min Max Unit
Driver characteristics:
Rise time tr Note 1,CL=50 pF 75 ns
Fall Time tf Note 1, CL=50 pF 75 ns
Rise/ Fall Time matching trfm tr/tf 80 120 %
Output signal Crossover
Voltage
Note1: Measured from 10% to 90% of the data signal. For more detailed informations, please refer to Chapter 7 (Elec­trical) of the USB specification (version 1.1).
VCRS 1.3 2.0 V
tr
Note 1, CL=600 pF 300 ns
Note 1, CL=600 pF 300 ns
100/109
Loading...