The Datasheet Archive - 100 Million Datasheets from 7500 Manufacturers.    


Datasheet Search Engine   
 
Part # or Description: • 5V RS232 Driver • 2SC5066* • "Real Time Clock" • "USB connector" • "blue led" 5mm • 10 watt zener diode • 2N3055* motorola
 
Search Tip: Try entering the part number only. Include a wildcard (eg. lm317* or 1n4148*)

 

 

32/44-PIN 8-BIT WITH FLASH/ROM, 10-BIT ADC, TIMERS, SPI, INTERFACE


Datasheet Thumbnail

  

Download PDF



Top Searches for this datasheet



ST72324B
32/44-PIN 8-BIT WITH FLASH/ROM, 10-BIT ADC, TIMERS, SPI, INTERFACE
Memories dual voltage High Density Flash (HDFlash) with read-out protection capability. In-Application Programming InCircuit Programming HDFlash devices bytes HDFlash endurance: cycles, data retention: years 55°C Clock, Reset Supply Management Enhanced voltage supervisor (LVD) main supply with programmable reset thresholds auxiliary voltage detector (AVD) with interrupt capability Clock sources: crystal/ceramic resonator oscillators, internal oscillator, clock security system bypass external clock frequency multiplication Four Power Saving Modes: Halt, Active-Halt, Wait Slow Interrupt Management Nested interrupt controller interrupt vectors plus TRAP RESET external interrupt lines vectors) Ports 32/24 multifunctional bidirectional lines 22/17 alternate function lines 12/10 high sink outputs Timers Main Clock Controller with: Real time base, Beep Clock-out capabilities Configurable watchdog timer 16-bit Timer with: input capture, output compare, external clock input, pulse generator modes 16-bit Timer with: input captures, output compares, pulse generator modeFeatures ST72324B(J/K)6
1024 (256)
TQFP32 TQFP44
SDIP42
SDIP32
Communication Interfaces synchronous serial interface asynchronous serial interface (LIN compatible) Analog Peripheral (low current coupling) 10-bit with robust input ports Instruction 8-bit Data Manipulation Basic Instructions main Addressing Modes Unsigned Multiply Instruction Development Tools Full hardware/software development package In-Circuit Testing capability
Device Summary
ST72324B(J/K)4
(256) 3.8V 5.5V -40°C +125°C SDIP42, TQFP44 10x10,SDIP32, TQFP32
ST72324B(J/K)2
(256)
Program memory bytes (stack) bytes Voltage Range Temp. Range Package
Rev. October 2003 1/160
This preliminary information product development undergoing evaluation. Details subject change without notice.
Table Content1 INTRODUCTION DESCRIPTION REGISTER MEMORY FLASH PROGRAM MEMORY INTRODUCTION MAIN FEATURES STRUCTURE 4.3.1 Read-out Protection INTERFACE (IN-CIRCUIT PROGRAMMING) (IN-APPLICATION PROGRAMMING) RELATED DOCUMENTATION
4.7.1 Register Description CENTRAL PROCESSING UNIT INTRODUCTION MAIN FEATURES REGISTERS
SUPPLY, RESET CLOCK MANAGEMENT PHASE LOCKED LOOP MULTI-OSCILLATOR (MO) RESET SEQUENCE MANAGER (RSM)
6.3.1 Introduction 6.3.2 Asynchronous External RESET 6.3.3 External Power-On RESET 6.3.4 Internal Voltage Detector (LVD) RESET 6.3.5 Internal Watchdog RESET SYSTEM INTEGRITY MANAGEMENT (SI) 6.4.1 Voltage Detector (LVD) 6.4.2 Auxiliary Voltage Detector (AVD) 6.4.3 Clock Security System (CSS) 6.4.4 Power Modes 6.4.5 Register Description INTERRUPTS INTRODUCTION
MASKING PROCESSING FLOW INTERRUPTS POWER MODES CONCURRENT NESTED MANAGEMENT INTERRUPT REGISTER DESCRIPTION EXTERNAL INTERRUPTS 7.6.1 Port Interrupt Sensitivity EXTERNAL INTERRUPT CONTROL REGISTER (EICR)
POWER SAVING MODES INTRODUCTION SLOW MODE
2/160
Table Content8.3 WAIT MODE ACTIVE-HALT HALT MODES
8.4.1 ACTIVE-HALT MODE 8.4.2 HALT MODE PORTS INTRODUCTION 9.2.1 Input Modes 9.2.2 Output Modes 9.2.3 Alternate Functions PORT IMPLEMENTATION
FUNCTIONAL DESCRIPTION
POWER MODES INTERRUPTS
9.5.1 Port Implementation ON-CHIP PERIPHERALS 10.1 WATCHDOG TIMER (WDG) 10.1.1 Introduction 10.1.2 Main Features 10.1.3 Functional Description 10.1.4 Program Watchdog Timeout 10.1.5 Power Modes 10.1.6 Hardware Watchdog Option 10.1.7 Using Halt Mode with (WDGHALT option) 10.1.8 Interrupts 10.1.9 Register Description 10.2 MAIN CLOCK CONTROLLER WITH REAL TIME CLOCK BEEPER (MCC/RTC) 10.2.1 Programmable Clock Prescaler 10.2.2 Clock-out Capability 10.2.3 Real Time Clock Timer (RTC) 10.2.4 Beeper 10.2.5 Power Modes 10.2.6 Interrupts 10.2.7 Register Description 10.3 16-BIT TIMER 10.3.1 Introduction 10.3.2 Main Features 10.3.3 Functional Description 10.3.4 Power Modes 10.3.5 Interrupts 10.3.6 Summary Timer modes 10.3.7 Register Description 10.4 SERIAL PERIPHERAL INTERFACE (SPI) 10.4.1 10.4.2 10.4.3 10.4.4 10.4.5 Introduction Main Features General Description Clock Phase Clock Polarity Error Flags
3/160
Table Content10.4.6 Power Modes 10.4.7 Interrupts 10.4.8 Register Description 10.5 SERIAL COMMUNICATIONS INTERFACE (SCI)
10.5.1 Introduction 10.5.2 Main Features 10.5.3 General Description 10.5.4 Functional Description 10.5.5 Power Modes 10.5.6 Interrupts 10.5.7 Register Description 10.6 10-BIT CONVERTER (ADC) 10.6.1 Introduction 10.6.2 Main Features 10.6.3 Functional Description 10.6.4 Power Modes 10.6.5 Interrupts 10.6.6 Register Description INSTRUCTION 11.1 ADDRESSING MODES 11.1.1 Inherent 11.1.2 Immediate 11.1.3 Direct 11.1.4 Indexed Offset, Short, Long) 11.1.5 Indirect (Short, Long) 11.1.6 Indirect Indexed (Short, Long) 11.1.7 Relative mode (Direct, Indirect) 11.2 INSTRUCTION GROUPS
ELECTRICAL CHARACTERISTICS 12.1 PARAMETER CONDITIONS 12.1.1 Minimum Maximum values 12.1.2 Typical values 12.1.3 Typical curves 12.1.4 Loading capacitor 12.1.5 input voltage 12.2 ABSOLUTE MAXIMUM RATINGS 12.2.1 Voltage Characteristics 12.2.2 Current Characteristics 12.2.3 Thermal Characteristics 12.3 OPERATING CONDITIONS
12.3.1 Operating Conditions 12.4 LVD/AVD CHARACTERISTICS 12.4.1 Voltage Detector (LVD) thresholds 12.4.2 Auxiliary Voltage Detector (AVD) Thresholds 12.5 SUPPLY CURRENT CHARACTERISTICS 12.5.1 CURRENT CONSUMPTION 12.5.2 Supply Clock Managers
4/160
Table Content12.5.3 On-Chip Peripherals 12.6 CLOCK TIMING CHARACTERISTICS 12.6.1 General Timings 12.6.2 External Clock Source 12.6.3 Crystal Ceramic Resonator Oscillators 12.6.4 Oscillators 12.6.5 Clock Security System (CSS) 12.6.6 Characteristics 12.7 MEMORY CHARACTERISTICS
12.7.1 Hardware Registers 12.7.2 FLASH Memory 12.8 CHARACTERISTICS 12.8.1 Functional 12.8.2 Electro Magnetic Interference (EMI) 12.8.3 Absolute Electrical Sensitivity 12.8.4 Protection Strategy 12.9 PORT CHARACTERISTICS
12.9.1 General Characteristics 12.9.2 Standard Voltage (StdV) Range Output Driving Current 12.10 CONTROL CHARACTERISTICS 12.10.1Asynchronous RESET 12.10.2ICCSEL/VPP 12.11 TIMER PERIPHERAL CHARACTERISTICS 12.11.116-Bit Timer 12.12 COMMUNICATION INTERFACE CHARACTERISTICS 12.12.1SPI Serial Peripheral Interface 12.13 10-BIT CHARACTERISTICS 12.13.1Analog Power Supply Reference Pins 12.13.2General Design Guidelines 12.13.3ADC Accuracy PACKAGE CHARACTERISTICS 13.1 PACKAGE MECHANICAL DATA
13.2 THERMAL CHARACTERISTICS 13.3 SOLDERING GLUEABILITY INFORMATION ST72324B DEVICE CONFIGURATION ORDERING INFORMATION 14.1 FLASH OPTION BYTES 14.2 DEVICE ORDERING INFORMATION TRANSFER CUSTOMER CODE 14.2.1 Version-Specific Sales Conditions 14.3 DEVELOPMENT TOOLS 14.3.1 Socket Emulator Adapter Information 14.4 APPLICATION NOTES KNOWN LIMITATIONS 15.1 EXTERNAL OPTION 15.2 FUNCTION 15.3 SAFE CONNECTION OSC1/OSC2 PINS 15.4 UNEXPECTED RESET FETCH
5/160
Table Content15.5 16-BIT TIMER MODE 15.6 LIMITATIONS SPECIFIC DEVICES ONLY 15.6.1 Read-Out Protection with 15.6.2 Port Configuration 15.7 LIMITATIONS DEVICES ONLY SUMMARY CHANGES
obtain most recent version this datasheet, please check www.st.com>products>technical literature>datasheet. Please also special attention Section "KNOWN LIMITATIONS" page 158.
6/160
ST72324B
INTRODUCTION
ST72324BK ST72324BJ devices enhanced versions ST72324 microcontroller family. They grouped follows: 32-pin ST72324BK devices designed mid-range applications 42/44-pin ST72324BJ devices target same range applications requiring more than ports. devices based common industrystandard 8-bit core, featuring enhanced instruc-
tion available with FLASH program memory. Under software control, devices placed WAIT, SLOW, ACTIVE-HALT HALT mode, reducing power consumption when application idle stand-by state. enhanced instruction addressing modes offer both power flexibility software developers, enabling design highly efficient compact application code. addition standard 8-bit data management, microcontrollers feature true manipulation, unsigned multiplication indirect addressing modes.
Figure Device Block Diagram
8-BIT CORE RESET CONTROL (384 2048 Bytes) PROGRAM MEMORY Bytes)
WATCHDOG OSC1 OSC2 ADDRESS DATA MCC/RTC/BEEP
PORT
PORT PF7:6,4,2:0 bits devices) bits devices) TIMER BEEP PORT PE1:0 bits)
PA7:3 bits devices) bits devices)
PORT
PB4:0 bits devices) bits devices)
PORT TIMER PORT PC7:0 bits)
PD5:0 bits devices) bits devices) VAREF VSSA
10-BIT
7/160
ST72324B
DESCRIPTION
Figure 42-Pin SDIP 44-Pin TQFP Package Pinout
(HS) AIN0 AIN1 AIN2 AIN3 AIN4
AIN5 VAREF VSSA AIN8 BEEP (HS) (HS) OCMP1_A AIN10 ICAP1_A (HS) EXTCLK_A (HS) VDD_0 VSS_0
VDD_2 OSC1 OSC2 VSS_2 RESET ICCSEL (HS) (HS) (HS) (HS)
VSS_1 VDD_1 (HS) AIN15 ICCCLK MOSI AIN14 MISO ICCDATA (HS) ICAP1_B (HS) ICAP2_B OCMP1_B AIN13 OCMP2_B AIN12
(HS) AIN0 AIN1 AIN2 AIN3 AIN4 AIN5 VAREF VSSA AIN8 BEEP (HS) (HS) AIN10 OCMP1_A ICAP1_A (HS) EXTCLK_A (HS) AIN12 OCMP2_B AIN13 OCMP1_B ICAP2_B/ (HS) ICAP1_B (HS) ICCDATA MISO AIN14 MOSI
VDD_2 OSC1 OSC2 VSS_2 RESET ICCSEL (HS) (HS) (HS) (HS) VSS_1 VDD_1 (HS) AIN15 ICCCLK (HS) 20mA high sink capability associated external interrupt vector
8/160
ST72324B
DESCRIPTION (Cont'd) Figure 32-Pin SDIP Package Pinout
(HS) AIN0 AIN1 VAREF VSSA AIN8 BEEP (HS) OCMP1_A AIN10 ICAP1_A (HS) EXTCLK_A (HS) AIN12 OCMP2_B AIN13 OCMP1_B ICAP2_B (HS) ICAP1_B (HS) ICCDATA/ MISO AIN14 MOSI
VDD_2 OSC1 OSC2 VSS_2 RESET ICCSEL (HS) (HS) (HS) (HS) AIN15 ICCCLK (HS) 20mA high sink capability associated external interrupt vector
Figure 32-Pin TQFP Package Pinout
VAREF VSSA AIN8 BEEP (HS) OCMP1_A AIN10 ICAP1_A (HS) EXTCLK_A (HS) AIN12 OCMP2_B
AIN13 OCMP1_B ICAP2_B (HS) ICAP1_B (HS) ICCDATA MISO AIN14 MOSI ICCCLK AIN15 (HS)
AIN1 AIN0 (HS) VDD_2
OSC1 OSC2 VSS_2 RESET ICCSEL (HS) (HS) (HS)
(HS) 20mA high sink capability associated external interrupt vector
9/160
ST72324B
DESCRIPTION (Cont'd) external connection guidelines, refer "ELECTRICAL CHARACTERISTICS" page 114. Legend Abbreviations Table Type: input, output, supply Input level: Dedicated analog input In/Output level: CMOS 0.3VDD/0.7VDD CMOS 0.3VDD/0.7VDD with input trigger Output level: 20mA high sink N-buffer only) Port control configuration: Input: float floating, weak pull-up, interrupt robust analog ports Output: open drain push-pull Refer "I/O PORTS" page more details software configuration ports. RESET configuration each shown bold. This configuration valid long device reset state. Table Device Description
TQFP44 TQFP32 Type SDIP42 SDIP32 Name Level Output Input Input float Port Main function Output (after reset) Port Port Port Port Port Port Port Analog Input Analog Input Analog Input Analog Input Analog Input Analog Input
Alternate Function
(HS) PD0/AIN0 PD1/AIN1 PD2/AIN2 PD3/AIN3 PD4/AIN4 PD5/AIN5
VAREF VSSA PF0/MCO/AIN8 (HS)/BEEP (HS)
Analog Reference Voltage Analog Ground Voltage Port Port Port Port Port Port Timer OutADC Analog ComInput pare Timer Input Capture Timer External Clock Source Main clock (fOSC/2) Analog Input
Beep signal output
PF4/OCMP1_A/ AIN10 (HS)/ICAP1_A
(HS)/ EXTCLK_A VDD_0 VSS_0 PC0/OCMP2_B/ AIN12
Digital Main Supply Voltage Digital Ground Voltage Port Timer OutADC Analog ComInput pare
10/160
ST72324B
TQFP44 TQFP32 Type SDIP42 SDIP32 Name
Level Output Input Input float
Port
Main function Output (after reset)
Alternate Function
PC1/OCMP1_B/ AIN13
Port Port Port Port
Timer OutADC Analog ComInput pare Timer Input Capture Timer Input Capture Master Slave Data Master Slave Data Serial Clock Slave Select (active low) Data Input Analog Input Clock Output Analog Input
(HS)/ICAP2_B (HS)/ICAP1_B PC4/MISO/ICCDATA
PC5/MOSI/AIN14
Port
PC6/SCK/ICCCLK PC7/SS/AIN15 (HS) VDD_1 VSS_1 (HS)
Port Port Port
Digital Main Supply Voltage Digital Ground Voltage Port Port Port Port Must tied low. flash programming mode, this acts programming voltage input VPP. Section 12.10.2 more details. High voltage must applied devices. priority maskable interrupt. Digital Ground Voltage Resonator oscillator inverter output External clock input Resonator oscillator inverter input Digital Main Supply Voltage Port Port Port Port Port Port Transmit Data Receive Data
(HS) (HS) (HS)
/ICCSEL
RESET VSS_2 OSC2 OSC1 VDD_2 PE0/TDO PE1/RDI
Notes: interrupt input column, "eiX" defines associated external interrupt vector. weak pull-up
11/160
ST72324B
column (wpu) merged with interrupt column (int), then configuration pull-up interrupt input, else configuration floating interrupt input. open drain output column, defines true open drain (P-Buffer protection diode implemented). "I/O PORTS" page Section 12.9 PORT CHARACTERISTICS more details. OSC1 OSC2 pins connect crystal/ceramic resonator, external source on-chip oscillator; Section INTRODUCTION Section 12.6 CLOCK TIMING CHARACTERISTICS more details. chip, each port pads. Pads that bonded external pins input pull-up configuration after reset. configuration these pads must kept reset state avoid added current consumption.
12/160
ST72324B
REGISTER MEMORY
shown Figure capable addressing bytes memories registers. available memory locations consist bytes register locations, 1024 bytes Kbytes user program memory. space includes bytes stack from 0100h 01FFh. Figure Memory highest address bytes contain user reset interrupt vectors. IMPORTANT: Memory locations marked "Reserved" must never accessed. Accessing reseved area have unpredictable effects device.
0000h 007Fh 0080h
Registers (see Table
0080h
Short Addressing (zero page)
00FFh 0100h
(1024, Bytes)
087Fh 0880h 0FFFh 1000h
Bytes Stack
01FFh 0200h
Reserved Program Memory (32K,
16-bit Addressing
027Fh 047Fh 8000h C000h E000h
KBytes KBytes Kbyte
FFDFh FFE0h FFFFh
Interrupt Reset Vectors (see Table
FFFFh
13/160
ST72324B
Table Hardware Register
Address 0000h 0001h 0002h 0003h 0004h 0005h 0006h 0007h 0008h 0009h 000Ah 000Bh 000Ch 000Dh 000Eh 000Fh 0010h 0011h 0012h 0020h 0021h 0022h 0023h 0024h 0025h 0026h 0027h 0028h 0029h 002Ah 002Bh 002Ch 002Dh 002Eh 0030h FLASH WATCHDOG SPIDR SPICR SPICSR ISPR0 ISPR1 ISPR2 ISPR3 EICR FCSR WDGCR SICSR MCCSR MCCBCR Block Register Label PADR PADDR PAOR PBDR PBDDR PBOR PCDR PCDDR PCOR PDADR PDDDR PDOR PEDR PEDDR PEOR PFDR PFDDR PFOR Register Name Port Data Register Port Data Direction Register Port Option Register Port Data Register Port Data Direction Register Port Option Register Port Data Register Port Data Direction Register Port Option Register Port Data Register Port Data Direction Register Port Option Register Port Data Register Port Data Direction Register Port Option Register Port Data Register Port Data Direction Register Port Option Register Reset Status 00h1) 00h1) 00h1) 00h1) 00h1) 00h1) Remarks R/W2) R/W2)
Port
Port
Port
Port
Port
Port
Reserved Area Bytes)
Data Register Control Register Control/Status Register Interrupt Interrupt Interrupt Interrupt Software Priority Software Priority Software Priority Software Priority Register Register Register Register
External Interrupt Control Register Flash Control/Status Register Watchdog Control Register System Integrity Control/Status Register Main Clock Control Status Register Main Clock Controller: Beep Control Register
000x 000x
Reserved Area Bytes)
14/160
ST72324B
Address 0031h 0032h 0033h 0034h 0035h 0036h 0037h 0038h 0039h 003Ah 003Bh 003Ch 003Dh 003Eh 003Fh 0040h 0041h 0042h 0043h 0044h 0045h 0046h 0047h 0048h 0049h 004Ah 004Bh 004Ch 004Dh 004Eh 004Fh 0050h 0051h 0052h 0053h 0054h 0055h 0056h 0057h 0070h 0071h 0072h 0073h 007Fh
Block
Register Label TACR2 TACR1 TACSR TAIC1HR TAIC1LR TAOC1HR TAOC1LR TACHR TACLR TAACHR TAACLR TAIC2HR TAIC2LR TAOC2HR TAOC2LR
Register Name Timer Control Register Timer Control Register Timer Control/Status Register Timer Input Capture High Register Timer Input Capture Register Timer Output Compare High Register Timer Output Compare Register Timer Counter High Register Timer Counter Register Timer Alternate Counter High Register Timer Alternate Counter Register Timer Input Capture High Register3 Timer Input Capture Register3 Timer Output Compare High Register3 Timer Output Compare Register3 Reserved Area Byte)
Reset Status xxxx x0xxb
Remarks Read Only Read Only Read Only Read Only Read Only Read Only Read Only Read Only
TIMER
TIMER
TBCR2 TBCR1 TBCSR TBIC1HR TBIC1LR TBOC1HR TBOC1LR TBCHR TBCLR TBACHR TBACLR TBIC2HR TBIC2LR TBOC2HR TBOC2LR SCISR SCIDR SCIBRR SCICR1 SCICR2 SCIERPR SCIETPR ADCCSR ADCDRH ADCDRL
Timer Control Register Timer Control Register Timer Control/Status Register Timer Input Capture High Register Timer Input Capture Register Timer Output Compare High Register Timer Output Compare Register Timer Counter High Register Timer Counter Register Timer Alternate Counter High Register Timer Alternate Counter Register Timer Input Capture High Register Timer Input Capture Register Timer Output Compare High Register Timer Output Compare Register Status Register Data Register Baud Rate Register Control Register Control Register Extended Receive Prescaler Register Reserved area Extended Transmit Prescaler Register Control/Status Register Data High Register Data Register Reserved Area Bytes)
xxxx x0xxb x000 0000h -00h
Read Only Read Only Read Only Read Only Read Only Read Only Read Only Read Only Read Only Read Only Read Only
Legend: x=undefined, R/W=read/write
15/160
ST72324B
Notes: contents port registers readable only output configuration. input configuration, values pins returned instead register contents. bits associated with unavailable pins must always keep their reset value. Timer Input Capture Output Compare pins available (not bonded). TAOC2HR TAOC2LR Registers used mode timebase generation.
16/160
ST72324B
FLASH PROGRAM MEMORY
Introduction dual voltage High Density Flash (HDFlash) non-volatile memory that electrically erased single block individual sectors programmed Byte-by-Byte basis using external supply. HDFlash devices programmed erased off-board (plugged programming tool) on-board using (In-Circuit Programming) (In-Application Programming). array matrix organisation allows each sector erased reprogrammed without affecting other sectors. Main Feature
Depending overall Flash memory size microcontroller device, there three user sectors (see Table Each these sectors erased independently avoid unnecessary erasing whole Flash memory when only partial erasing required. first sectors have fixed size Kbytes (see Figure They mapped upper part addressing space reset interrupt vectors located Sector (F000hFFFFh). Table Sectors available Flash deviceFlash Size (bytes) Available Sectors Sector Sectors Sectors 0,1,
Three Flash programming modes: Insertion programming tool. this mode, sectors including option bytes programmed erased. (In-Circuit Programming). this mode, sectors including option bytes programmed erased without removing device from application board. (In-Application Programming) this mode, sectors except Sector programmed erased without removing device from application board while application running. (In-Circuit Testing) downloading executing user application test patterns Read-out protection against piracy Register Access Security System (RASS) prevent accidental programming erasing
4.3.1 Read-out Protection Read-out protection, when selected, makes impossible extract memory content from microcontroller, thus preventing piracy. Even cannot access user code. flash devices, this protection removed reprogramming option. this case, entire program memory first automatically erased. Read-out protection selection depends device type: Flash devices enabled removed through FMP_R option byte. devices enabled mask option specified Option List.
Structure Flash memory organised sectors used both code data storage. Figure Memory Sector Addres4K
1000h 3FFFh 7FFFh 9FFFh BFFFh D7FFh DFFFh EFFFh FFFFh
FLASH MEMORY SIZE
SECTOR Kbytes Kbytes Kbytes Kbytes Kbytes Kbytes Kbytes Kbytes SECTOR SECTOR
17/160
ST72324B
FLASH PROGRAM MEMORY (Cont'd) Interface needs minimum pins connected programming tool (see Figure These pins are: RESET: device reset VSS: device power supply ground Figure Typical Interface
PROGRAMMING TOOL CONNECTOR Cable APPLICATION BOARD OPTIONAL (See Note OPTIONAL (See Note CONNECTOR HE10 CONNECTOR TYPE APPLICATION RESET SOURCE Note APPLICATION POWER SUPPLY Note APPLICATION
ICCCLK: output serial clock ICCDATA: input/output serial data ICCSEL/VPP: programming voltage OSC1(or OSCIN): main clock input external source (optional) VDD: application board power supply (optional, Figure Note
RESET
Notes: ICCCLK ICCDATA pins only used outputs application, signal isolation necessary. soon Programming Tool plugged board, even session progress, ICCCLK ICCDATA pins available application. they used inputs application, isolation such serial resistor implemented case another device forces signal. Refer Programming Tool documentation recommended resistor values. During session, programming tool must control RESET pin. This lead conflicts between programming tool application reset circuit drives more than high level (push pull output pull-up resistor<1K). schottky diode used isolate application RESET circuit this case. When using classical network with R>1K reset management with open drain output pull-up
sistor>1K, additional components needed. cases user must ensure that external reset generated application during session. connector depends Programming Tool architecture. This must connected when using most Programming Tools used monitor application power supply). Please refer Programming Tool manual. connected OSC1 OSCIN when clock available application selected clock option programmed option byte. devices with multi-oscillator capability need have OSC2 grounded this case.
18/160
ICCSEL/VPP
ICCDATA
ICCCLK
OSC2
OSC1
ST72324B
FLASH PROGRAM MEMORY (Cont'd) (In-Circuit Programming) perform microcontroller must switched (In-Circuit Communication) mode external controller programming tool. Depending code downloaded RAM, Flash memory programming fully customized (number bytes program, program locations, selection serial communication interface downloading). When using STMicroelectronics third-party programming tool that supports specific microcontroller device, user needs only implement hardware interface application board (see Figure more details locations, refer device pinout description. (In-Application Programming) This mode uses BootLoader program previously stored Sector user mode plugging device programming tool). This mode fully controlled user software. This allows adapted user application, (user-defined strategy entering programming mode, choice communications protocol used fetch data stored, etc.). example, possible download code from SPI, SCI, interface program Flash. mode used program Flash sectors except Sector which write/erase protected allow recovery case errors occur during programming operation. Related Documentation details Flash programming protocol, refer Flash Programming Reference Manual Protocol Reference Manual. 4.7.1 Register Description FLASH CONTROL/STATUS REGISTER (FCSR) Read /Write Reset Value: 0000 0000 (00h)
This register reserved Programming Tool software. controls Flash programming erasing operations.
Table Flash Control/Status Register Address Reset Value
Address (Hex.) 0029h Register Label FCSR Reset Value
19/160
ST72324B
CENTRAL PROCESSING UNIT
INTRODUCTION This full 8-bit architecture contains internal registers allowing efficient 8-bit data manipulation. MAIN FEATURES
REGISTERS registers shown Figure present memory mapping accessed specific instructions. Accumulator Accumulator 8-bit general purpose register used hold operands results arithmetic logic calculations manipulate data. Index Registers These 8-bit registers used create effective addresses temporary storage areas data manipulation. (The Cross-Assembler generates precede instruction (PRE) indicate that following instruction refers register.) register affected interrupt automatic procedures. Program Counter (PC) program counter 16-bit register containing address next instruction executed CPU. made 8-bit registers (Program Counter which LSB) (Program Counter High which MSB).
Enable executing basic instructions Fast 8-bit 8-bit multiply main addressing modes (with indirect addressing mode) 8-bit index registers 16-bit stack pointer power HALT WAIT modes Priority maskable hardware interrupts Non-maskable software/hardware interrupt
Figure Register7 RESET VALUE RESET VALUE RESET VALUE PROGRAM COUNTER RESET VALUE RESET VECTOR FFFEh-FFFFh CONDITION CODE REGISTER RESET VALUE STACK POINTER RESET VALUE STACK HIGHER ADDRESS Undefined Value INDEX REGISTER INDEX REGISTER ACCUMULATOR
20/160
ST72324B
CENTRAL PROCESSING UNIT (Cont'd) Condition Code Register (CC) Read/Write Reset Value: 111x1xxx
Zero. This cleared hardware. This indicates that result last arithmetic, logical data manipulation zero. result last operation different from zero. result last operation zero. This accessed JREQ JRNE test instructions. Carry/borrow. This cleared hardware software. indicates overflow underflow occurred during last arithmetic operation. overflow underflow occurred. overflow underflow occurred. This driven instructions tested JRNC instructions. also affected "bit test branch", shift rotate instructions. Interrupt Management Bits Interrupt combination bits gives current interrupt software priority.
Interrupt Software Priority Level (main) Level Level Level interrupt disable)
8-bit Condition Code register contains interrupt masks four flags representative result instruction just executed. This register also handled PUSH instructions. These bits individually tested and/or controlled specific instructions. Arithmetic Management Bits Half carry. This hardware when carry occurs between bits during instructions. reset hardware during same instructions. half carry occurred. half carry occurred. This tested using JRNH instruction. useful arithmetic subroutines. Negative This cleared hardware. representative result sign last arithmetic, logical data manipulation. It's copy result bit. result last operation positive null. result last operation negative (i.e. most significant logic This accessed JRMI JRPL instructions.
These bits set/cleared hardware when entering interrupt. loaded value given corresponding bits interrupt software priority registers (IxSPR). They also set/ cleared software with RIM, SIM, IRET, HALT, PUSH/POP instructions. interrupt management chapter more details.
21/160
ST72324B
CENTRAL PROCESSING UNIT (Cont'd) Stack Pointer (SP) Read/Write Reset Value:
Stack Pointer 16-bit register which always pointing next free location stack. then decremented after data been pushed onto stack incremented before data popped from stack (see Figure Since stack bytes deep, most significant bits forced hardware. Following Reset, after Reset Stack Pointer instruction (RSP), Stack Pointer contains reset value (the bits set) which stack higher address. Figure Stack Manipulation Example
CALL Subroutine 0100h Interrupt Event PUSH
least significant byte Stack Pointer (called directly accessed instruction. Note: When lower limit exceeded, Stack Pointer wraps around stack upper limit, without indicating stack overflow. previously stored information then overwritten therefore lost. stack also wraps case underflow. stack used save return address during subroutine call context during interrupt. user also directly manipulate stack means PUSH instructions. case interrupt, stored first location pointed Then other registers stored next locations shown Figure When interrupt received, decremented context pushed stack. return from interrupt, incremented context popped from stack. subroutine call occupies locations interrupt five locations stack area.
IRET
01FFh
Stack Higher Address 01FFh Stack Lower Address 0100h
22/160
ST72324B
SUPPLY, RESET CLOCK MANAGEMENT
device includes range utility features securing application critical situations (for example case power brown-out), reducing number external components. overview shown Figure more details, refer dedicated parametric section. PHASE LOCKED LOOP clock frequency input range MHz, used multiply frequency obtain fOSC2 MHz. enabled option byte. disabled, then fOSC2 fOSC/2. Caution: recommended applications where timing accuracy required. Caution: must used with internal oscillator.
Main features Optional multiplying frequency (not used with internal oscillator order respect max. operating frequency) Reset Sequence Manager (RSM) Figure Block Diagram Multi-Oscillator Clock Management (MO) Crystal/Ceramic resonator oscillators Internal oscillator fOSC System Integrity Management (SI) fOSC2 Main supply voltage detection (LVD) Auxiliary Voltage detector (AVD) with interrupt OPTION capability monitoring main supply Clock Security System (CSS) with Clock Filter Backup Safe Oscillator (enabled option byte) Figure Clock, Reset Supply Block Diagram
SYSTEM INTEGRITY MANAGEMENT CLOCK SECURITY SYSTEM (CSS) OSC2 OSC1 MULTIOSCILLATOR (MO) fOSC (option) fOSC2 CLOCK FILTER SAFE fOSC2
MAIN CLOCK fCPU CONTROLLER WITH REALTIME CLOCK (MCC/RTC)
RESET SEQUENCE RESET MANAGER (RSM)
Interrupt Request SICSR
WATCHDOG TIMER (WDG)
Interrupt Request VOLTAGE DETECTOR (LVD)
AUXILIARY VOLTAGE DETECTOR (AVD)
23/160
ST72324B
MULTI-OSCILLATOR (MO) main clock generated three different source types coming from multioscillator block: external source crystal ceramic resonator oscillators internal high frequency oscillator Each oscillator optimized given frequency range terms consumption selectable through option byte. associated hardware configurations shown Table Refer electrical characteristics section more details. Caution: OSC1 and/or OSC2 pins must left unconnected. purposes Failure Mode Effect Analysis, should noted that OSC1 and/or OSC2 pins left unconnected, main oscillator start and, this configuration, could generate fOSC clock frequency excess allowed maximum (>16MHz.), putting unsafe/undefined state. product behaviour must therefore considered undefined when pins left unconnected. External Clock Source this external clock mode, clock signal (square, sinus triangle) with ~50% duty cycle drive OSC1 while OSC2 tied ground. Crystal/Ceramic Oscillators This family oscillators advantage producing very accurate rate main clock ST7. selection within list oscillators with different frequency ranges done option byte order reduce consumption (refer Section 14.1 page more details frequency ranges). this mode multioscillator, resonator load capacitors have placed close possible oscillator pins order minimize output distortion start-up stabilization time. loading capacitance values must adjusted according selected oscillator. These oscillators stopped during RESET phase avoid losing time oscillator start-up phase. Internal Oscillator This oscillator allows cost solution main clock using only internal resistor capacitor. Internal oscillator mode drawback lower frequency accuracy should used applications that require accurate timing. this mode, oscillator pins have tied ground. order exceed max. operating frequency, internal oscillator must used with PLL. Table Clock SourceHardware Configuration
External Clock
OSC1 OSC2
EXTERNAL SOURCE
Crystal/Ceramic Resonator
OSC1 OSC2
LOAD CAPACITORS
Internal Oscillator
OSC1 OSC2
24/160
ST72324B
RESET SEQUENCE MANAGER (RSM) 6.3.1 Introduction reset sequence manager includes three RESET sources shown Figure External RESET source pulse Internal RESET (Low Voltage Detection) Internal WATCHDOG RESET These sources RESET always kept during delay phase. RESET service routine vector fixed addresses FFFEh-FFFFh memory map. basic RESET sequence consists phases shown Figure Active Phase depending RESET source 4096 clock cycle delay (selected option byte) RESET vector fetch 4096 clock cycle delay allows oscillator stabilise ensures that recovery taken place from Reset state. shorter longer clock cycle delay should selected option byte correspond stabilization time external oscillator used application. Figure Reset Block Diagram RESET vector fetch phase duration clock cycles. Figure RESET Sequence Phase
RESET
Active Phase INTERNAL RESET 4096 CLOCK CYCLES FETCH VECTOR
6.3.2 Asynchronous External RESET RESET both input open-drain output with integrated weak pull-up resistor. This pull-up fixed value varies accordance with input voltage. pulled external circuitry reset device. Electrical Characteristic section more details. RESET signal originating from external source must have duration least th(RSTL)in order recognized (see Figure 14). This detection asynchronous therefore enter reset state even HALT mode.
RESET
Filter INTERNAL RESET
PULSE GENERATOR
WATCHDOG RESET RESET
25/160
ST72324B
RESET SEQUENCE MANAGER (Cont'd) RESET asynchronous signal which plays major role performance. noisy environment, recommended follow guidelines mentioned electrical characteristics section. 6.3.3 External Power-On RESET disabled option byte, start microcontroller correctly, user must ensure means external reset circuit that reset signal held until over minimum level specified selected fOSC frequency. proper reset signal slow rising supply generally provided external network connected RESET pin. 6.3.4 Internal Voltage Detector (LVD) RESET different RESET sequences caused internal circuitry distinguished: Power-On RESET Voltage Drop RESET device RESET acts output that pulled when VDD<VIT+ (rising edge) VDD<VIT- (falling edge) shown Figure filters spikes larger than tg(VDD) avoid parasitic resets. 6.3.5 Internal Watchdog RESET RESET sequence generated internal Watchdog counter overflow shown Figure Starting from Watchdog counter underflow, device RESET acts output that pulled during least tw(RSTL)out.
Figure RESET Sequences
VIT+(LVD) VIT-(LVD)
RESET
EXTERNAL RESET
WATCHDOG RESET
ACTIVE PHASE
ACTIVE PHASE
ACTIVE PHASE
th(RSTL)in
EXTERNAL RESET SOURCE
tw(RSTL)out
RESET
WATCHDOG RESET WATCHDOG UNDERFLOW INTERNAL RESET (256 4096 TCPU) VECTOR FETCH
26/160
ST72324B
SYSTEM INTEGRITY MANAGEMENT (SI) System Integrity Management block contains Voltage Detector (LVD), Auxiliary Voltage Detector (AVD) functions Clock Security System (CSS). managed SICSR register. 6.4.1 Voltage Detector (LVD) Voltage Detector function (LVD) generates static reset when supply voltage below VIT- reference value. This means that secures power-up well power-down keeping reset. VIT- reference value voltage drop lower than VIT+ reference value power-on order avoid parasitic reset when starts running sinks current supply (hysteresis). Reset circuitry generates reset when below: VIT+ when rising VIT- when falling function illustrated Figure voltage threshold configured option byte low, medium high. Provided minimum value (guaranteed oscillator frequency) above VIT-, only modes: under full software control static safe reset these conditions, secure operation always ensured application without need external reset hardware. During Voltage Detector Reset, RESET held low, thus permitting reset other devices. Notes: allows device used without external RESET circuitry. medium thresholds selected, detection occur outside specified operating voltage range. Below 3.8V, device operation guaranteed. optional function which selected option byte.
Figure Voltage Detector Reset
Vhys VIT+ VIT-
RESET
27/160
ST72324B
SYSTEM INTEGRITY MANAGEMENT (Cont'd) 6.4.2 Auxiliary Voltage Detector (AVD) Voltage Detector function (AVD) based analog comparison between VIT-(AVD) VIT+(AVD) reference value main supply. VIT- reference value falling voltage lower than VIT+ reference value rising voltage order avoid parasitic detection (hysteresis). output comparator directly readable application software through real time status (AVDF) SICSR register. This read only. Caution: function active only enabled through option byte (see Section 14.1 page 149). 6.4.2.1 Monitoring Main Supply voltage threshold value relative selected threshold configured option byte (see interrupt enabled, interrupt generated when voltage crosses VIT+(AVD) VIT-(AVD) threshold (AVDF toggles). Figure Using Monitor Early Warning Interrupt (Power dropped, reset)
Vhyst
case drop voltage, interrupt acts early warning, allowing software shut down safely before resets microcontroller. Figure interrupt rising edge used inform application that warning state over. voltage rise time less than 4096 cycles (depending reset delay selected option byte), interrupt will generated when VIT+(AVD) reached. greater than 4096 cycles then: interrupt enabled before VIT+(AVD) threshold reached, then interrupts will received: first when AVDIE set, second when threshold reached. interrupt enabled after VIT+(AVD) threshold reached then only interrupt will occur.
VIT+(AVD) VIT-(AVD) VIT+(LVD) VIT-(LVD)
VOLTAGE RISE TIME
AVDF INTERRUPT REQUEST AVDIE
RESET VALUE
INTERRUPT PROCESS
INTERRUPT PROCESS
RESET
28/160
ST72324B
SYSTEM INTEGRITY MANAGEMENT (Cont'd) 6.4.3 Clock Security System (CSS) Clock Security System (CSS) protects against breakdowns, spikes overfrequencies occurring main clock source (fOSC). based clock filter clock detection control with internal safe oscillator (fSFOSC). Caution: function guaranteed current silicon revision. "KNOWN LIMITATIONS" page 158. 6.4.3.1 Clock Filter Control integrated glitch filtering capability making possible protect internal clock from overfrequencies created individual spikes. This feature available only when enabled. glitches occur fOSC (for example, loose connection noise), filters these automatically, internal frequency (fCPU) continues deliver glitch-free signal (see Figure 17). 6.4.3.2 Clock detection Control clock signal disappears (due broken disconnected resonator.), safe oscillator delivers frequency clock signal (fSFOSC) which allows perform some rescue operations. Automatically, clock source switches back from safe oscillator (fSFOSC) main clock source (fOSC) recovers. When internal clock (fCPU) driven safe oscillator (fSFOSC), application software notified hardware setting CSSD SICFigure Clock Filter Function
Clock Filter Function
fOSC2 fCPU
register. interrupt generated CSSIE been previously set. These bits described SICSR register description. 6.4.4 Power ModeMode WAIT Description effect interrupts cause device exit from Wait mode. CRSR register frozen. (including safe oscillator) disabled until HALT mode exited. previous configuration resumes when woken interrupt with "exit from HALT mode" capability from counter reset value when woken RESET.
HALT
6.4.4.1 Interrupts interrupt events generate interrupt corresponding Enable Control (CSSIE AVDIE) interrupt mask register reset (RIM instruction).
Interrupt Event Enable Event Control Flag CSSIE AVDIE Exit from Wait Exit from Halt
event detection (safe oscillator acti- CSSD vated main clock) event AVDF
Clock Detection Function
fOSC2 fSFOSC fCPU
29/160
ST72324B
SYSTEM INTEGRITY MANAGEMENT (Cont'd) 6.4.5 Register Description SYSTEM INTEGRITY (SI) CONTROL/STATUS REGISTER (SICSR) Read /Write Clock security system interrupt enabled When disabled OPTION BYTE, Reset Value: 000x 000x (00h) CSSIE effect.
AVDIE Voltage Detector interrupt enable This cleared software. enables interrupt generated when AVDF flag changes (toggles). pending interrupt information automatically cleared when software enters interrupt routine. interrupt disabled interrupt enabled AVDF Voltage Detector flag This read-only cleared hardware. AVDIE set, interrupt request generated when AVDF changes value. Refer Figure Section 6.4.2.1 additional details. over VIT+(AVD) threshold under VIT-(AVD) threshold LVDRF reset flag This indicates that last Reset generated block. hardware (LVD reset) cleared software (writing zero). WDGRF flag description more details. When disabled OPTION BYTE, LVDRF value undefined. Bits Reserved, must kept cleared. CSSIE Clock security syst interrupt enable This enables interrupt when disturbance detected Clock Security System (CSSD set). cleared software. Clock security system interrupt disabled
CSSD Clock security system detection This indicates that safe oscillator Clock Security System block been selected hardware disturbance main clock signal (fOSC). hardware cleared reading SICSR register when original oscillator recovers. Safe oscillator active Safe oscillator been activated When disabled OPTION BYTE, CSSD value forced WDGRF Watchdog reset flag This indicates that last Reset generated Watchdog peripheral. hardware (watchdog reset) cleared software (writing zero) Reset ensure stable cleared state WDGRF flag when starts). Combined with LVDRF flag information, flag description given following table.
RESET Sources External RESET Watchdog LVDRF WDGRF
Application notes LVDRF flag cleared when another RESET type occurs (external watchdog), LVDRF flag remains keep trace original failure. this case, watchdog reset detected software while external reset not. CAUTION: When activated with associated option byte, WDGRF flag used application.
30/160
ST72324B
INTERRUPTS
INTRODUCTION enhanced interrupt management provides following features: Hardware interrupts Software interrupt (TRAP) Nested concurrent interrupt management with flexible interrupt priority level management: software programmable nesting levels interrupt vectors fixed hardware maskable events: RESET, TRAP This interrupt management based register (I1:0), Interrupt software priority registers (ISPRx), Fixed interrupt vector addresses located high addresses memory (FFE0h FFFFh) sorted hardware priority order. This enhanced interrupt controller guarantees full upward compatibility with standard (not nested) interrupt controller. MASKING PROCESSING FLOW interrupt masking managed bits register ISPRx registers which give interrupt software priority level each interrupt vector (see Table processing flow shown Figure Figure Interrupt Processing Flowchart
RESET PENDING INTERRUPT TRAP Interrupt same lower software priority than current I1:0 Interrupt higher software priority than current
When interrupt request serviced: Normal processing suspended current instruction execution. registers saved onto stack. bits register according corresponding values ISPRx registers serviced interrupt vector. then loaded with interrupt vector interrupt service first instruction interrupt service routine fetched (refer "Interrupt Mapping" table vector addresses). interrupt service routine should with IRET instruction which causes contents saved registers recovered from stack. Note: consequence IRET instruction, bits will restored from stack program previous level will resume. Table Interrupt Software Priority LevelInterrupt software priority Level (main) Level Level Level interrupt disable) Level
High
FETCH NEXT INSTRUCTION
INTERRUPT STAYS PENDING
"IRET"
RESTORE FROM STACK
EXECUTE INSTRUCTION
STACK LOAD I1:0 FROM INTERRUPT REG. LOAD FROM INTERRUPT VECTOR
31/160
ST72324B
INTERRUPTS (Cont'd) Servicing Pending Interrupts several interrupts pending same time, interrupt taken into account determined following two-step process: highest software priority interrupt serviced, several interrupts have same software priority then interrupt with highest hardware priority serviced first. Figure describes this decision process. Figure Priority Decision ProcesPENDING INTERRUPTS
vector loaded register bits disable interrupts (level These sources allow processor exit HALT mode. TRAP (Non Maskable Software Interrupt) This software interrupt serviced when TRAP instruction executed. will serviced according flowchart Figure RESET RESET source highest priority ST7. This means that first current routine highest software priority (level highest hardware priority. RESET chapter more details. Maskable Sources Maskable interrupt vector sources serviced corresponding interrupt enabled interrupt software priority ISPRx registers) higher than currently being serviced register). these conditions false, interrupt latched thus remains pending. External Interrupts External interrupts allow processor exit from HALT power mode. External interrupt sensitivity software selectable through External Interrupt Control register (EICR). External interrupt triggered edge will latched interrupt request automatically cleared upon entering interrupt service routine. several input pins group connected same interrupt line selected simultaneously, these will logically ORed. Peripheral Interrupts Usually peripheral interrupts cause exit from HALT mode except those mentioned "Interrupt Mapping" table. peripheral interrupt occurs when specific flag peripheral status registers corresponding enable peripheral control register. general sequence clearing interrupt based access status register followed read write associated register. Note: clearing sequence resets internal latch. pending interrupt (i.e. waiting being serviced) will therefore lost clear sequence executed.
Same
SOFTWARE PRIORITY
Different
HIGHEST SOFTWARE PRIORITY SERVICED HIGHEST HARDWARE PRIORITY SERVICED
When interrupt request serviced immediately, latched then processed when software priority combined with hardware priority becomes highest one. Note hardware priority exclusive while software not. This allows previous process succeed with only interrupt. Note RESET TRAP considered having highest software priority decision process. Different Interrupt Vector Sources interrupt source types managed interrupt controller: non-maskable type (RESET,TRAP) maskable type (external from internal peripherals). Non-Maskable Sources These sources processed regardless state bits register (see Figure 18). After stacking registers (except RESET), corresponding
32/160
ST72324B
INTERRUPTS (Cont'd) INTERRUPTS POWER MODES interrupts allow processor exit WAIT power mode. contrary, only external other specified interrupts allow processor exit from HALT modes (see column "Exit from HALT" "Interrupt Mapping" table). When several pending interrupts present while exiting HALT mode, first serviced only interrupt with exit from HALT mode capability selected through same decision process shown Figure Note: interrupt, that able Exit from HALT mode, pending with highest priority when exiting HALT mode, this interrupt serviced after first serviced. Figure Concurrent Interrupt Management
TRAP SOFTWARE PRIORITY LEVEL
CONCURRENT NESTED MANAGEMENT following Figure Figure show different interrupt management modes. first called concurrent mode does allow interrupt interrupted, unlike nested mode Figure interrupt hardware priority given this order from lowest highest: MAIN, IT4, IT3, IT2, IT1, IT0. software priority given each interrupt. Warning: stack overflow occur without notifying software failure.
HARDWARE PRIORITY
TRAP MAIN MAIN
Figure Nested Interrupt Management
TRAP
SOFTWARE PRIORITY LEVEL
HARDWARE PRIORITY
TRAP MAIN MAIN
33/160
USED STACK BYTES
USED STACK BYTES
ST72324B
INTERRUPTS (Cont'd) INTERRUPT REGISTER DESCRIPTION REGISTER INTERRUPT BITS Read /Write Reset Value: 111x 1010 (xAh)
ISPR0
INTERRUPT SOFTWARE PRIORITY REGISTERS (ISPRX) Read/Write (bit ISPR3 read only) Reset Value: 1111 1111 (FFh)
I1_3 I1_7 I0_3 I0_7 I1_2 I1_6 I0_2 I0_6 I1_1 I1_5 I0_1 I0_5 I0_9 I1_0 I1_4 I1_8 I0_0 I0_4 I0_8
Software Interrupt Priority These bits indicate current interrupt software priority.
Interrupt Software Priority Level (main) Level Level Level interrupt disable*) Level
ISPR1 ISPR2 ISPR3
I1_11 I0_11 I1_10 I0_10 I1_9
I1_13 I0_13 I1_12 I0_12
High
These bits set/cleared hardware when entering interrupt. loaded value given corresponding bits interrupt software priority registers (ISPRx). They also set/cleared software with RIM, SIM, HALT, WFI, IRET PUSH/POP instructions (see "Interrupt Dedicated Instruction Set" table). *Note: TRAP RESET events interrupt level program.
These four registers contain interrupt software priority each interrupt vector. Each interrupt vector (except RESET TRAP) corresponding bits these registers where software priority stored. This correspondance shown following table.
Vector address FFFBh-FFFAh FFF9h-FFF8h FFE1h-FFE0h ISPRx bits I1_0 I0_0 bits* I1_1 I0_1 bits I1_13 I0_13
Each I1_x I0_x value ISPRx registers same meaning bits register. Level written (I1_x=1, I0_x=0). this case, previously stored value kept. (example: previous=CFh, write=64h, result=44h) RESET, TRAP vectors have software priorities. When serviced, bits register both set. Caution: I1_x I0_x bits modified while interrupt executed following behaviour considered: interrupt still pending (new interrupt flag cleared) software priority higher than previous one, interrupt re-entered. Otherwise, software priority stays unchanged next interrupt request (after IRET interrupt
34/160
ST72324B
INTERRUPTS (Cont'd)
Table Dedicated Interrupt Instruction
Instruction HALT IRET JRNM TRAP Description Entering Halt mode Interrupt routine return Jump I1:0=11 (level Jump I1:0<>11 from Stack Enable interrupt (level set) Disable interrupt (level set) Software trap Wait interrupt I1:0=11 I1:0<>11 Load I1:0 Load I1:0 Software Function/Example
Note: During execution interrupt routine, HALT, POPCC, RIM, instructions change current software priority next IRET instruction previously mentioned instructions.
35/160
ST72324B
INTERRUPTS (Cont'd) Table Interrupt Mapping
Source Block RESET TRAP MCC/RTC TIMER TIMER Reset Software interrupt used Main clock controller time base interrupt Safe oscillator activation interrupt External interrupt port A3.0 External interrupt port F2.0 External interrupt port B3.0 External interrupt port B7.4 peripheral interrupts TIMER peripheral interrupts TIMER peripheral interrupts Peripheral interrupts Auxiliary Voltage detector interrupt SPICSR TASR TBSR SCISR SICSR Lower Priority MCCSR SICSR Higher Priority Description Register Label Priority Order Exit from HALT1) Address Vector FFFEh-FFFFh FFFCh-FFFDh FFFAh-FFFBh FFF8h-FFF9h FFF6h-FFF7h FFF4h-FFF5h FFF2h-FFF3h FFF0h-FFF1h FFECh-FFEDh FFEAh-FFEBh FFE8h-FFE9h FFE6h-FFE7h FFE4h-FFE5h
Notes: Valid HALT ACTIVE-HALT modes except MCC/RTC interrupt source which exits from ACTIVE-HALT mode only. EXTERNAL INTERRUPTS 7.6.1 Port Interrupt Sensitivity external interrupt sensitivity controlled IPA, ISxx bits EICR register (Figure 22). This control allows have fully independent external interrupt source sensitivities. Each external interrupt source generated four five) different events pin: Falling edge Rising edge Falling rising edge Falling edge level Rising edge high level (only ei2) guarantee correct functionality, sensitivity bits EICR register modified only when bits register both (level This means that interrupts must disabled before changing sensitivity. pending interrupts cleared writing different value ISx[1:0], bits EICR.
36/160
ST72324B
Figure External Interrupt Control
PORT INTERRUPT PAOR.3 PADDR.3
EICR IS20 IS21 INTERRUPT SOURCE
SENSITIVITY CONTROL
PORT [2:0] INTERRUPTS PFOR.2 PFDDR.2 EICR IS20 IS21
SENSITIVITY CONTROL
INTERRUPT SOURCE
PORT [3:0] INTERRUPTS PBOR.3 PBDDR.3
EICR IS10 IS11
SENSITIVITY CONTROL
INTERRUPT SOURCE
PORT [7:4] INTERRUPTS PBOR.7 PBDDR.7
EICR IS10 IS11
SENSITIVITY CONTROL
INTERRUPT SOURCE
37/160
ST72324B
INTERRUPTS (Cont'd) EXTERNAL INTERRUPT CONTROL REGISTER (EICR) Read /Write Reset Value: 0000 0000 (00h)
IS11 IS10 IS21 IS20
IS2[1:0] sensitivity interrupt sensitivity, defined using IS2[1:0] bits, applied following external interrupts:
IS1[1:0] sensitivity interrupt sensitivity, defined using IS1[1:0] bits, applied following external interrupts: (port B3.0)
External Interrupt Sensitivity IS11 IS10 Falling edge level Rising edge only Falling edge only Rising edge high level Falling edge only Rising edge only
(port A3.0)
External Interrupt Sensitivity IS21 IS20 Falling edge level Rising edge only Falling edge only Rising edge high level Falling edge only Rising edge only
Rising falling edge
Rising falling edge
(port F2.0)
IS21 IS20 External Interrupt Sensitivity Falling edge level Rising edge only Falling edge only Rising falling edge
(port
IS11 IS10 External Interrupt Sensitivity Falling edge level Rising edge only Falling edge only Rising falling edge
These bits written only when register both (level Interrupt polarity port This used invert sensitivity port [3:0] external interrupts. cleared software only when register both (level sensitivity inversion Sensitivity inversion Bits Reserved, must always kept cleared.
These bits written only when register both (level Interrupt polarity port This used invert sensitivity port [3:0] external interrupts. cleared software only when register both (level sensitivity inversion Sensitivity inversion
38/160
ST72324B
INTERRUPTS (Cont'd) Table Nested Interrupts Register Reset ValueAddress (Hex.) 0024h Register Label ISPR0 Reset Value ISPR1 Reset Value ISPR2 Reset Value ISPR3 Reset Value EICR Reset Value I1_3 0025h I1_7 0026h I1_11 I0_11 I1_10 I0_7 I1_6 I0_10 I0_6 I1_5 I0_3 I1_2 I0_2 I1_1 I0_5 I1_4 I0_1 I0_4
TIMER I1_9 I0_9 I1_13 IS20 I0_13
TIMER I1_8 I0_8 I1_12 I0_12
0027h 0028h
IS11
IS10
IS21
39/160
ST72324B
POWER SAVING MODES
INTRODUCTION give large measure flexibility application terms power consumption, four main power saving modes implemented (see Figure 23): SLOW, WAIT (SLOW WAIT), ACTIVE HALT HALT. After RESET normal operating mode selected default (RUN mode). This mode drives device (CPU embedded peripherals) means master clock which based main oscillator frequency divided multiplied (fOSC2). From mode, different power saving modes selected setting relevant register bits calling specific software instruction whose action depends oscillator status. Figure Power Saving Mode Transitions Figure SLOW Mode Clock TransitionHigh
fOSC2/2 fOSC2/4 fOSC2
SLOW MODE This mode targets: reduce power consumption decreasing internal clock device, adapt internal clock frequency (fCPU) available supply voltage. SLOW mode controlled three bits MCCSR register: which enables disables Slow mode bits which select internal slow frequency (fCPU). this mode, master clock frequency (fOSC2) divided peripherals clocked this lower frequency (fCPU). Note: SLOW-WAIT mode activated when entering WAIT mode while device already SLOW mode.
SLOW MCCSR WAIT SLOW WAIT ACTIVE HALT HALT POWER CONSUMPTION
fCPU
fOSC2 CP1:0
SLOW FREQUENCY REQUEST
NORMAL MODE REQUEST
40/160
ST72324B
POWER SAVING MODES (Cont'd) WAIT MODE WAIT mode places power consumption mode stopping CPU. This power saving mode selected calling `WFI' instruction. peripherals remain active. During WAIT mode, I[1:0] bits register forced `10', enable interrupts. other registers memory remain unchanged. remains WAIT mode until interrupt RESET occurs, whereupon Program Counter branches starting address interrupt Reset service routine. will remain WAIT mode until Reset Interrupt occurs, causing wake Refer Figure Figure WAIT Mode Flow-chart
OSCILLATOR PERIPHERALS I[1:0] BITS
INSTRUCTION
RESET INTERRUPT OSCILLATOR PERIPHERALS I[1:0] BITS
4096 CLOCK CYCLE DELAY
OSCILLATOR PERIPHERALS I[1:0] BITS
FETCH RESET VECTOR SERVICE INTERRUPT
Note: Before servicing interrupt, register pushed stack. I[1:0] bits register current software priority level interrupt routine recovered when register popped.
41/160
ST72324B
POWER SAVING MODES (Cont'd) ACTIVE-HALT HALT MODES ACTIVE-HALT HALT modes lowest power consumption modes MCU. They both entered executing `HALT' instruction. decision enter either ACTIVE-HALT HALT mode given MCC/RTC interrupt enable flag (OIE MCCSR register).
MCCSR Power Saving Mode entered when HALT instruction executed HALT mode ACTIVE-HALT mode
pending option byte). Otherwise, enters HALT mode remaining tDELAY period. Figure ACTIVE-HALT Timing Overview
ACTIVE 4096 HALT CYCLE DELAY RESET INTERRUPT
HALT INSTRUCTION [MCCSR.OIE=1]
FETCH VECTOR
Figure ACTIVE-HALT Mode Flow-chart 8.4.1 ACTIVE-HALT MODE ACTIVE-HALT mode lowest power consumption mode with real time clock available. entered executing `HALT' instruction when Main Clock Controller Status register (MCCSR) (see Section 10.2 page more details MCCSR register). exit ACTIVE-HALT mode reception either MCC/RTC interrupt, specific interrupt (see Table "Interrupt Mapping," page RESET. When exiting ACTIVEHALT mode means interrupt, 4096 cycle delay occurs. resumes operation servicing interrupt fetching reset vector which woke (see Figure 27). When entering ACTIVE-HALT mode, I[1:0] bits register forced `10b' enable interrupts. Therefore, interrupt pending, wakes immediately. ACTIVE-HALT mode, only main oscillator associated counter (MCC/RTC) running keep wake-up time base. other peripherals clocked except those which their clock supply from another clock generator (such external auxiliary oscillator). safeguard against staying locked ACTIVEHALT mode provided oscillator interrupt. Note: soon interrupt capability oscillators selected (MCCSR.OIE set), entering ACTIVE-HALT mode while Watchdog active does generate RESET. This means that device cannot spend more than defined delay this power saving mode. CAUTION: When exiting ACTIVE-HALT mode following interrupt, MCCSR register must cleared before tDELAY after interrupt occurs (tDELAY 4096 tCPU delay deHALT INSTRUCTION (MCCSR.OIE=1) OSCILLATOR PERIPHERALS I[1:0] BITS
RESET
INTERRUPT
OSCILLATOR PERIPHERALS I[1:0] BITS
4096 CLOCK CYCLE DELAY OSCILLATOR PERIPHERALS I[1:0] BITS
FETCH RESET VECTOR SERVICE INTERRUPT
Notes: This delay occurs only exits ACTIVEHALT mode means RESET. Peripheral clocked with external clock source still active. Only MCC/RTC interrupt some specific interrupts exit from ACTIVE-HALT mode (such external interrupt). Refer Table "Interrupt Mapping," page more details. Before servicing interrupt, register pushed stack. I[1:0] bits register current software priority level interrupt routine restored when register popped.
42/160
ST72324B
POWER SAVING MODES (Cont'd) 8.4.2 HALT MODE HALT mode lowest power consumption mode MCU. entered executing `HALT' instruction when Main Clock Controller Status register (MCCSR) cleared (see Section 10.2 page more details MCCSR register). exit HALT mode reception either specific interrupt (see Table "Interrupt Mapping," page RESET. When exiting HALT mode means RESET interrupt, oscillator immediately turned 4096 cycle delay used stabilize oscillator. After start delay, resumes operation servicing interrupt fetching reset vector which woke (see Figure 29). When entering HALT mode, I[1:0] bits register forced `10b'to enable interrupts. Therefore, interrupt pending, wakes immediately. HALT mode, main oscillator turned causing internal processing stopped, including operation on-chip peripherals. peripherals clocked except ones which their clock supply from another clock generator (such external auxiliary oscillator). compatibility Watchdog operation with HALT mode configured "WDGHALT" option option byte. HALT instruction when executed while Watchdog system enabled, generate Watchdog RESET (see Section 14.1 page 149) more details. Figure HALT Timing Overview
HALT 4096 CYCLE DELAY RESET INTERRUPT FETCH VECTOR FETCH RESET VECTOR SERVICE INTERRUPT
Figure HALT Mode Flow-chart
HALT INSTRUCTION (MCCSR.OIE=0) ENABLE WDGHALT WATCHDOG RESET OSCILLATOR PERIPHERALS I[1:0] BITS WATCHDOG DISABLE
RESET INTERRUPT OSCILLATOR PERIPHERALS I[1:0] BITS
4096 CLOCK CYCLE DELAY OSCILLATOR PERIPHERALS I[1:0] BITS
HALT INSTRUCTION [MCCSR.OIE=0]
Notes: WDGHALT option bit. option byte section more details. Peripheral clocked with external clock source still active. Only some specific interrupts exit from HALT mode (such external interrupt). Refer Table "Interrupt Mapping," page more details. Before servicing interrupt, register pushed stack. I[1:0] bits register current software priority level interrupt routine recovered when register popped.
43/160
ST72324B
POWER SAVING MODES (Cont'd) 8.4.2.1 Halt Mode Recommendations Make sure that external event available wake microcontroller from Halt mode. When using external interrupt wake microcontroller, reinitialize corresponding "Input Pull-up with Interrupt" before executing HALT instruction. main reason this that wrongly configured external interference unforeseen logical condition. same reason, reinitialize level sensitiveness each external interrupt precautionary measure. opcode HALT instruction 0x8E. avoid unexpected HALT instruction program counter failure, advised clear occurrences data value 0x8E from memory. example, avoid defining constant with value 0x8E. HALT instruction clears interrupt mask register allow interrupts, user choose clear pending interrupt bits before executing HALT instruction. This avoids entering other peripheral interrupt routines after executing external interrupt routine corresponding wake-up event (reset external interrupt).
44/160
ST72324B
PORTS
INTRODUCTION ports offer different functional modes: transfer data through digital inputs outputs specific pins: external interrupt generation alternate signal input/output on-chip peripherals. port contains pins. Each programmed independently digital input (with without interrupt generation) digital output. FUNCTIONAL DESCRIPTION Each port main registers: Data Register (DR) Data Direction Register (DDR) optional register: Option Register (OR) Each programmed using corresponding register bits registers: corresponding port. same correspondence used register. following description takes into account register, (for specific ports which provide this register refer Port Implementation section). generic block diagram shown Figure 9.2.1 Input Modes input configuration selected clearing corresponding register bit. this case, reading register returns digital value applied external pin. Different input modes selected software through register. Notes: Writing register modifies latch value does affect status. When switching from input output mode, register written first drive correct level soon port configured output. read/modify/write instructions (BSET BRES) modify register External interrupt function When configured Input with Interrupt, event this generate external interrupt request CPU. Each independently generate interrupt request. interrupt sensitivity independently programmable using sensitivity bits EICR register. Each external interrupt vector linked dedicated group port pins (see pinout description interrupt section). several input pins selected simultaneously interrupt sources, these first detected according sensitivity bits EICR register then logically ORed. external interrupts hardware interrupts, which means that request latch (not accessible directly application) automatically cleared when corresponding interrupt vector fetched. clear unwanted pending interrupt software, sensitivity bits EICR register must modified. 9.2.2 Output Modes output configuration selected setting corresponding register bit. this case, writing register applies this digital value through latch. Then reading register returns previously stored value. different output modes selected software through register: Output push-pull open-drain. register value output status:
Push-pull Open-drain Floating
9.2.3 Alternate Functions When on-chip peripheral configured pin, alternate function automatically selected. This alternate function takes priority over standard programming. When signal coming from on-chip peripheral, automatically configured output mode (push-pull open drain according peripheral). When signal going on-chip peripheral, must configured input mode. this case, state also digitally readable addressing register. Note: Input pull-up configuration cause unexpected value input alternate peripheral input. When on-chip peripheral input output, this configured input floating mode.
45/160
ST72324B
PORTS (Cont'd) Figure Port General Block Diagram
REGISTER ACCESS ALTERNATE OUTPUT ALTERNATE ENABLE
P-BUFFER (see table below) PULL-UP (see table below)
PULL-UP CONDITION implemented N-BUFFER CMOS SCHMITT TRIGGER ANALOG INPUT DIODES (see table below)
EXTERNAL INTERRUPT SOURCE (eix)
Table Port Mode OptionConfiguration Mode Input Floating with/without Interrupt Pull-up with/without Interrupt Push-pull Open Drain (logic level) True Open Drain Pull-Up P-Buffer Diodes
Output
Legend: implemented implemented activated implemented activated
46/160
DATA
ALTERNATE INPUT
(see note)
Note: diode implemented true open drain pads. local protection between implemented protect device against positive stress.
ST72324B
PORTS (Cont'd) Table Port ConfigurationHardware Configuration
IMPLEMENTED TRUE OPEN DRAIN PORTS PULL-UP CONDITION REGISTER ACCESS
REGISTER
DATA
INPUT
ALTERNATE INPUT EXTERNAL INTERRUPT SOURCE (eix) INTERRUPT CONDITION ANALOG INPUT IMPLEMENTED TRUE OPEN DRAIN PORTS
OPEN-DRAIN OUTPUT
REGISTER ACCESS
REGISTER
DATA
ALTERNATE ENABLE
ALTERNATE OUTPUT
PUSH-PULL OUTPUT
IMPLEMENTED TRUE OPEN DRAIN PORTS
REGISTER ACCESS
REGISTER
DATA
ALTERNATE ENABLE
ALTERNATE OUTPUT
Notes: When port input configuration associated alternate function enabled output, reading register will read alternate function output status. When port output configuration associated alternate function enabled input, alternate function reads status given register content.
47/160
ST72324B
PORTS (Cont'd) CAUTION: alternate function must activated long configured input with interrupt, order avoid generating spurious interrupts. Analog alternate function When used input, must configured floating input. analog multiplexer (controlled registers) switches analog voltage present selected common analog rail which connected input. recommended change voltage level loading port while conversion progress. Furthermore recommended have clocking pins located close selected analog pin. WARNING: analog input voltage level must within limits stated absolute maximum ratings. PORT IMPLEMENTATION hardware implementation each port depends settings registers specific feature port such Input true open drain. Switching these ports from state another should done sequence that prevents unwanted side effects. Recommended safe transitions illustrated Figure Other transitions potentially risky should avoided, since they likely present unwanted side-effects such spurious interrupt generation.
Figure Interrupt Port State Transition01
INPUT floating/pull-up interrupt
INPUT floating (reset state)
OUTPUT open-drain
OUTPUT push-pull
DDR,
POWER MODES
Mode WAIT HALT Description effect ports. External interrupts cause device exit from WAIT mode. effect ports. External interrupts cause device exit from HALT mode.
INTERRUPTS external interrupt event generates interrupt corresponding configuration selected with registers interrupt mask register active (RIM instruction).
Interrupt Event External interrupt selected external event Enable Event Control Flag DDRx Exit from Wait Exit from Halt
48/160
ST72324B
PORTS (Cont'd) 9.5.1 Port Implementation port register configurations summarised follows. Standard Ports PA5:4, PC7:0, PD5:0, PE1:0, PF7:6,
MODE floating input pull-up input open drain output push-pull output
PA3, PB3, (without pull-up)
MODE floating input floating interrupt input open drain output push-pull output
True Open Drain Ports PA7:6
MODE floating input open drain (high sink ports)
Interrupt Ports PB4, PB2:0, PF1:0 (with pull-up)
MODE floating input pull-up interrupt input open drain output push-pull output
Table Port Configuration
Port name
PA7:6 Port PA5:4 PB4, PB2:0 PC7:0 PD5:0 PE1:0 PF7:6, PF1:0 floating floating floating floating floating floating floating floating floating floating
Input
floating pull-up floating interrupt floating interrupt pull-up interrupt pull-up pull-up pull-up pull-up floating interrupt pull-up interrupt
Output
open drain open drain open drain open drain open drain open drain open drain open drain open drain open drain
push-pull push-pull push-pull push-pull push-pull push-pull push-pull push-pull push-pull push-pull
true open-drain
Port Port Port Port Port
49/160
ST72324B
PORTS (Cont'd) Table Port Register Reset ValueAddress (Hex.) Register Label
Reset Value port registers 0000h PADR 0001h PADDR 0002h PAOR 0003h PBDR 0004h PBDDR 0005h PBOR 0006h PCDR 0007h PCDDR 0008h PCOR 0009h PDDR 000Ah PDDDR 000Bh PDOR 000Ch PEDR 000Dh PEDDR 000Eh PEOR 000Fh PFDR 0010h PFDDR 0011h PFOR
50/160
ST72324B
ON-CHIP PERIPHERALS
10.1 WATCHDOG TIMER (WDG) 10.1.1 Introduction Watchdog timer used detect occurrence software fault, usually generated external interference unforeseen logical conditions, which causes application program abandon normal sequence. Watchdog circuit generates reset expiry programmed time period, unless program refreshes counter's contents before becomes cleared. 10.1.2 Main Features Programmable free-running downcounter Programmable reset Reset watchdog activated) when reaches zero Optional reset HALT instruction (configurable option byte) Hardware Watchdog selectable option byte 10.1.3 Functional Description counter value stored Watchdog Control register (WDGCR bits T[6:0]), decremented every 16384 fOSC2 cycles (approx.), length timeout period programmed user increments. watchdog activated (the WDGA set) when 7-bit timer (bits T[6:0]) rolls over from becomes cleared), initiates reset cycle pulling reset typically 500ns. application program must write WDGCR register regular intervals during normal operation prevent reset. This downcounter free-running: counts down even watchdog disabled. value stored WDGCR register must between C0h: WDGA (watchdog enabled) prevent generating immediate reset T[5:0] bits contain number increments which represents time delay before watchdog produces reset (see Figure Approximate Timeout Duration). timing varies between minimum maximum value unknown status prescaler when writing WDGCR register (see Figure 34). Following reset, watchdog disabled. Once activated cannot disabled, except reset. used generate software reset (the WDGA cleared). watchdog activated, HALT instruction will generate Reset.
Figure Watchdog Block Diagram
RESET
fOSC2 MCC/RTC
WATCHDOG CONTROL REGISTER (WDGCR) WDGA
6-BIT DOWNCOUNTER (CNT)
12-BIT COUNTER
TB[1:0] bits (MCCSR Register)
PRESCALER
51/160
ST72324B
WATCHDOG TIMER (Cont'd) 10.1.4 Program Watchdog Timeout Figure shows linear relationship between 6-bit value loaded Watchdog Counter (CNT) resulting timeout duration milliseconds. This used quick calculation without taking timing variations into account. Figure Approximate Timeout Duration
more precision needed, formulae Figure Caution: When writing WDGCR register, always write avoid generating immediate reset.
Value (hex.)
Watchdog timeout (ms) MHz. fOSC2
52/160
ST72324B
WATCHDOG TIMER (Cont'd) Figure Exact Timeout Duration (tmin tmax) WHERE: tmin0 (LSB 128) tOSC2 tmax0 16384 tOSC2 tOSC2 125ns fOSC2=8 Value T[5:0] bits WDGCR register bits) values from table below depending timebase selected TB[1:0] bits MCCSR register
(MCCSR Reg.) (MCCSR Reg.) Selected MCCSR Timebase 10ms 25ms
calculate minimum Watchdog Timeout (tmin):
calculate maximum Watchdog Timeout (tmax):
Note: above formulae, division results must rounded down next integer value. Example: With timeout selected MCCSR register
Value T[5:0] Bits WDGCR Register (Hex.) Min. Watchdog Timeout (ms) tmin 1.496 Max. Watchdog Timeout (ms) tmax 2.048 128.552
ELSE tmax0 16384
THEN
tmax0
16384 tosc2 4CNT -MSB 4CNT -MSB osc2
ELSE tmin0 16384
THEN
tmin0
16384 osc2 -MSB 4CNT -MSB osc2
53/160
ST72324B
WATCHDOG TIMER (Cont'd) 10.1.5 Power Modes Mode SLOW WAIT Description effect Watchdog. effect Watchdog.
MCCSR register WDGHALT Option Byte Watchdog reset generated. enters Halt mode. Watchdog counter decremented once then stops counting longer able generate watchdog reset until receives external interrupt reset. external interrupt received, Watchdog restarts counting after 4096 clocks. reset generated, Watchdog disabled (reset state) unless Hardware Watchdog selected option byte. application recommendations Section 10.1.7 below. reset generated. reset generated. enters Active Halt mode. Watchdog counter decremented. stop counting. When receives oscillator interrupt external interrupt, Watchdog restarts counting immediately. When receives reset Watchdog restarts counting after 4096 clocks.
HALT
10.1.6 Hardware Watchdog Option Hardware Watchdog selected option byte, watchdog always active WDGA WDGCR used. Refer Option Byte description. 10.1.7 Using Halt Mode with (WDGHALT option) following recommendation applies Halt mode used when watchdog enabled. Before executing HALT instruction, refresh counter, avoid unexpected reset immediately after waking microcontroller. 10.1.8 Interrupts None.
10.1.9 Register Description CONTROL REGISTER (WDGCR) Read /Write Reset Value: 0111 1111 (7Fh)
WDGA
WDGA Activation bit. This software only cleared hardware after reset. When WDGA watchdog generate reset. Watchdog disabled Watchdog enabled Note: This used hardware watchdog option enabled option byte. T[6:0] 7-bit counter (MSB LSB). These bits contain value watchdog counter. decremented every 16384 fOSC2 cycles (approx.). reset produced when rolls over from becomes cleared).
54/160
ST72324B
Table Watchdog Timer Register Reset ValueAddress (Hex.) 002Ah Register Label WDGCR Reset Value WDGA
55/160
ST72324B
10.2 MAIN CLOCK CONTROLLER WITH REAL TIME CLOCK BEEPER (MCC/RTC) Main Clock Controller consists three different functions: programmable clock prescaler clock-out signal supply external devices real time clock timer with interrupt capability Each function used independently simultaneously. 10.2.1 Programmable Clock Prescaler programmable clock prescaler supplies clock internal peripherals. manages SLOW power saving mode (See Section SLOW MODE more details). prescaler selects fCPU main clock frequency controlled three bits MCCSR register: CP[1:0] SMS. 10.2.2 Clock-out Capability clock-out capability alternate function port that outputs OSC2 clock drive external devices. controlled MCCSR register. CAUTION: When selected, clock suspends clock during ACTIVE-HALT mode. 10.2.3 Real Time Clock Timer (RTC) counter real time clock timer allows interrupt generated based accurate real time clock. Four different time bases depending directly fOSC2 available. whole functionality controlled four bits MCCSR register: TB[1:0], OIF. When interrupt enabled (OIE set), enters ACTIVE-HALT mode when HALT instruction executed. Section ACTIVE-HALT HALT MODES more details. 10.2.4 Beeper beep function controlled MCCBCR register. output three selectable frequencies BEEP (I/O port alternate function).
Figure Main Clock Controller (MCC/RTC) Block Diagram
MCCBCR BEEP BEEP SIGNAL SELECTION
12-BIT COUNTER
WATCHDOG TIMER
MCCSR fOSC2
MCC/RTC INTERRUPT
fCPU
CLOCK PERIPHERALS
56/160
ST72324B
MAIN CLOCK CONTROLLER WITH REAL TIME CLOCK (Cont'd) 10.2.5 Power ModeMode WAIT Description effect MCC/RTC peripheral. MCC/RTC interrupt cause device exit from WAIT mode. effect MCC/RTC counter (OIE set), registers frozen. MCC/RTC interrupt cause device exit from ACTIVE-HALT mode. MCC/RTC counter registers frozen. MCC/RTC operation resumes when woken interrupt with "exit from HALT" capability.
CP[1:0] clock prescaler These bits select clock prescaler which applied different slow modes. Their action conditioned setting bit. These bits cleared software
fCPU SLOW mode fOSC2 fOSC2 fOSC2 fOSC2
ACTIVEHALT
HALT
10.2.6 Interrupts MCC/RTC interrupt event generates interrupt MCCSR register interrupt mask register active (RIM instruction).
Interrupt Event Time base overflow event Enable Event Control Flag Exit from Wait Exit from Halt
Slow mode select This cleared software. Normal mode. fCPU fOSC2 Slow mode. fCPU given CP1, Section SLOW MODE Section 10.2 MAIN CLOCK CONTROLLER WITH REAL TIME CLOCK BEEPER (MCC/RTC) more details. TB[1:0] Time base control These bits select programmable divider time base. They cleared software.
Time Base Counter Prescaler OSC2 =4MHz fOSC2=8MHz 16000 20ms 50ms 10ms 25ms 32000 80000 200000
Note: MCC/RTC interrupt wakes from ACTIVE-HALT mode, from HALT mode.
10.2.7 Register Description CONTROL/STATUS REGISTER (MCCSR) Read /Write Reset Value: 0000 0000 (00h
modification time base taken into account current period (previously set) avoid unwanted time shift. This allows this time base real time clock. Oscillator interrupt enable This cleared software. Oscillator interrupt disabled Oscillator interrupt enabled This interrupt used exit from ACTIVEHALT mode. When this set, calling software HALT instruction enters ACTIVE-HALT power saving mode.
Main clock selection This enables alternate function port. cleared software. alternate function disabled (I/O free general-purpose I/O) alternate function enabled (fCPU port) Note: reduce power consumption, function active ACTIVE-HALT mode.
57/160
ST72324B
MAIN CLOCK CONTROLLER WITH REAL TIME CLOCK (Cont'd) Oscillator interrupt flag This hardware cleared software reading MCCSR register. indicates when that main oscillator reached selected elapsed time (TB1:0). Timeout reached Timeout reached CAUTION: BRES BSET instructions must used MCCSR register avoid unintentionally clearing bit. BEEP CONTROL REGISTER (MCCBCR) Read /Write Reset Value: 0000 0000 (00h)
Reserved, must kept cleared. BC[1:0] Beep control These bits select beep capability.
~2-KHz ~1-KHz ~500-Hz Beep mode with fOSC2=8MHz Output Beep signal ~50% duty cycle
beep output signal available ACTIVEHALT mode disabled reduce consumption. Table Main Clock Controller Register Reset ValueAddress (Hex.) 002Bh 002Ch 002Dh Register Label SICSR Reset Value MCCSR Reset Value MCCBCR Reset Value AVDIE AVDF LVDRF CSSIE CSSD WDGRF
58/160
ST72324B
10.3 16-BIT TIMER 10.3.1 Introduction timer consists 16-bit free-running counter driven programmable prescaler. used variety purposes, including pulse length measurement input signals (input capture) generation output waveforms (output compare PWM). Pulse lengths waveform periods modulated from microseconds several milliseconds using timer prescaler clock prescaler. Some devices have on-chip 16-bit timers. They completely independent, share resources. They synchronized after reset long timer clock frequencies modified. This description covers 16-bit timers. devices with timers, register names prefixed with (Timer (Timer 10.3.2 Main Features Programmable prescaler: fCPU divided Overflow status flag maskable interrupt External clock input (must least times slower than clock speed) with choice active edge Output Compare functions each with: dedicated 16-bit registers dedicated programmable signals dedicated status flags dedicated maskable interrupt Input Capture functions each with: dedicated 16-bit registers dedicated active edge selection signals dedicated status flags dedicated maskable interrupt Pulse width modulation mode (PWM) pulse mode Reduced Power Mode alternate functions ports (ICAP1, ICAP2, OCMP1, OCMP2, EXTCLK)* Block Diagram shown Figure *Note: Some timer pins available (not bonded) some devices. Refer device description. When reading input signal non-bonded pin, value will always `1'. 10.3.3 Functional Description 10.3.3.1 Counter main block Programmable Timer 16-bit free running upcounter associated 16-bit registers. 16-bit registers made 8-bit registers called high low. Counter Register (CR): Counter High Register (CHR) most significant byte Byte). Counter Register (CLR) least significant byte Byte). Alternate Counter Register (ACR) Alternate Counter High Register (ACHR) most significant byte Byte). Alternate Counter Register (ACLR) least significant byte Byte). These read-only 16-bit registers contain same value with difference that reading ACLR register does clear (Timer overflow flag), located Status register, (SR), (see note paragraph titled 16-bit read sequence). Writing register ACLR register resets free running counter FFFCh value. Both counters have reset value FFFCh (this only value which reloaded 16-bit timer). reset value both counters also FFFCh Pulse mode mode. timer clock depends clock control bits register, illustrated Table Clock Control Bits. value counter register repeats every 131072, 262144 524288 clock cycles depending CC[1:0] bits. timer frequency fCPU/2, fCPU/4, fCPU/8 external frequency.
59/160
ST72324B
16-BIT TIMER (Cont'd) Figure Timer Block Diagram
INTERNAL fCPU MCU-PERIPHERAL INTERFACE
high
8-bit buffer
high
high
high
high
EXEDG
EXTCLK COUNTER REGISTER ALTERNATE COUNTER REGISTER OUTPUT COMPARE REGISTER OUTPUT COMPARE REGISTER INPUT CAPTURE REGISTER INPUT CAPTURE REGISTER
CC[1:0] TIMER INTERNAL OVERFLOW DETECT CIRCUIT
OUTPUT COMPARE CIRCUIT
EDGE DETECT CIRCUIT1
ICAP1
EDGE DETECT CIRCUIT2
ICAP2
LATCH1
ICF1 OCF1 ICF2 OCF2 TIMD
OCMP1 OCMP2
LATCH2
(Control/Status Register)
ICIE OCIE TOIE FOLV2 FOLV1 OLVL2 IEDG1 OLVL1
OC1E OC2E
IEDG2 EXEDG
(Control Register
(Control Register
(See note) TIMER INTERRUPT
Note: interrupt requests have separate vectors then last present (See device Interrupt Vector Table)
60/160
ST72324B
16-BIT TIMER (Cont'd) 16-bit read sequence: (from either Counter Register Alternate Counter Register).
Beginning sequence
Read Byte Other instructions Read Byte
Returns buffered
Byte buffered
Byte value
Sequence completed
user must read Byte first, then Byte value buffered automatically. This buffered value remains unchanged until 16-bit read sequence completed, even user reads Byte several times. After complete reading sequence, only register ACLR register read, they return Byte count value time read. Whatever timer mode used (input capture, output compare, pulse mode mode) overflow occurs when counter rolls over from FFFFh 0000h then: register set. timer interrupt generated TOIE register register cleared. these conditions false, interrupt remains pending issued soon they both true.
Clearing overflow interrupt request done steps: Reading register while set. access (read write) register. Notes: cleared accesses ACLR register. advantage accessing ACLR register rather than register that allows simultaneous overflow function reading free running counter random times (for example, measure elapsed time) without risk clearing erroneously. timer affected WAIT mode. HALT mode, counter stops counting until mode exited. Counting then resumes from previous count (MCU awakened interrupt) from reset count (MCU awakened Reset). 10.3.3.2 External Clock external clock (where available) selected CC0=1 CC1=1 register. status EXEDG register determines type level transition external clock EXTCLK that will trigger free running counter. counter synchronized with falling edge internal clock. minimum four falling edges clock must occur between consecutive active edges external clock; thus external clock frequency must less than quarter clock frequency.
61/160
ST72324B
16-BIT TIMER (Cont'd) Figure Counter Timing Diagram, internal clock divided
CLOCK INTERNAL RESET TIMER CLOCK COUNTER REGISTER TIMER OVERFLOW FLAG (TOF) FFFD FFFE FFFF 0000 0001 0002 0003
Figure Counter Timing Diagram, internal clock divided
CLOCK INTERNAL RESET TIMER CLOCK COUNTER REGISTER TIMER OVERFLOW FLAG (TOF) FFFC FFFD 0000 0001
Figure Counter Timing Diagram, internal clock divided
CLOCK INTERNAL RESET TIMER CLOCK COUNTER REGISTER FFFC FFFD 0000
TIMER OVERFLOW FLAG (TOF)
Note: reset state when internal reset signal high, when running.
62/160
ST72324B
16-BIT TIMER (Cont'd) 10.3.3.3 Input Capture this section, index, because there input capture functions 16-bit timer. 16-bit input capture registers (IC1R IC2R) used latch value free running counter after transition detected ICAPi (see figure
ICiR Byte ICiHR Byte ICiLR
ICiR register read-only register. active transition software programmable through IEDGi Control Registers (CRi). Timing resolution count free running counter: (fCPU/CC[1:0]). Procedure: input capture function select following register: Select timer clock (CC[1:0]) (see Table Clock Control Bits). Select edge active transition ICAP2 with IEDG2 (the ICAP2 must configured floating input input with pull-up without interrupt this configuration available). select following register: ICIE generate interrupt after input capture coming from either ICAP1 ICAP2 Select edge active transition ICAP1 with IEDG1 (the ICAP1pin must configured floating input input with pullup without interrupt this configuration available).
When input capture occurs: ICFi set. register contains value free running counter active transition ICAPi (see Figure 41). timer interrupt generated ICIE cleared register. Otherwise, interrupt remains pending until both conditions become true. Clearing Input Capture interrupt request (i.e. clearing ICFi bit) done steps: Reading register while ICFi set. access (read write) ICiLR register. Notes: After reading ICiHR register, transfer input capture data inhibited ICFi will never until ICiLR register also read. ICiR register contains free running counter value which corresponds most recent input capture. input capture functions used together even timer also uses output compare functions. pulse Mode mode only Input Capture used. alternate inputs (ICAP1 ICAP2) always directly connected timer. transitions these pins activates input capture function. Moreover ICAPi pins configured input second output, interrupt generated user toggles output ICIE set. This avoided input capture function disabled reading (see note used with interrupt generation order measure events that beyond timer range (FFFFh).
63/160
ST72324B
16-BIT TIMER (Cont'd) Figure Input Capture Block Diagram
ICAP1 ICAP2 EDGE DETECT CIRCUIT2 EDGE DETECT CIRCUIT1
ICIE
(Control Register
IEDG1
(Status Register) IC2R Register IC1R Register
ICF1 ICF2
16-BIT 16-BIT FREE RUNNING COUNTER
(Control Register
IEDG2
Figure Input Capture Timing Diagram
TIMER CLOCK COUNTER REGISTER ICAPi ICAPi FLAG ICAPi REGISTER Note: rising edge active edge. FF03 FF01 FF02 FF03
64/160
ST72324B
16-BIT TIMER (Cont'd) 10.3.3.4 Output Compare this section, index, because there output compare functions 16-bit timer. This function used control output waveform indicate when period time elapsed. When match found between Output Compare register free running counter, output compare function: Assigns pins with programmable value OCiE Sets flag status register Generates interrupt enabled 16-bit registers Output Compare Register (OC1R) Output Compare Register (OC2R) contain value compared counter register each timer clock cycle.
OCiR Byte OCiHR Byte OCiLR
OCMPi takes OLVLi value (OCMPi latch forced during reset). timer interrupt generated OCIE register cleared register (CC). OCiR register value required specific timing application calculated using following formula:
OCiR
fCPU
PRESC
Where: Output compare period seconds) clock frequency hertz) fCPU PRESC Timer prescaler factor depending CC[1:0] bits, Table Clock Control Bits) timer clock external clock, formula
These registers readable writable affected timer hardware. reset event changes OCiR value 8000h. Timing resolution count free running counter: (fCPU/CC[1:0]). Procedure: output compare function, select following register: OCiE output needed then OCMPi dedicated output compare signal. Select timer clock (CC[1:0]) (see Table Clock Control Bits). select following register: Select OLVLi applied OCMP pins after match occurs. OCIE generate interrupt needed. When match found between OCRi register register: OCFi set.
OCiR fEXT
Where: Output compare period seconds) External timer clock frequency hertz) fEXT Clearing output compare interrupt request (i.e. clearing OCFi bit) done Reading register while OCFi set. access (read write) OCiLR register. following procedure recommended prevent OCFi from being between time read write OCiR register: Write OCiHR register (further compares inhibited). Read register (first step clearance OCFi bit, which already set). Write OCiLR register (enables output compare function clears OCFi bit).
65/160
ST72324B
16-BIT TIMER (Cont'd) Notes: After processor write cycle OCiHR register, output compare function inhibited until OCiLR register also written. OCiE set, OCMPi general port OLVLi will appear when match found interrupt could generated OCIE set. When timer clock fCPU/2, OCFi OCMPi while counter value equals OCiR register value (see Figure page 67). This behaviour same mode. When timer clock fCPU/4, fCPU/8 external clock mode, OCFi OCMPi while counter value equals register value plus (see Figure page 67). output compare functions used both generating external events OCMPi pins even input capture mode also used. value 16-bit OCiR register OLVi should changed after each successful comparison order control output waveform establish elapsed timeout. Figure Output Compare Block Diagram
Forced Compare Output capability When FOLVi software, OLVLi copied OCMPi pin. OLVi toggled order toggle OCMPi when enabled (OCiE bit=1). OCFi then hardware, thus interrupt request generated. FOLVLi bits have effect both pulse mode mode.
FREE RUNNING COUNTER
OC1E OC2E
16-bit
OUTPUT COMPARE CIRCUIT
(Control Register (Control Register
OCIE FOLV2 FOLV1 OLVL2 OLVL1 Latch
OCMP1 OCMP2
16-bit
16-bit
OC1R Register
OCF1 OCF2
Latch
OC2R Register (Status Register)
66/160
ST72324B
16-BIT TIMER (Cont'd) Figure Output Compare Timing Diagram, fTIMER =fCPU/2
INTERNAL CLOCK TIMER CLOCK COUNTER REGISTER OUTPUT COMPARE REGISTER (OCRi) OUTPUT COMPARE FLAG (OCFi) OCMPi (OLVLi=1) 2ECF 2ED0 2ED1 2ED2 2ED3 2ED4 2ED3
Figure Output Compare Timing Diagram, fTIMER =fCPU/4
INTERNAL CLOCK TIMER CLOCK COUNTER REGISTER OUTPUT COMPARE REGISTER (OCRi) COMPARE REGISTER LATCH OUTPUT COMPARE FLAG (OCFi) OCMPi (OLVLi=1) 2ECF 2ED0 2ED1 2ED2 2ED3 2ED4 2ED3
67/160
ST72324B
16-BIT TIMER (Cont'd) 10.3.3.5 Pulse Mode Pulse mode enables generation pulse when external event occurs. This mode selected register. pulse mode uses Input Capture1 function Output Compare1 function. Procedure: pulse mode: Load OC1R register with value corresponding length pulse (see formula opposite column). Select following register: Using OLVL1 bit, select level applied OCMP1 after pulse. Using OLVL2 bit, select level applied OCMP1 during pulse. Select edge active transition ICAP1 with IEDG1 (the ICAP1 must configured floating input). Select following register: OC1E bit, OCMP1 then dedicated Output Compare function. bit. Select timer clock CC[1:0] (see Table Clock Control Bits).
Clearing Input Capture interrupt request (i.e. clearing ICFi bit) done steps: Reading register while ICFi set. access (read write) ICiLR register. OC1R register value required specific timing application calculated using following formula: OCiR Value
fCPU
PRESC
Where: Pulse period seconds) fCPU clock frequency hertz) PRESC Timer prescaler factor depending CC[1:0] bits, Table Clock Control Bits) timer clock external clock formula OCiR fEXT Where: Pulse period seconds) fEXT External timer clock frequency hertz) When value counter equal value contents OC1R register, OLVL1 output OCMP1 pin, (See Figure 45). Notes: OCF1 cannot hardware pulse mode OCF2 generate Output Compare interrupt. When Pulse Width Modulation (PWM) Pulse Mode (OPM) bits both set, mode only active one. OLVL1=OLVL2 continuous signal will seen OCMP1 pin. ICAP1 used perform input capture. ICAP2 used perform input capture (ICF2 IC2R loaded) user must take care that counter reset each time valid edge occurs ICAP1 ICF1 also generates interrupt ICIE set. When pulse mode used OC1R dedicated this mode. Nevertheless OC2R OCF2 used indicate period time been elapsed cannot generate output waveform because level OLVL2 dedicated pulse mode.
pulse mode cycle
When event occurs ICAP1 ICR1 Counter OCMP1 OLVL2 Counter reset FFFCh ICF1 When Counter OC1R
OCMP1 OLVL1
Then, valid event ICAP1 pin, counter initialized FFFCh OLVL2 loaded OCMP1 pin, ICF1 value FFFDh loaded IC1R register. Because ICF1 when active edge occurs, interrupt generated ICIE set.
68/160
ST72324B
16-BIT TIMER (Cont'd) Figure Pulse Mode Timing Example
IC1R COUNTER ICAP1 OCMP1 OLVL2 OLVL1 OLVL2 01F8 FFFC FFFD FFFE 01F8 2ED0 2ED1 2ED2 2ED3 2ED3 FFFC FFFD
compare1 Note: IEDG1=1, OC1R=2ED0h, OLVL1=0, OLVL2=1
Figure Pulse Width Modulation Mode Timing Example with Output Compare Function
COUNTER 34E2 FFFC FFFD FFFE OCMP1
2ED0 2ED1 2ED2
34E2
FFFC
OLVL2
OLVL1
OLVL2
compare2
compare1
compare2
Note: OC1R=2ED0h, OC2R=34E2, OLVL1=0, OLVL2=
Note: timers with only Output Compare register, fixed frequency signal generated using output compare counter overflow define pulse length.
69/160
ST72324B
16-BIT TIMER (Cont'd) 10.3.3.6 Pulse Width Modulation Mode Pulse Width Modulation (PWM) mode enables generation signal with frequency pulse length determined value OC1R OC2R registers. Pulse Width Modulation mode uses complete Output Compare function plus OC2R register, this functionality used when mode activated. mode, double buffering implemented output compare registers. values written OC1R OC2R registers taken into account only period (OC2) avoid spikes output (OCMP1). Procedure pulse width modulation mode: Load OC2R register with value corresponding period signal using formula opposite column. Load OC1R register with value corresponding period pulse (OLVL1=0 OLVL2=1) using formula opposite column. Select following register: Using OLVL1 bit, select level applied OCMP1 after successful comparison with OC1R register. Using OLVL2 bit, select level applied OCMP1 after successful comparison with OC2R register. Select following register: OC1E bit: OCMP1 then dedicated output compare function. bit. Select timer clock (CC[1:0]) (see Table Clock Control Bits).
OLVL1=1 OLVL2=0 length positive pulse difference between OC2R OC1R registers. OLVL1=OLVL2 continuous signal will seen OCMP1 pin. OCiR register value required specific timing application calculated using following formula: OCiR Value
fCPU
PRESC
Where: Signal pulse period seconds) fCPU clock frequency hertz) PRESC Timer prescaler factor depending CC[1:0] bits, Table Clock Control Bits) timer clock external clock formula OCiR fEXT Where: Signal pulse period seconds) fEXT External timer clock frequency hertz) Output Compare event causes counter initialized FFFCh (See Figure Notes: After write instruction register, output compare function inhibited until OCiLR register also written. OCF1 OCF2 bits cannot hardware mode therefore Output Compare interrupt inhibited. ICF1 hardware when counter reaches OC2R value produce timer interrupt ICIE cleared. mode ICAP1 used perform input capture because disconnected timer. ICAP2 used perform input capture (ICF2 IC2R loaded) user must take care that counter reset each period ICF1 also generates interrupt ICIE set. When Pulse Width Modulation (PWM) Pulse Mode (OPM) bits both set, mode only active one.
Pulse Width Modulation cycle
When Counter OC1R
OCMP1 OLVL1
When Counter OC2R
OCMP1 OLVL2 Counter reset FFFCh ICF1
70/160
ST72324B
16-BIT TIMER (Cont'd) 10.3.4 Power ModeMode WAIT Description effect 16-bit Timer. Timer interrupts cause device exit from WAIT mode. 16-bit Timer registers frozen. HALT mode, counter stops counting until Halt mode exited. Counting resumes from previous count when woken interrupt with "exit from HALT mode" capability from counter reset value when woken RESET. input capture event occurs ICAPi pin, input capture detection circuitry armed. Consequently, when woken interrupt with "exit from HALT mode" capability, ICFi set, counter value present when exiting from HALT mode captured into ICiR register.
HALT
10.3.5 InterruptInterrupt Event Input Capture event/Counter reset mode Input Capture event Output Compare event (not available mode) Output Compare event (not available mode) Timer Overflow event Event Flag ICF1 ICF2 OCF1 OCF2 Enable Control ICIE OCIE TOIE Exit from Wait Exit from Halt
Note: 16-bit Timer interrupt events connected same interrupt vector (see Interrupts chapter). These events generate interrupt corresponding Enable Control interrupt mask register reset (RIM instruction). 10.3.6 Summary Timer modeMODES Input Capture and/or Output Compare and/or Pulse Mode Mode Input Capture TIMER RESOURCES Input Capture Output Compare Output Compare Recommended1) Partially Recommended3)
note Section 10.3.3.5 Pulse Mode note Section 10.3.3.5 Pulse Mode note Section 10.3.3.6 Pulse Width Modulation Mode
71/160
ST72324B
16-BIT TIMER (Cont'd) 10.3.7 Register Description Each Timer associated with three control status registers, with pairs data registers (16-bit values) relating input captures, output compares, counter alternate counter. CONTROL REGISTER (CR1) Read/Write Reset Value: 0000 0000 (00h)
FOLV2 Forced Output Compare This cleared software. effect OCMP2 pin. Forces OLVL2 copied OCMP2 pin, OC2E even there successful comparison. FOLV1 Forced Output Compare This cleared software. effect OCMP1 pin. Forces OLVL1 copied OCMP1 pin, OC1E even there successful comparison. OLVL2 Output Level This copied OCMP2 whenever successful comparison occurs with OC2R register OCxE register. This value copied OCMP1 Pulse Mode Pulse Width Modulation mode. IEDG1 Input Edge This determines which type level transition ICAP1 will trigger capture. falling edge triggers capture. rising edge triggers capture. OLVL1 Output Level OLVL1 copied OCMP1 whenever successful comparison occurs with OC1R register OC1E register.
ICIE OCIE TOIE FOLV2 FOLV1 OLVL2 IEDG1 OLVL1
ICIE Input Capture Interrupt Enable. Interrupt inhibited. timer interrupt generated whenever ICF1 ICF2 register set. OCIE Output Compare Interrupt Enable. Interrupt inhibited. timer interrupt generated whenever OCF1 OCF2 register set. TOIE Timer Overflow Interrupt Enable. Interrupt inhibited. timer interrupt enabled whenever register set.
72/160
ST72324B
16-BIT TIMER (Cont'd) CONTROL REGISTER (CR2) Read/Write Reset Value: 0000 0000 (00h)
OC1E OC2E IEDG2 EXEDG
Pulse Width Modulation. mode active. mode active, OCMP1 outputs programmable cyclic signal; length pulse depends value OC1R register; period depends value OC2R register. CC[1:0] Clock Control. timer clock mode depends these bits: Table Clock Control BitTimer Clock fCPU fCPU fCPU External Clock (where available)
OC1E Output Compare Enable. This used only output signal from timer OCMP1 (OLV1 Output Compare mode, both OLV1 OLV2 one-pulse mode). Whatever value OC1E bit, Output Compare function timer remains active. OCMP1 alternate function disabled (I/O free general-purpose I/O). OCMP1 alternate function enabled. OC2E Output Compare Enable. This used only output signal from timer OCMP2 (OLV2 Output Compare mode). Whatever value OC2E bit, Output Compare function timer remains active. OCMP2 alternate function disabled (I/O free general-purpose I/O). OCMP2 alternate function enabled. Pulse Mode. Pulse Mode active. Pulse Mode active, ICAP1 used trigger pulse OCMP1 pin; active transition given IEDG1 bit. length generated pulse depends contents OC1R register.
Note: external clock available, programming external clock configuration stops counter. IEDG2 Input Edge This determines which type level transition ICAP2 will trigger capture. falling edge triggers capture. rising edge triggers capture. EXEDG External Clock Edge. This determines which type level transition external clock EXTCLK will trigger counter register. falling edge triggers counter register. rising edge triggers counter register.
73/160
ST72324B
16-BIT TIMER (Cont'd) CONTROL/STATUS REGISTER (CSR) Read Only (except R/W) Reset Value: xxxx x0xx (xxh)
ICF1 OCF1 ICF2 OCF2 TIMD
Note: Reading writing ACLR register does clear TOF. ICF2 Input Capture Flag input capture (reset value). input capture occurred ICAP2 pin. clear this bit, first read register, then read write byte IC2R (IC2LR) register. OCF2 Output Compare Flag match (reset value). content free running counter matched content OC2R register. clear this bit, first read register, then read write byte OC2R (OC2LR) register. TIMD Timer disable. This cleared software. When set, freezes timer prescaler counter disabled output functions (OCMP1 OCMP2 pins) reduce power consumption. Access timer registers still available, allowing timer configuration changed, counter reset, while disabled. Timer enabled Timer prescaler, counter outputs disabled Bits Reserved, must kept cleared.
ICF1 Input Capture Flag input capture (reset value). input capture occurred ICAP1 counter reached OC2R value mode. clear this bit, first read register, then read write byte IC1R (IC1LR) register. OCF1 Output Compare Flag match (reset value). content free running counter matched content OC1R register. clear this bit, first read register, then read write byte OC1R (OC1LR) register. Timer Overflow Flag. timer overflow (reset value). free running counter rolled over from FFFFh 0000h. clear this bit, first read register, then read write byte (CLR) register.
74/160
ST72324B
16-BIT TIMER (Cont'd) INPUT CAPTURE HIGH REGISTER (IC1HR) Read Only Reset Value: Undefined This 8-bit read only register that contains high part counter value (transferred input capture event).
OUTPUT COMPARE HIGH REGISTER (OC1HR) Read/Write Reset Value: 1000 0000 (80h) This 8-bit register that contains high part value compared register.
INPUT CAPTURE REGISTER (IC1LR) Read Only Reset Value: Undefined This 8-bit read only register that contains part counter value (transferred input capture event).
OUTPUT COMPARE REGISTER (OC1LR) Read/Write Reset Value: 0000 0000 (00h) This 8-bit register that contains part value compared register.
75/160
ST72324B
16-BIT TIMER (Cont'd) OUTPUT COMPARE HIGH REGISTER (OC2HR) Read/Write Reset Value: 1000 0000 (80h) This 8-bit register that contains high part value compared register.
ALTERNATE COUNTER HIGH REGISTER (ACHR) Read Only Reset Value: 1111 1111 (FFh) This 8-bit register that contains high part counter value.
OUTPUT COMPARE REGISTER (OC2LR) Read/Write Reset Value: 0000 0000 (00h) This 8-bit register that contains part value compared register.
ALTERNATE COUNTER REGISTER (ACLR) Read Only Reset Value: 1111 1100 (FCh) This 8-bit register that contains part counter value. write this register resets counter. access this register after access register does clear register.
COUNTER HIGH REGISTER (CHR) Read Only Reset Value: 1111 1111 (FFh) This 8-bit register that contains high part counter value.
INPUT CAPTURE HIGH REGISTER (IC2HR) Read Only Reset Value: Undefined This 8-bit read only register that contains high part counter value (transferred Input Capture event).
COUNTER REGISTER (CLR) Read Only Reset Value: 1111 1100 (FCh) This 8-bit register that contains part counter value. write this register resets counter. access this register after accessing register clears bit.
INPUT CAPTURE REGISTER (IC2LR) Read Only Reset Value: Undefined This 8-bit read only register that contains part counter value (transferred Input Capture event).
76/160
ST72324B
16-BIT TIMER (Cont'd) Table 16-Bit Timer Register Reset ValueAddress (Hex.) Timer Timer Timer Timer Timer Timer Timer Timer Timer Timer Timer Timer Timer Timer Timer Timer Timer Timer Timer Timer Timer Timer Timer Timer Timer Timer Timer Timer Timer Timer Register Label Reset Value Reset Value Reset Value IC1HR Reset Value IC1LR Reset Value OC1HR Reset Value OC1LR Reset Value OC2HR Reset Value OC2LR Reset Value Reset Value Reset Value ACHR Reset Value ACLR Reset Value IC2HR Reset Value IC2LR Reset Value ICIE OC1E ICF1 OCIE OC2E OCF1 TOIE FOLV2 ICF2 FOLV1 OCF2 OLVL2 TIMD IEDG1 IEDG2 OLVL1 EXEDG
77/160
ST72324B
10.4 SERIAL PERIPHERAL INTERFACE (SPI) 10.4.1 Introduction Serial Peripheral Interface (SPI) allows fullduplex, synchronous, serial communication with external devices. system consist master more slaves however interface master multi-master system. 10.4.2 Main Features Full duplex synchronous transfers lines) Simplex synchronous transfers lines) Master slave operation master mode frequencies (fCPU/4 max.) fCPU/2 max. slave mode frequency Management software hardware Programmable clock polarity phase transfer interrupt flag Write collision, Master Mode Fault Overrun flags 10.4.3 General Description Figure shows serial peripheral interface (SPI) block diagram. There registers: Control Register (SPICR) Control/Status Register (SPICSR) Data Register (SPIDR) connected external devices through pins: MISO: Master Slave data MOSI: Master Slave data SCK: Serial Clock masters input slaves Slave select: This input signal acts `chip select' master communicate with slaves individually avoid contention data lines. Slave inputs driven standard ports master MCU.
Figure Serial Peripheral Interface Block Diagram
Data/Address SPIDR Read Read Buffer Interrupt request
MOSI MISO
8-Bit Shift Register
SPIF WCOL MODF
SPICSR
Write
STATE CONTROL
SPIE
SPICR
SPR2 MSTR CPOL CPHA SPR1 SPR0
MASTER CONTROL SERIAL CLOCK GENERATOR
78/160
ST72324B
SERIAL PERIPHERAL INTERFACE (Cont'd) 10.4.3.1 Functional Description basic example interconnections between single master single slave illustrated Figure MOSI pins connected together MISO pins connected together. this data transferred serially between master slave (most significant first). communication always initiated master. When master device transmits data slave device MOSI pin, slave device reFigure Single Master/ Single Slave Application
sponds sending data master device MISO pin. This implies full duplex communication with both data data synchronized with same clock signal (which provided master device pin). single data line, MISO MOSI pins must connected each node this case only simplex communication possible). Four possible data/clock timing relationships chosen (see Figure master slave must programmed with same timing mode.
MASTER MSBit LSBit MISO MISO MSBit
SLAVE LSBit
8-BIT SHIFT REGISTER
8-BIT SHIFT REGISTER
MOSI
MOSI
CLOCK GENERATOR
used managed software
79/160
ST72324B
SERIAL PERIPHERAL INTERFACE (Cont'd) 10.4.3.2 Slave Select Management alternative using control Slave Select signal, application choose manage Slave Select signal software. This configured SPICSR register (see Figure software management, external free other application uses internal signal level driven writing SPICSR register. Master mode: internal must held high continuously
Slave Mode: There cases depending data/clock timing relationship (see Figure 49): CPHA=1 (data latched clock edge): internal must held during entire transmission. This implies that single slave applications either tied VSS, made free standard managing function software (SSM= SSI=0 SPICSR

Other recent searches


XN04608G - XN04608G   XN04608G Datasheet
TGM-18-2004 - TGM-18-2004   TGM-18-2004 Datasheet
PSMDA05C-4 - PSMDA05C-4   PSMDA05C-4 Datasheet
PD84006L-E - PD84006L-E   PD84006L-E Datasheet
MSP7120 - MSP7120   MSP7120 Datasheet
CFOI050 - CFOI050   CFOI050 Datasheet

 

Privacy Policy | Disclaimer
© 2012 Datasheet Archive