ST7LITE2 STMICROELECTRONICS | Alldatasheet

Document overview

  • Manufacturer or author: Provided By ALLDATASHEET.COM(FREE DATASHEET DOWNLOAD SITE)
  • PDF pages: 131

Technical content

Rev. 2.0 ST7LITE2 8-BIT MCU WITH SINGLE VOLTAGE FLASH MEMORY , DATA EEPROM, ADC, TIMERS, SPI ■ Memories – 8 Kbytes single voltage Flash Program mem- ory with read-out protection, In-Circuit Pro- gramming and In-Application programming (ICP and IAP). 10K write/erase cycles guar- anteed, data retention: 20 years at 55°C. – 384 bytes RAM – 256 bytes data EEPROM with read-out pro- tection. 300K write/erase cycles guaranteed, data retention: 20 years at 55°C. ■ Clock, Reset and Supply Management – Enhanced reset system – Enhanced low voltage supervisor (LVD) for main supply and an auxiliary voltage detector (AVD) with interrupt capability for implement- ing safe power-down procedures – Clock sources: Internal 1% RC oscillator, crystal/ceramic resonator or external clock – Internal 32-MHz input clock for Auto-reload timer – Optional x4 or x8 PLL for 4 or 8 MHz internal clock – Five Power Saving Modes: Halt, Active-Halt, Wait and Slow, Auto Wake Up From Halt ■ I/O Ports – Up to 15 multifunctional bidirectional I/O lines –7 high sink outputs ■ 4 Timers – Configurable Watchdog Timer – Two 8-bit Lite Timers with prescaler, 1 realtime base and 1 input capture – One 12-bit Auto-reload Timer with 4 PWM outputs, input capture and output compare functions ■ 1 Communication Interface – SPI synchronous serial interface ■ Interrupt Management – 10 interrupt vectors plus TRAP and RESET – 15 external interrupt lines (on 4 vectors) ■ A/D Converter – 7 input channels – Fixed gain Op-amp – 13-bit resolution for 0 to 430 mV (@ 5V VDD ) – 10-bit resolution for 430 mV to 5V (@ 5V VDD ) ■ Instruction Set – 8-bit data manipulation – 63 basic instructions – 17 main addressing modes – 8 x 8 unsigned multiply instructions ■ Development Tools – Full hardware/software development package – DM (Debug Module) Device Summary DIP20 SO20 300” Features ST7LITE20 ST7LITE25 ST7LITE29 Program memory - bytes 8K RAM (stack) - bytes 384 (128) Data EEPROM - bytes - - 256 Peripherals Lite Timer with Watchdog, Autoreload Timer, SPI, 10-bit ADC with Op-Amp Lite Timer with Watchdog, Autoreload Timer with 32-MHz input clock, SPI, 10-bit ADC with Op-Amp Operating Supply 2.4V to 5.5V CPU Frequency Up to 8Mhz (w/ ext OSC up to 16MHz) Up to 8Mhz (w/ ext OSC up to 16MHz and int 1MHz RC 1% PLLx8/4MHz) Operating Temperature -40°C to +85°C

To obtain the most recent version of this datasheet, please check at www.st.com>products>technical literature>datasheet Please also pay special attention to the Section “IMPORTANT NOTES” on page 129.

1 INTRODUCTION

Application Programming (IAP) capability. ICC Protocol Reference Manual. Figure 1. General Block Diagram

2 PIN DESCRIPTION

Figure 2. 20-Pin SO Package Pinout Figure 3. 20-Pin DIP Package Pinout

The RESET configuration of each pin is shown in bold which is valid as long as the device is in reset state. Table 1. Device Pin Description

XX Port A5 Auto-Reload Timer PWM3 or In Circuit Communication Data 14 9 PA4/ATPWM2 I/O C T HS X XX Port A4 Auto-Reload Timer PWM2 15 10 PA3/ATPWM1 I/O C T HS X ei0 XX Port A3 Auto-Reload Timer PWM1 16 11 PA2/ATPWM0 I/O C T HS X XX Port A2 Auto-Reload Timer PWM0 17 12 PA1/ATIC I/O C T HS X XX Port A1 Auto-Reload Timer Input Cap- ture 18 13 PA0/LTIC I/O C T HS X XX Port A0 Lite Timer Input Capture 19 14 OSC2 O Resonator oscillator inverter output 20 15 OSC1/CLKIN I Resonator oscillator inverter input or Exter- nal clock input Pin No. Pin Name Type Level Port / Control Main Function (after reset) Alternate Function SO20 DIP20 Input Output Input Output float wpu int ana OD PP

3 REGISTER & MEMORY MAP

dressing 64K bytes of memories and I/O registers. bytes for the stack from 180h to 1FFh. are located in Sector 0 (F000h-FFFFh). Figure 4. Memory Map

128 Bytes Stack

1 Kbyte

7 Kbytes

Table 2. Hardware Register Map

Legend : x=undefined, R/W=read/write Notes: 1. The contents of the I/O port DR registers are readable only in output configuration. In input configura- tion, the values of the I/O pins are returned instead of the DR register contents. 2. The bits associated with unavailable pins must always keep their reset value. 3. For a description of the Debug Module registers, see ICC reference manual. 0037h ITC EICR External Interrupt Control Register 00h R/W 0038h MCC MCCSR Main Clock Control/Status Register 00h R/W 0039h 003Ah Clock and Reset RCCR SICSR RC oscillator Control Register System Integrity Control/Status Register FFh 0000 0XX0h R/W R/W 003Bh Reserved area (1 byte) 003Ch ITC EISR External Interrupt Selection Register 0Ch R/W 003Dh to 0048h Reserved area (12 bytes) 0049h 004Ah AWU AWUPR AWUCSR AWU Prescaler Register AWU Control/Status Register FFh 00h R/W R/W 004Bh 004Ch 004Dh 004Eh 004Fh 0050h DM DMCR DMSR DMBK1H DMBK1L DMBK2H DMBK2L DM Control Register DM Status Register DM Breakpoint Register 1 High DM Breakpoint Register 1 Low DM Breakpoint Register 2 High DM Breakpoint Register 2 Low 00h 00h 00h 00h 00h 00h R/W R/W R/W R/W R/W R/W 0051h to 007Fh Reserved area (47 bytes) Address Block Register Label Register Name Reset Status Remarks

4 FLASH PROGRAM MEMORY

4.1 Introduction

The ST7 single voltage extended Flash (XFlash) is a non-volatile memory that can be electrically erased and programmed either on a byte-by-byte basis or up to 32 bytes in parallel. The XFlash devices can be programmed off-board (plugged in a programming tool) or on-board using In-Circuit Programming or In-Application Program- ming. The array matrix organisation allows each sector to be erased and reprogrammed without affecting other sectors.

4.2 Main Features

■ ICP (In-Circuit Programming) ■ IAP (In-Application Programming) ■ ICT (In-Circuit Testing) for downloading and executing user application test patterns in RAM ■ Sector 0 size configurable by option byte ■ Read-out and write protection against piracy

4.3 PROGRAMMING MODES

The ST7 can be programmed in three different ways: – Insertion in a programming tool. In this mode, FLASH sectors 0 and 1, option byte row and data EEPROM (if present) can be pro- grammed or erased. – In-Circuit Programming. In this mode, FLASH sectors 0 and 1, option byte row and data EEPROM (if present) can be programmed or erased without removing the device from the application board. – In-Application Programming. In this mode, sector 1 and data EEPROM (if present) can be programmed or erased without removing the device from the application board and while the application is running.

4.3.1 In-Circuit Programming (ICP)

ICP uses a protocol called ICC (In-Circuit Commu- nication) which allows an ST7 plugged on a print- ed circuit board (PCB) to communicate with an ex- ternal programming device connected via cable. ICP is performed in three steps: Switch the ST7 to ICC mode (In-Circuit Communi- cations). This is done by driving a specific signal sequence on the ICCCLK/DATA pins while the RESET pin is pulled low. When the ST7 enters ICC mode, it fetches a specific RESET vector which points to the ST7 System Memory contain- ing the ICC protocol routine. This routine enables the ST7 to receive bytes from the ICC interface. – Download ICP Driver code in RAM from the ICCDATA pin – Execute ICP Driver code in RAM to program the FLASH memory Depending on the ICP Driver code downloaded in RAM, FLASH memory programming can be fully customized (number of bytes to program, program locations, or selection of the serial communication interface for downloading).

4.3.2 In Application Programming (IAP)

This mode uses an IAP Driver program previously programmed in Sector 0 by the user (in ICP mode). This mode is fully controlled by user software. This allows it to be adapted to the user application, (us- er-defined strategy for entering programming mode, choice of communications protocol used to fetch the data to be stored etc.) IAP mode can be used to program any memory ar- eas except Sector 0, which is write/erase protect- ed to allow recovery in case errors occur during the programming operation.

4.4 ICC interface

  1. If the ICCCLK or ICCDATA pins are only used
  2. During the ICP session, the programming tool

high level (push pull output or pull-up resistor<1K). sistor>1K, no additional components are needed.

  1. The use of Pin 7 of the ICC connector depends
  2. Pin 9 has to be connected to the OSC1 pin of
  3. During reset, this pin must be held at high level

Figure 5. Typical ICC Interface

FLASH PROGRAM MEMORY (Cont’d)

4.5 Memory Protection

There are two different types of memory protec- tion: Read Out Protection and Write/Erase Protec- tion which can be applied individually.

4.5.1 Read out Protection

Read out protection, when selected, makes it im- possible to extract the memory content from the microcontroller, thus preventing piracy. Both pro- gram and data E2 memory are protected. In flash devices, this protection is removed by re- programming the option. In this case, both pro- gram and data E 2 memory are automatically erased and the device can be reprogrammed. Read-out protection selection depends on the de- vice type: – In Flash devices it is enabled and removed through the FMP_R bit in the option byte. – In ROM devices it is enabled by mask option specified in the Option List.

4.5.2 Flash Write/Erase Protection

Write/erase protection, when set, makes it impos- sible to both overwrite and erase program memo- ry. It does not apply to E2 data. Its purpose is to provide advanced security to applications and pre- vent any change being made to the memory con- tent. Warning : Once set, Write/erase protection can never be removed. A write-protected flash device is no longer reprogrammable. Write/erase protection is enabled through the FMP_W bit in the option byte.

4.6 Related Documentation

For details on Flash programming and ICC proto- col, refer to the ST7 Flash Programming Refer- ence Manual and to the ST7 ICC Protocol Refer- ence Manual

4.7 Register Description

FLASH CONTROL/STATUS REGISTER (FCSR) Read/Write Reset Value: 000 0000 (00h) 1st RASS Key: 0101 0110 (56h) 2nd RASS Key: 1010 1110 (AEh) Note: This register is reserved for programming using ICP, IAP or other programming methods. It controls the XFlash programming and erasing op- erations. When an EPB or another programming tool is used (in socket or ICP mode), the RASS keys are sent automatically.

00000 O P T L A T P G M

5 DATA EEPROM

5.1 INTRODUCTION

basic access protocol described in this chapter.

5.2 MAIN FEATURES

Figure 6. EEPROM Block Diagram

0 E2LAT00 0 0 0 E2PGM

5.3 MEMORY ACCESS

put on the data bus in less than 1 CPU clock cycle. set by software (the E2PGM bit remains cleared). Significant Bits of the address can change. LAT bits are cleared simultaneously. It is not possible to read the latched data. This note is ilustrated by the Figure 9. Figure 7. Data EEPROM Programming Flowchart

Figure 8. Data E2PROM Write Operation

5.4 POWER SAVING MODES

function in progress, and data may be corrupted.

5.5 ACCESS ERROR HANDLING

data bus will not be driven. data on the bus will not be latched.

5.6 Data EEPROM Read-out Protection

tion bit (see section 15.1 on page 123). are protected using the same option bit. Figure 9. Data EEPROM Programming Cycle

5.7 REGISTER DESCRIPTION

Bits 7:2 = Reserved, forced by hardware to 0. Table 3. DATA EEPROM Register Map and Reset Values

000000 E 2 L A T E 2 P G M

6 CENTRAL PROCESSING UNIT

6.1 INTRODUCTION

6.2 MAIN FEATURES

6.3 CPU REGISTERS

temporary storage areas for data manipulation. (Program Counter High which is the MSB). Figure 10. CPU Registers

CPU REGISTERS (Cont’d) CONDITION CODE REGISTER (CC) Read/Write Reset Value: 111x1xxx The 8-bit Condition Code register contains the in- terrupt mask and four flags representative of the result of the instruction just executed. This register can also be handled by the PUSH and POP in- structions. These bits can be individually tested and/or con- trolled by specific instructions. Bit 4 = H Half carry. This bit is set by hardware when a carry occurs be- tween bits 3 and 4 of the ALU during an ADD or ADC instruction. It is reset by hardware during the same instructions. 0: No half carry has occurred. 1: A half carry has occurred. This bit is tested using the JRH or JRNH instruc- tion. The H bit is useful in BCD arithmetic subrou- tines. Bit 3 = I Interrupt mask. This bit is set by hardware when entering in inter- rupt or by software to disable all interrupts except the TRAP software interrupt. This bit is cleared by software. 0: Interrupts are enabled. 1: Interrupts are disabled. This bit is controlled by the RIM, SIM and IRET in- structions and is tested by the JRM and JRNM in- structions. Note: Interrupts requested while I is set are latched and can be processed when I is cleared. By default an interrupt routine is not interruptable because the I bit is set by hardware at the start of the routine and reset by the IRET instruction at the end of the routine. If the I bit is cleared by software in the interrupt routine, pending interrupts are serviced regardless of the priority level of the cur- rent interrupt routine. Bit 2 = N Negative. This bit is set and cleared by hardware. It is repre- sentative of the result sign of the last arithmetic, logical or data manipulation. It is a copy of the 7th bit of the result. 0: The result of the last operation is positive or null. 1: The result of the last operation is negative (i.e. the most significant bit is a logic 1). This bit is accessed by the JRMI and JRPL instruc- tions. Bit 1 = Z Zero. This bit is set and cleared by hardware. This bit in- dicates that the result of the last arithmetic, logical or data manipulation is zero. 0: The result of the last operation is different from zero. 1: The result of the last operation is zero. This bit is accessed by the JREQ and JRNE test instructions. Bit 0 = C Carry/borrow. This bit is set and cleared by hardware and soft- ware. It indicates an overflow or an underflow has occurred during the last arithmetic operation. 0: No overflow or underflow has occurred. 1: An overflow or underflow has occurred. This bit is driven by the SCF and RCF instructions and tested by the JRC and JRNC instructions. It is also affected by the “bit test and branch”, shift and rotate instructions. 111HIN Z C

ways pointing to the next free location in the stack. popped from the stack (see Figure 11). mented and the context is pushed on the stack. and the context is popped from the stack. terrupt five locations in the stack area. Figure 11. Stack Manipulation Example

1 SP6 SP5 SP4 SP3 SP2 SP1 SP0

7 SUPPLY, RESET AND CLOCK MANAGEMENT

The device includes a range of utility features for securing the application in critical situations (for example in case of a power brown-out), and re- ducing the number of external components. Main features ■ Clock Management – 1 MHz internal RC oscillator (enabled by op- tion byte, available on ST7LITE25 and ST7LITE29 devices only) – 1 to 16 MHz or 32kHz External crystal/ceramic resonator (selected by option byte) – External Clock Input (enabled by option byte) – PLL for multiplying the frequency by 8 or 4 (enabled by option byte) – For clock ART counter only: PLL32 for multi- plying the 8 MHz frequency by 4 (enabled by option byte). The 8 MHz input frequency is mandatory and can be obtained in the follow- ing ways: –1 MHz RC + PLLx8 –16 MHz external clock (internally divided by 2) –2 MHz. external clock (internally divided by 2) + PLLx8 –Crystal oscillator with 16 MHz output fre- quency (internally divided by 2) ■ Reset Sequence Manager (RSM) ■ System Integrity Management (SI) – Main supply Low voltage detection (LVD) with reset generation (enabled by option byte) – Auxiliary Voltage detector (AVD) with interrupt capability for monitoring the main supply (en- abled by option byte)

7.1 INTERNAL RC OSCILLATOR ADJUSTMENT

The device contains an internal RC oscillator with an accuracy of 1% for a given device, temperature and voltage range (4.5V-5.5V). It must be calibrat- ed to obtain the frequency required in the applica- tion. This is done by software writing a calibration value in the RCCR (RC Control Register). Whenever the microcontroller is reset, the RCCR returns to its default value (FFh), i.e. each time the device is reset, the calibration value must be load- ed in the RCCR. Predefined calibration values are stored in EEPROM for 3 and 5V V DD supply volt- ages at 25°C, as shown in the following table. Note: – See “ELECTRICAL CHARACTERISTICS” on page 91. for more information on the frequency and accuracy of the RC oscillator. – To improve clock stability, it is recommended to place a decoupling capacitor between the VDD and VSS pins. – These two bytes are systematically programmed by ST, including on FASTROM devices. Conse- quently, customers intending to use FASTROM service must not use these two bytes. – RCCR0 and RCCR1 calibration values will be erased if the read-out protection bit is reset after it has been set. See “Read out Protection” on page 14. Caution: If the voltage or temperature conditions change in the application, the frequency may need to be recalibrated. Refer to application note AN1324 for information on how to calibrate the RC frequency using an ex- ternal reference signal.

7.2 PHASE LOCKED LOOP

The PLL can be used to multiply a 1MHz frequen- cy from the RC oscillator or the external clock by 4 or 8 to obtain f OSC of 4 or 8 MHz. The PLL is ena- bled and the multiplication factor of 4 or 8 is select- ed by 2 option bits. – The x4 PLL is intended for operation with V DD in the 2.4V to 3.3V range – The x8 PLL is intended for operation with VDD in the 3.3V to 5.5V range Refer to Section 15.1 for the option byte descrip- tion. If the PLL is disabled and the RC oscillator is ena- bled, then fOSC = 1MHz. If both the RC oscillator and the PLL are disabled, fOSC is driven by the external clock. RCCR Conditions ST7LITE29 Address ST7LITE25 Address RCCR0 VDD =5V TA=25°C fRC =1MHz 1000h and FFDEh FFDEh RCCR1 VDD =3V TA=25°C fRC =700KHz 1001h and FFDFh FFDFh

Figure 12. PLL Output Frequency Timing

13.3.4 Internal RC Oscillator and PLL)

of the LOCKED bit in the SICSR register.

7.3 REGISTER DESCRIPTION

Bits 7:2 = Reserved, must be kept cleared. and write it to this register at start-up.

000000 MCO SMS

Figure 13. Clock Management Block Diagram

7.4 MULTI-OSCILLATOR (MO)

electrical characteristics section for more details. the OSC1 pin while the OSC2 pin is tied to ground. selected by default as external clock. Table 4. ST7 Clock Sources

7.5 RESET SEQUENCE MANAGER (RSM)

7.5.1 Introduction

ways kept low during the delay phase. dresses FFFEh-FFFFh in the ST7 memory map. Figure 14. RESET Sequence Phases

7.5.2 Asynchronous External RESET pin

output with integrated RON weak pull-up resistor. Electrical Characteristic section for more details. can enter reset state even in HALT mode. Figure 15. Reset Block Diagram

7.5.3 External Power-On RESET

level specified for the selected fOSC frequency. work connected to the RESET pin.

7.5.4 Internal Low Voltage Detector (LVD)

VDD <V IT- (falling edge) as shown in Figure 16.

7.5.5 Internal Watchdog RESET

Watchdog counter overflow is shown in Figure 16. low during at least tw(RSTL)out. Figure 16. RESET Sequences

7.6 SYSTEM INTEGRITY MANAGEMENT (SI)

7.6.1 Low Voltage Detector (LVD)

The LVD function is illustrated in Figure 17. byte to be low, medium or high. Figure 17. Low Voltage Detector vs Reset

Figure 18. Reset and Supply Management Block Diagram

00 LVDRFLOCKEDWDGRF0

7.6.2 Auxiliary Voltage Detector (AVD)

asitic detection (hysteresis). abled through the option byte.

7.6.2.1 Monitoring the V

(see section 15.1 on page 123). VIT-(AVD) threshold (AVDF bit is set). Figure 19. Using the AVD to Monitor V

SYSTEM INTEGRITY MANAGEMENT (Cont’d)

7.6.3 Low Power Modes

7.6.3.1 Interrupts

The AVD interrupt event generates an interrupt if the corresponding Enable Control Bit (AVDIE) is set and the interrupt mask in the CC register is re- set (RIM instruction). Mode Description WAIT No effect on SI. AVD interrupts cause the device to exit from Wait mode. HALT The CRSR register is frozen. The AVD remains active. Interrupt Event Event Flag Enable Control Bit Exit from Wait Exit from Halt AVD event AVDF AVDIE Yes No

SYSTEM INTEGRITY MANAGEMENT (Cont’d)

7.6.4 Register Description

SYSTEM INTEGRITY (SI) CONTROL/STATUS REGISTER (SICSR) Read/Write Reset Value: 0000 0xx0 (0xh) Bit 7:5 = Reserved, must be kept cleared. Bit 4 = WDGRF Watchdog reset flag This bit indicates that the last Reset was generat- ed by the Watchdog peripheral. It is set by hard- ware (watchdog reset) and cleared by software (writing zero) or an LVD Reset (to ensure a stable cleared state of the WDGRF flag when CPU starts). Combined with the LVDRF flag information, the flag description is given by the following table. Bit 3 = LOCKED PLL Locked Flag This bit is set and cleared by hardware. It is set au- tomatically when the PLL reaches its operating fre- quency. 0: PLL not locked 1: PLL locked Bit 2 = LVDRF LVD reset flag This bit indicates that the last Reset was generat- ed by the LVD block. It is set by hardware (LVD re- set) and cleared by software (by reading). When the LVD is disabled by OPTION BYTE, the LVDRF bit value is undefined. Bit 1 = AVDF Voltage Detector flag This read-only bit is set and cleared by hardware. If the AVDIE bit is set, an interrupt request is gen- erated when the AVDF bit is set. Refer to Figure 19 and to Section 7.6.2.1 for additional details. 0: V DD over AVD threshold 1: VDD under AVD threshold Bit 0 = AVDIE Voltage Detector interrupt enable This bit is set and cleared by software. It enables an interrupt to be generated when the AVDF flag is set. The pending interrupt information is automati- cally cleared when software enters the AVD inter- rupt routine. 0: AVD interrupt disabled 1: AVD interrupt enabled Application notes The LVDRF flag is not cleared when another RE- SET type occurs (external or watchdog), the LVDRF flag remains set to keep trace of the origi- nal failure. In this case, a watchdog reset can be detected by software while an external reset can not.

000 WDG

RF LOCKED LVDRF AVDF AVDIE RESET Sources LVDRF WDGRF External RESET pin 0 0 Watchdog 0 1 LVD 1 X

8 INTERRUPTS

The ST7 core may be interrupted by one of two dif- ferent methods: maskable hardware interrupts as listed in the Interrupt Mapping Table and a non- maskable software interrupt (TRAP). The Interrupt processing flowchart is shown in Figure 20. The maskable interrupts must be enabled by clearing the I bit in order to be serviced. However, disabled interrupts may be latched and processed when they are enabled (see external interrupts subsection). Note: After reset, all interrupts are disabled. When an interrupt has to be serviced: – Normal processing is suspended at the end of the current instruction execution. – The PC, X, A and CC registers are saved onto the stack. – The I bit of the CC register is set to prevent addi- tional interrupts. – The PC is then loaded with the interrupt vector of the interrupt to service and the first instruction of the interrupt service routine is fetched (refer to the Interrupt Mapping Table for vector address- es). The interrupt service routine should finish with the IRET instruction which causes the contents of the saved registers to be recovered from the stack. Note: As a consequence of the IRET instruction, the I bit will be cleared and the main program will resume. Priority Management By default, a servicing interrupt cannot be inter- rupted because the I bit is set by hardware enter- ing in interrupt routine. In the case when several interrupts are simultane- ously pending, an hardware priority defines which one will be serviced first (see the Interrupt Map- ping Table). Interrupts and Low Power Mode All interrupts allow the processor to leave the WAIT low power mode. Only external and specifi- cally mentioned interrupts allow the processor to leave the HALT low power mode (refer to the “Exit from HALT“ column in the Interrupt Mapping Ta- ble).

8.1 NON MASKABLE SOFTWARE INTERRUPT

This interrupt is entered when the TRAP instruc- tion is executed regardless of the state of the I bit. It will be serviced according to the flowchart on Figure 20.

8.2 EXTERNAL INTERRUPTS

External interrupt vectors can be loaded into the PC register if the corresponding external interrupt occurred and if the I bit is cleared. These interrupts allow the processor to leave the Halt low power mode. The external interrupt polarity is selected through the miscellaneous register or interrupt register (if available). An external interrupt triggered on edge will be latched and the interrupt request automatically cleared upon entering the interrupt service routine. If several input pins, connected to the same inter- rupt vector, are configured as interrupts, their sig- nals are logically NANDed before entering the edge/level detection block. Caution: The type of sensitivity defined in the Mis- cellaneous or Interrupt register (if available) ap- plies to the ei source. In case of a NANDed source (as described on the I/O ports section), a low level on an I/O pin configured as input with interrupt, masks the interrupt request even in case of rising- edge sensitivity.

8.3 PERIPHERAL INTERRUPTS

Different peripheral interrupt flags in the status register are able to cause an interrupt when they are active if both: – The I bit of the CC register is cleared. – The corresponding enable bit is set in the control register. If any of these two conditions is false, the interrupt is latched and thus remains pending. Clearing an interrupt request is done by: – Writing “0” to the corresponding bit in the status register or – Access to the status register while the flag is set followed by a read or write of an associated reg- ister. Note: the clearing sequence resets the internal latch. A pending interrupt (i.e. waiting for being en- abled) will therefore be lost if the clear sequence is executed.

Figure 20. Interrupt Processing Flowchart Table 5. Interrupt Mapping Note 1: This interrupt exits the MCU from “Auto Wake-up from Halt” mode only.

0 AWU Auto Wake Up Interrupt AWUCSR yes 1) FFFAh-FFFBh

5 LITE TIMER LITE TIMER RTC2 interrupt LTCSR2 no FFF0h-FFF1h

6 Not used FFEEh-FFEFh

7 SI AVD interrupt SICSR

9 AT TIMER Overflow Interrupt ATCSR yes FFE8h-FFE9h

10 LITE TIMER LITE TIMER Input Capture Interrupt LTCSR no FFE6h-FFE7h

11 LITE TIMER RTC1 Interrupt LTCSR yes FFE4h-FFE5h

12 SPI SPI Peripheral Interrupts SPICSR yes no FFE2h-FFE3h

13 Not usedNot used FFE0h-FFE1h

(Port B0) according to Table 6. (Port B3) according to Table 6. (Port A7) according to Table 6. (Port A0) according to Table 6. bit in the CC register is set. Table 6. Interrupt Sensitivity Bits

01 P B 1

10 P B 2

01 P B 4

10 P B 5

11 P B 6

INTERRUPTS (Cont’d) Bit 3:2 = ei1[1:0] ei1 pin selection These bits are written by software. They select the Port A I/O pin used for the ei1 external interrupt ac- cording to the table below. External Interrupt I/O pin selection * Reset State Bit 1:0 = ei0[1:0] ei0 pin selection These bits are written by software. They select the Port A I/O pin used for the ei0 external interrupt ac- cording to the table below. External Interrupt I/O pin selection * Reset State Bits 1:0 = Reserved. ei11 ei10 I/O Pin 0 0 PA4 0 1 PA5 1 0 PA6

11 P A 7 *

0 0 PA0 *

01 P A 1

10 P A 2

11 P A 3

9 POWER SAVING MODES

9.1 INTRODUCTION

Figure 21. Power Saving Mode Transitions

9.2 SLOW MODE

the available supply voltage.

  1. The CPU and peripherals are clocked at this

Figure 22. SLOW Mode Clock Transition

9.3 WAIT MODE

sumption mode by stopping the CPU. the interrupt or Reset service routine. or an Interrupt occurs, causing it to wake up. Figure 23. WAIT Mode Flow-chart

  1. Before servicing an interrupt, the CC register is

256 OR 4096 CPU CLOCK

9.4 HALT MODE

cluding the operation of the on-chip peripherals. tion 15.1 on page 123 for more details). Figure 24. HALT Timing Overview Figure 25. HALT Mode Flow-chart

  1. WDGHALT is an option bit. See option byte sec-
  2. Peripheral clocked with an external clock source
  3. Only some specific interrupts can exit the MCU

fer to Table 5 Interrupt Mapping for more details.

  1. Before servicing an interrupt, the CC register is
  2. If the PLL is enabled by option byte, it outputs

POWER SAVING MODES (Cont’d)

9.4.1 Halt Mode Recommendations

– Make sure that an external event is available to wake up the microcontroller from Halt mode. – When using an external interrupt to wake up the microcontroller, reinitialize the corresponding I/O as “Input Pull-up with Interrupt” before executing the HALT instruction. The main reason for this is that the I/O may be wrongly configured due to ex- ternal interference or by an unforeseen logical condition. – For the same reason, reinitialize the level sensi- tiveness of each external interrupt as a precau- tionary measure. – The opcode for the HALT instruction is 0x8E. To avoid an unexpected HALT instruction due to a program counter failure, it is advised to clear all occurrences of the data value 0x8E from memo- ry. For example, avoid defining a constant in pro- gram memory with the value 0x8E. – As the HALT instruction clears the interrupt mask in the CC register to allow interrupts, the user may choose to clear all pending interrupt bits be- fore executing the HALT instruction. This avoids entering other peripheral interrupt routines after executing the external interrupt routine corre- sponding to the wake-up event (reset or external interrupt).

9.5 ACTIVE-HALT MODE

ACTIVE-HALT mode is the lowest power con- sumption mode of the MCU with a real time clock available. It is entered by executing the ‘HALT’ in- struction. The decision to enter either in ACTIVE- HALT or HALT mode is given by the LTCSR/ATC- SR register status as shown in the following table: The MCU can exit ACTIVE-HALT mode on recep- tion of a specific interrupt (see Table 5, “Interrupt Mapping,” on page 35) or a RESET. – When exiting ACTIVE-HALT mode by means of a RESET, a 256 or 4096 CPU cycle delay oc- curs. After the start up delay, the CPU resumes operation by fetching the reset vector which woke it up (see Figure 27). – When exiting ACTIVE-HALT mode by means of an interrupt, the CPU immediately resumes oper- ation by servicing the interrupt vector which woke it up (see Figure 27). When entering ACTIVE-HALT mode, the I bit in the CC register is cleared to enable interrupts. Therefore, if an interrupt is pending, the MCU wakes up immediately (see Note 3). In ACTIVE-HALT mode, only the main oscillator and the selected timer counter (LT/AT) are running to keep a wake-up time base. All other peripherals are not clocked except those which get their clock supply from another clock generator (such as ex- ternal or auxiliary oscillator). Note: As soon as ACTIVE-HALT is enabled, exe- cuting a HALT instruction while the Watchdog is active does not generate a RESET. This means that the device cannot spend more than a defined delay in this power saving mode. LTCSR1 TB1IE bit ATCSR OVFIE bit ATCSR CK1 bit ATCSR CK0 bit Meaning 0x x 0 ACTIVE-HALT mode disabled00 x x 1 xxx ACTIVE-HALT mode enabledx 101

Figure 26. ACTIVE-HALT Timing Overview Figure 27. ACTIVE-HALT Mode Flow-chart

  1. This delay occurs only if the MCU exits ACTIVE-

HALT mode by means of a RESET.

  1. Peripherals clocked with an external clock
  2. Only the RTC1 interrupt and some specific inter-

rupts can exit the MCU from ACTIVE-HALT mode.

  1. Before servicing an interrupt, the CC register is

9.6 AUTO WAKE UP FROM HALT MODE

curate realtime clock available. Figure 28. AWUFH Mode Block Diagram software reading the AWUCSR register.

set (see Section 9.4 HALT MODE). cluding the operation of the on-chip peripherals. lator like the AWU oscillator). Figure 29. AWUF Halt Timing Diagram

Figure 30. AWUFH Mode Flow-chart Notes:

  1. WDGHALT is an option bit. See option byte sec-
  2. Peripheral clocked with an external clock source
  3. Only an AWUFH interrupt and some specific in-

Mapping,” on page 35 for more details.

  1. Before servicing an interrupt, the CC register is
  2. If the PLL is enabled by option byte, it outputs

9.6.0.1 Register Description

viding the right value in the AWUPRE register. before waking up automatically. Table 7. AWU Register Map and Reset Values

00000 AWU

10 I/O PORTS

10.1 INTRODUCTION

The I/O ports allow data transfer. An I/O port can contain up to 8 pins. Each pin can be programmed independently either as a digital input or digital output. In addition, specific pins may have several other functions. These functions can include exter- nal interrupt, alternate signal input/output for on- chip peripherals or analog input.

10.2 FUNCTIONAL DESCRIPTION

A Data Register (DR) and a Data Direction Regis- ter (DDR) are always associated with each port. The Option Register (OR), which allows input/out- put options, may or may not be implemented. The following description takes into account the OR register. Refer to the Port Configuration table for device specific information. An I/O pin is programmed using the corresponding bits in the DDR, DR and OR registers: bit x corre- sponding to pin x of the port. Figure 31 shows the generic I/O block diagram.

10.2.1 Input Modes

Clearing the DDRx bit selects input mode. In this mode, reading its DR bit returns the digital value from that I/O pin. If an OR bit is available, different input modes can be configured by software: floating or pull-up. Re- fer to I/O Port Implementation section for configu- ration. Notes: 1. Writing to the DR modifies the latch value but does not change the state of the input pin. 2. Do not use read/modify/write instructions (BSET/BRES) to modify the DR register. External Interrupt Function Depending on the device, setting the ORx bit while in input mode can configure an I/O as an input with interrupt. In this configuration, a signal edge or lev- el input on the I/O generates an interrupt request via the corresponding interrupt vector (eix). Falling or rising edge sensitivity is programmed in- dependently for each interrupt vector. The Exter- nal Interrupt Control Register (EICR) or the Miscel- laneous Register controls this sensitivity, depend- ing on the device. A device may have up to 7 external interrupts. Several pins may be tied to one external interrupt vector. Refer to Pin Description to see which ports have external interrupts. If several I/O interrupt pins on the same interrupt vector are selected simultaneously, they are logi- cally combined. For this reason if one of the inter- rupt pins is tied low, it may mask the others. External interrupts are hardware interrupts. Fetch- ing the corresponding interrupt vector automatical- ly clears the request latch. Modifying the sensitivity bits will clear any pending interrupts.

10.2.2 Output Modes

Setting the DDRx bit selects output mode. Writing to the DR bits applies a digital value to the I/O through the latch. Reading the DR bits returns the previously stored value. If an OR bit is available, different output modes can be selected by software: push-pull or open- drain. Refer to I/O Port Implementation section for configuration. DR Value and Output Pin Status

10.2.3 Alternate Functions

Many ST7s I/Os have one or more alternate func- tions. These may include output signals from, or input signals to, on-chip peripherals. The Device Pin Description table describes which peripheral signals can be input/output to which ports. A signal coming from an on-chip peripheral can be output on an I/O. To do this, enable the on-chip peripheral as an output (enable bit in the peripher- al’s control register). The peripheral configures the I/O as an output and takes priority over standard I/ O programming. The I/O’s state is readable by ad- dressing the corresponding I/O data register. Configuring an I/O as floating enables alternate function input. It is not recommended to configure an I/O as pull-up as this will increase current con- sumption. Before using an I/O as an alternate in- put, configure it without interrupt. Otherwise spuri- ous interrupts can occur. Configure an I/O as input floating for an on-chip peripheral signal which can be input and output. Caution: I/Os which can be configured as both an analog and digital alternate function need special atten- tion. The user must control the peripherals so that the signals do not arrive at the same time on the same pin. If an external clock is used, only the clock alternate function should be employed on that I/O pin and not the other alternate function. DR Push-Pull Open-Drain 0V OL VOL 1V OH Floating

Figure 31. I/O Port General Block Diagram Table 8. I/O Port Mode Options vice against positive stress. table for device specific information.

Table 9. I/O Configurations

  1. When the I/O port is in input configuration and the associated alternate function is enabled as an output,

reading the DR register will read the alternate function output status.

  1. When the I/O port is in output configuration and the associated alternate function is enabled as an input,

the alternate function reads the pin status given by the DR register content.

  1. For true open drain, these elements are not implemented.

rail, connected to the ADC input.

10.3 I/O PORT IMPLEMENTATION

spurious interrupt generation. Figure 32. Interrupt I/O Port State Transitions

10.4 UNUSED I/O PINS

age levels. Refer to Section 13.8.

10.5 LOW POWER MODES

10.6 INTERRUPTS

register is cleared (RIM instruction). cause the device to exit from WAIT mode. cause the device to exit from HALT mode.

10.7 DEVICE-SPECIFIC I/O PORT CONFIGURATION

Table 10. Port Configuration (Standard ports) Table 11. I/O Port Register Map and Reset Values

11 ON-CHIP PERIPHERALS

11.1 WATCHDOG TIMER (WDG)

11.1.1 Introduction

11.1.2 Main Features

11.1.3 Functional Description

programmed by the user in 64 increments. Figure 33. Watchdog Block Diagram

WATCHDOG TIMER (Cont’d) The application program must write in the CR reg- ister at regular intervals during normal operation to prevent an MCU reset. This downcounter is free- running: it counts down even if the watchdog is disabled. The value to be stored in the CR register must be between FFh and C0h (see Table 12 .Watchdog Timing): – The WDGA bit is set (watchdog enabled) – The T6 bit is set to prevent generating an imme- diate reset – The T[5:0] bits contain the number of increments which represents the time delay before the watchdog produces a reset. Following a reset, the watchdog is disabled. Once activated it cannot be disabled, except by a reset. The T6 bit can be used to generate a software re- set (the WDGA bit is set and the T6 bit is cleared). If the watchdog is activated, the HALT instruction will generate a Reset. Table 12.Watchdog Timing Notes: 1. The timing variation shown in Table 12 is due to the unknown status of the prescaler when writing to the CR register. 2. The number of CPU clock cycles applied during the RESET phase (256 or 4096) must be taken into account in addition to these timings.

11.1.4 Hardware Watchdog Option

If Hardware Watchdog is selected by option byte, the watchdog is always active and the WDGA bit in the CR is not used. Refer to the Option Byte description in section 15 on page 123.

11.1.4.1 Using Halt Mode with the WDG

(WDGHALT option) If Halt mode with Watchdog is enabled by option byte (No watchdog reset on HALT instruction), it is recommended before executing the HALT instruc- tion to refresh the WDG counter, to avoid an unex- pected WDG reset immediately after waking up the microcontroller. Same behavior in active-halt mode. fCPU = 8MHz WDG Counter Code min [ms] max [ms] C0h 1 2 FFh 127 128

WATCHDOG TIMER (Cont’d)

11.1.5 Interrupts

None.

11.1.6 Register Description

CONTROL REGISTER (CR) Read/Write Reset Value: 0111 1111 (7Fh) Bit 7 = WDGA Activation bit. This bit is set by software and only cleared by hardware after a reset. When WDGA = 1, the watchdog can generate a reset. 0: Watchdog disabled 1: Watchdog enabled Note: This bit is not used if the hardware watch- dog option is enabled by option byte. Bit 6:0 = T[6:0] 7-bit timer (MSB to LSB). These bits contain the decremented value. A reset is produced when it rolls over from 40h to 3Fh (T6 becomes cleared). WDGA T6 T5 T4 T3 T2 T1 T0

Table 13. Watchdog Timer Register Map and Reset Values

11.2.1 Introduction

11.2.2 Main Features

Figure 34. Block Diagram

32 MHz

4 PWM Channels

11.2.3 Functional Description

mum value is 1 KHz (ATR register value = 0). At reset, the counter starts counting from 0. be greater than the contents of the ATR register. Figure 35. PWM Inversion Diagram Figure 36. PWM Function

Figure 37. PWM Signal from 0% to 100% Duty Cycle This mode is always available. ble for DCRx values other than 0 (reset value). cy shutdown of the power converter. function without using the BREAK pin. – The 12-bit PWM counter is set to its reset value. registers are set to their reset values. – The PWMCR register is reset.

Figure 38. Block Diagram of Break Function

11.2.3.1 Input Capture

ing or falling edge is detected on the ATIC pin. Figure 39. Input Capture Timing Diagram The BREAK pin value is latched by the BA bit.

12-BIT AUTORELOAD TIMER (Cont’d)

11.2.4 Low Power Modes

11.2.5 Interrupts

Note 1: The CMP and IC events are connected to the same interrupt vector. The OVF event is mapped on a separate vector (see Interrupts chapter). They generate an interrupt if the enable bit is set in the ATCSR register and the interrupt mask in the CC register is reset (RIM instruction). Note 2: Only if CK0=1 and CK1=0 Mode Description SLOW The input frequency is divided by 32 WAIT No effect on AT timer ACTIVE-HALT AT timer halted except if CK0=1, CK1=0 and OVFIE=1 HALT AT timer halted Interrupt Event1) Event Flag Enable Control Bit Exit from Wait Exit from Halt Exit from Active- Halt Overflow Event OVF OVIE Yes No Yes 2) IC Event ICF ICIE Yes No No CMP Event CMPF0 CMPIE Yes No No

12-BIT AUTORELOAD TIMER (Cont’d)

11.2.6 Register Description

TIMER CONTROL STATUS REGISTER (ATCSR) Read / Write Reset Value: 0x00 0000 (x0h) Bit 7 = Reserved. Bit 6 = ICF Input Capture Flag. This bit is set by hardware and cleared by software by reading the ATICR register (a read access to ATICRH or ATICRL will clear this flag). Writing to this bit does not change the bit value. 0: No input capture 1: An input capture has occurred Bit 5 = ICIE IC Interrupt Enable. This bit is set and cleared by software. 0: Input capture interrupt disabled 1: Input capture interrupt enabled Bits 4:3 = CK[1:0] Counter Clock Selection. These bits are set and cleared by software and cleared by hardware after a reset. They select the clock frequency of the counter. The change be- comes effective after an overflow. Note 1: PWM mode is not available at this fre- quency. Note 2: ATICR counter may return inaccurate re- sults when read. It is therefore not recommended to use Input Capture mode at this frequency. Bit 2 = OVF Overflow Flag. This bit is set by hardware and cleared by software by reading the TCSR register. It indicates the tran- sition of the counter from FFh to ATR value. 0: No counter overflow occurred 1: Counter overflow occurred Bit 1 = OVFIE Overflow Interrupt Enable. This bit is read/write by software and cleared by hardware after a reset. 0: OVF interrupt disabled. 1: OVF interrupt enabled. Bit 0 = CMPIE Compare Interrupt Enable. This bit is read/write by software and cleared by hardware after a reset. It can be used to mask the interrupt generated when the CMPF bit is set. 0: CMPF interrupt disabled. 1: CMPF interrupt enabled. COUNTER REGISTER HIGH (CNTRH) Read only Reset Value: 0000 0000 (000h) COUNTER REGISTER LOW (CNTRL) Read only Reset Value: 0000 0000 (000h) Bits 15:12 = Reserved. Bits 11:0 = CNTR[11:0] Counter Value. This 12-bit register is read by software and cleared by hardware after a reset. The counter is incre- mented continuously as soon as a counter clok is selected. To obtain the 12-bit value, software should read the counter value in two consecutive read operations, LSB first. When a counter over- flow occurs, the counter restarts from the value specified in the ATR register. 76 0

0 ICF ICIE CK1 CK0 OVF OVFIE CMPIE

Counter Clock Selection CK1 CK0 OFF 0 0 fLTIMER (1 ms timebase @ 8 MHz) 1) 01 fCPU 10

32 MHz 2) 11

0000 CNTR

10 CNTR9 CNTR8

CNTR7 CNTR6 CNTR5 CNTR4 CNTR3 CNTR2 CNTR1 CNTR0

12-BIT AUTORELOAD TIMER (Cont’d) AUTORELOAD REGISTER (ATRH) Read / Write Reset Value: 0000 0000 (00h) AUTORELOAD REGISTER (ATRL) Read / Write Reset Value: 0000 0000 (00h) Bits 11:0 = ATR[11:0] Autoreload Register. This is a 12-bit register which is written by soft- ware. The ATR register value is automatically loaded into the upcounter when an overflow oc- curs. The register value is used to set the PWM frequency. PWM OUTPUT CONTROL REGISTER (PWMCR) Read/Write Reset Value: 0000 0000 (00h) Bits 7:0 = OE[3:0] PWMx output enable. These bits are set and cleared by software and cleared by hardware after a reset. 0: PWM mode disabled. PWMx Output Alternate Function disabled (I/O pin free for general pur- pose I/O) 1: PWM mode enabled PWMx CONTROL STATUS REGISTER (PWMxCSR) Read / Write Reset Value: 0000 0000 (00h) Bits 7:2= Reserved, must be kept cleared. Bit 1 = OPx PWMx Output Polarity. This bit is read/write by software and cleared by hardware after a reset. This bit selects the polarity of the PWM signal. 0: The PWM signal is not inverted. 1: The PWM signal is inverted. Bit 0 = CMPFx PWMx Compare Flag. This bit is set by hardware and cleared by software by reading the PWMxCSR register. It indicates that the upcounter value matches the DCRx regis- ter value. 0: Upcounter value does not match DCR value. 1: Upcounter value matches DCR value. BREAK CONTROL REGISTER (BREAKCR) Read/Write Reset Value: 0000 0000 (00h) Bits 7:6 = Reserved. Forced by hardware to 0. Bit 5 = BA Break Active. This bit is read/write by software, cleared by hard- ware after reset and set by hardware when the BREAK pin is low. It activates/deactivates the Break function. 0: Break not active 1: Break active 15 8 0 0 0 0 ATR11 ATR10 ATR9 ATR8 ATR7 ATR6 ATR5 ATR4 ATR3 ATR2 ATR1 ATR0 0O E 30O E 20O E 10O E 0 76 0

000000 O P x C M P F x

0 0 BA BPEN PWM3 PWM2 PWM1 PWM0

12-BIT AUTORELOAD TIMER (Cont’d) Bit 4 = BPEN Break Pin Enable. This bit is read/write by software and cleared by hardware after Reset. 0: Break pin disabled 1: Break pin enabled Bit 3:0 = PWM[3:0] Break Pattern. These bits are read/write by software and cleared by hardware after a reset. They are used to force the four PWMx output signals into a stable state when the Break function is active. PWMx DUTY CYCLE REGISTER HIGH (DCRxH) Read / Write Reset Value: 0000 0000 (00h) PWMx DUTY CYCLE REGISTER LOW (DCRxL) Read / Write Reset Value: 0000 0000 (00h) Bits 15:12 = Reserved. Bits 11:0 = DCR[11:0] PWMx Duty Cycle Value This 12-bit value is written by software. It defin- esthe duty cycle of the corresponding PWM output signal (see Figure 36). In PWM mode (OEx=1 in the PWMCR register) the DCR[11:0] bits define the duty cycle of the PWMx output signal (see Figure 36). In Output Compare mode, they define the value to be com- pared with the 12-bit upcounter value. INPUT CAPTURE REGISTER HIGH (ATICRH) Read only Reset Value: 0000 0000 (00h) INPUT CAPTURE REGISTER LOW (ATICRL) Read only Reset Value: 0000 0000 (00h) Bits 15:12 = Reserved. Bits 11:0 = ICR[11:0] Input Capture Data. This is a 12-bit register which is readable by soft- ware and cleared by hardware after a reset. The ATICR register contains captured the value of the 12-bit CNTR register when a rising or falling edge occurs on the ATIC pin. Capture will only be per- formed when the ICF flag is cleared. TRANSFER CONTROL REGISTER (TRANCR) Read/Write Reset Value: 0000 0001 (01h) Bits 7:1 Reserved. Forced by hardware to 0. Bit 0 = TRAN Transfer enable This bit is read/write by software, cleared by hard- ware after each completed transfer and set by hardware after reset. It allows the value of the DCRx registers to be transferred to the DCRx shadow registers after the next overflow event. The OPx bits are transferred to the shadow OPx bits in the same way. 15 8 0 0 0 0 DCR11 DCR10 DCR9 DCR8 DCR7 DCR6 DCR5 DCR4 DCR3 DCR2 DCR1 DCR0 15 8

0000 I C R 1 1 I C R 1 0 I C R 9 I C R 8

ICR7 ICR6 ICR5 ICR4 ICR3 ICR2 ICR1 ICR0

0000000 T R A N

Table 14. Register Map and Reset Values

10 ATRH

11 ATRL

12 PWMCR

13 PWM0CSR

14 PWM1CSR

15 PWM2CSR

16 PWM3CSR

17 DCR0H

18 DCR0L

19 DCR1H

20 ATICRL

21 TRANCR

22 BREAKCR

(Hex.) Register Label 76543210

11.3 LITE TIMER 2 (LT2)

11.3.1 Introduction

bit upcounters, an 8-bit input capture register.

11.3.2 Main Features

Figure 40. Lite Timer 2 Block Diagram

11.3.3 Functional Description

11.3.3.1 Timebase Counter 1

riod between two counter overflow events is 1 ms. software reading the LTCSR1 register.

11.3.3.2 Timebase Counter 2

rupt request is generated if the TB2IE bit is set.

11.3.3.3 Input Capture

LTICR1 register contains the MSB of Counter 1. ICF bit is cleared by reading the LTICR register. capture is inhibited if the ICF bit is set. Figure 41. Input Capture Timing Diagram.

LITE TIMER (Cont’d) – The opcode for the HALT instruction is 0x8E. To avoid an unexpected HALT instruction due to a program counter failure, it is advised to clear all occurrences of the data value 0x8E from memo- ry. For example, avoid defining a constant in ROM with the value 0x8E. – As the HALT instruction clears the I bit in the CC register to allow interrupts, the user may choose to clear all pending interrupt bits before execut- ing the HALT instruction. This avoids entering other peripheral interrupt routines after executing the external interrupt routine corresponding to the wake-up event (reset or external interrupt).

11.3.4 Low Power Modes

11.3.5 Interrupts

Note: The TBxF and ICF interrupt events are con- nected to separate interrupt vectors (see Inter- rupts chapter). They generate an interrupt if the enable bit is set in the LTCSR1 or LTCSR2 register and the interrupt mask in the CC register is reset (RIM instruction).

11.3.6 Register Description

LITE TIMER CONTROL/STATUS REGISTER 2 (LTCSR2) Read / Write Reset Value: 0x00 0000 (x0h) Bits 7:2 = Reserved, must be kept cleared. Bit 1 = TB2IE Timebase 2 Interrupt enable. This bit is set and cleared by software. 0: Timebase (TB2) interrupt disabled 1: Timebase (TB2) interrupt enabled Bit 0 = TB2F Timebase 2 Interrupt Flag. This bit is set by hardware and cleared by software reading the LTCSR register. Writing to this bit has no effect. 0: No Counter 2 overflow 1: A Counter 2 overflow has occurred LITE TIMER AUTORELOAD REGISTER (LTARR) Read / Write Reset Value: 0000 0000 (00h) Bits 7:0 = AR[7:0] Counter 2 Reload Value. These bits register is read/write by software. The LTARR value is automatically loaded into Counter 2 (LTCNTR) when an overflow occurs. Mode Description SLOW No effect on Lite timer (this peripheral is driven directly by f OSC /32) WAIT No effect on Lite timer ACTIVE-HALT No effect on Lite timer HALT Lite timer stops counting Interrupt Event Event Flag Enable Control Bit Exit from Wait Exit from Active Halt Exit from Halt Timebase 1 Event TB1F TB1IE Yes Yes No Timebase 2 Event TB2F TB2IE Yes No No IC Event ICF ICIE Yes No No

000000 T B 2 I E T B 2 F

AR7 AR7 AR7 AR7 AR3 AR2 AR1 AR0

LITE TIMER (Cont’d) LITE TIMER COUNTER 2 (LTCNTR) Read only Reset Value: 0000 0000 (00h) Bits 7:0 = CNT[7:0] Counter 2 Reload Value. This register is read by software. The LTARR val- ue is automatically loaded into Counter 2 (LTCN- TR) when an overflow occurs. LITE TIMER CONTROL/STATUS REGISTER (LTCSR1) Read / Write Reset Value: 0x00 0000 (x0h) Bit 7 = ICIE Interrupt Enable. This bit is set and cleared by software. 0: Input Capture (IC) interrupt disabled 1: Input Capture (IC) interrupt enabled Bit 6 = ICF Input Capture Flag. This bit is set by hardware and cleared by software by reading the LTICR register. Writing to this bit does not change the bit value. 0: No input capture 1: An input capture has occurred Note: After an MCU reset, software must initialise the ICF bit by reading the LTICR register Bit 5 = TB Timebase period selection. This bit is set and cleared by software. 0: Timebase period = tOSC * 8000 (1ms @ 8 MHz) 1: Timebase period = tOSC * 16000 (2ms @ 8 MHz) Bit 4 = TB1IE Timebase Interrupt enable. This bit is set and cleared by software. 0: Timebase (TB1) interrupt disabled 1: Timebase (TB1) interrupt enabled Bit 3 = TB1F Timebase Interrupt Flag. This bit is set by hardware and cleared by software reading the LTCSR register. Writing to this bit has no effect. 0: No counter overflow 1: A counter overflow has occurred Bits 2:0 = Reserved LITE TIMER INPUT CAPTURE REGISTER (LTICR) Read only Reset Value: 0000 0000 (00h) Bits 7:0 = ICR[7:0] Input Capture Value These bits are read by software and cleared by hardware after a reset. If the ICF bit in the LTCSR is cleared, the value of the 8-bit up-counter will be captured when a rising or falling edge occurs on the LTIC pin. CNT7 CNT7 CNT7 CNT7 CNT3 CNT2 CNT1 CNT0 ICIE ICF TB TB1IE TB1F - - - ICR7 ICR6 ICR5 ICR4 ICR3 ICR2 ICR1 ICR0

Table 15. Lite Timer Register Map and Reset Values

08 LTCSR2

09 LTARR

11.4 SERIAL PERIPHERAL INTERFACE (SPI)

11.4.1 Introduction

which devices may be either masters or slaves.

11.4.2 Main Features

11.4.3 General Description

ard I/O ports on the master Device. Figure 42. Serial Peripheral Interface Block Diagram

11.4.3.1 Functional Description

slave (most significant bit first). the master device via the SCK pin). simplex communication is possible). must be programmed with the same timing mode. Figure 43. Single Master/ Single Slave Application

11.4.3.2 Slave Select Management

shift register (see Section 11.4.5.3). Figure 44. Generic SS Figure 45. Hardware/Software Slave Select Management

SERIAL PERIPHERAL INTERFACE (Cont’d)

11.4.3.3 Master Mode Operation

In master mode, the serial clock is output on the SCK pin. The clock frequency, polarity and phase are configured by software (refer to the description of the SPICSR register). Note: The idle state of SCK must correspond to the polarity selected in the SPICSR register (by pulling up SCK if CPOL=1 or pulling down SCK if CPOL=0). To operate the SPI in master mode, perform the following two steps in order (if the SPICSR register is not written first, the SPICR register setting may be not taken into account): 1. Write to the SPICSR register: – Select the clock frequency by configuring the SPR[2:0] bits. – Select the clock polarity and clock phase by configuring the CPOL and CPHA bits. Figure 46 shows the four possible configurations. Note: The slave must have the same CPOL and CPHA settings as the master. – Either set the SSM bit and set the SSI bit or clear the SSM bit and tie the SS pin high for the complete byte transmit sequence. 2. Write to the SPICR register: – Set the MSTR and SPE bits Note: MSTR and SPE bits remain set only if SS is high). The transmit sequence begins when software writes a byte in the SPIDR register.

11.4.3.4 Master Mode Transmit Sequence

When software writes to the SPIDR register, the data byte is loaded into the 8-bit shift register and then shifted out serially to the MOSI pin most sig- nificant bit first. When data transfer is complete: – The SPIF bit is set by hardware – An interrupt request is generated if the SPIE bit is set and the interrupt mask in the CCR register is cleared. Clearing the SPIF bit is performed by the following software sequence: 1. An access to the SPICSR register while the SPIF bit is set 2. A read to the SPIDR register. Note: While the SPIF bit is set, all writes to the SPIDR register are inhibited until the SPICSR reg- ister is read.

11.4.3.5 Slave Mode Operation

In slave mode, the serial clock is received on the SCK pin from the master device. To operate the SPI in slave mode: 1. Write to the SPICSR register to perform the fol- lowing actions: – Select the clock polarity and clock phase by configuring the CPOL and CPHA bits (see Figure 46). Note: The slave must have the same CPOL and CPHA settings as the master. – Manage the SS pin as described in Section 11.4.3.2 and Figure 44. If CPHA=1 SS must be held low continuously. If CPHA=0 SS must be held low during byte transmission and pulled up between each byte to let the slave write in the shift register. 2. Write to the SPICR register to clear the MSTR bit and set the SPE bit to enable the SPI I/O functions.

11.4.3.6 Slave Mode Transmit Sequence

When software writes to the SPIDR register, the data byte is loaded into the 8-bit shift register and then shifted out serially to the MISO pin most sig- nificant bit first. The transmit sequence begins when the slave de- vice receives the clock signal and the most signifi- cant bit of the data on its MOSI pin. When data transfer is complete: – The SPIF bit is set by hardware – An interrupt request is generated if SPIE bit is set and interrupt mask in the CCR register is cleared. Clearing the SPIF bit is performed by the following software sequence: 1. An access to the SPICSR register while the SPIF bit is set. 2. A write or a read to the SPIDR register. Notes: While the SPIF bit is set, all writes to the SPIDR register are inhibited until the SPICSR reg- ister is read. The SPIF bit can be cleared during a second transmission; however, it must be cleared before the second SPIF bit in order to prevent an Overrun condition (see Section 11.4.5.2).

11.4.4 Clock Phase and Clock Polarity

master and the slave device. Figure 46. Data Clock Timing Diagram Note: This figure should not be used as a replacement for parametric information. Refer to the Electrical Characteristics chapter.

11.4.5 Error Flags

11.4.5.1 Master Mode Fault (MODF)

quest is generated if the SPIE bit is set.

  1. A read access to the SPICSR register while the
  2. A write to the SPICR register.

inal state during or after this clearing sequence. the MODF bit clearing sequence. slave mode with the MODF bit set.

11.4.5.2 Overrun Condition (OVR)

generated if the SPIE bit is set.

11.4.5.3 Write Collision Error (WCOL)

and the software write will be unsuccessful. is set (the WCOL bit is a status flag only). Figure 47. Clearing the WCOL bit (Write Collision Flag) Software Sequence

11.4.5.4 Single Master and Multimaster

the four SS pins of the slave devices. that time, thus disabling the slave devices. through the serial peripheral interface system. Figure 48. Single Master / Multiple Slave Configuration

SERIAL PERIPHERAL INTERFACE (Cont’d)

11.4.6 Low Power Modes

11.4.6.1 Using the SPI to wake-up the Device

In slave configuration, the SPI is able to wake-up the Device from HALT mode through a SPIF inter- rupt. The data received is subsequently read from the SPIDR register when the software is running (interrupt vector fetch). If multiple data transfers have been performed before software clears the SPIF bit, then the OVR bit is set by hardware. Note: When waking up from Halt mode, if the SPI remains in Slave mode, it is recommended to per- form an extra communications cycle to bring the SPI from Halt mode state to normal state. If the SPI exits from Slave mode, it returns to normal state immediately. Caution: The SPI can wake-up the Device from Halt mode only if the Slave Select signal (external SS pin or the SSI bit in the SPICSR register) is low when the Device enters Halt mode. So if Slave se- lection is configured as external (see Section 11.4.3.2), make sure the master drives a low level on the SS pin when the slave enters Halt mode.

11.4.7 Interrupts

Note: The SPI interrupt events are connected to the same interrupt vector (see Interrupts chapter). They generate an interrupt if the corresponding Enable Control Bit is set and the interrupt mask in the CC register is reset (RIM instruction). Mode Description WAIT No effect on SPI. SPI interrupt events cause the Device to exit from WAIT mode. HALT SPI registers are frozen. In HALT mode, the SPI is inactive. SPI oper- ation resumes when the Device is woken up by an interrupt with “exit from HALT mode” capability. The data received is subsequently read from the SPIDR register when the soft- ware is running (interrupt vector fetching). If several data are received before the wake- up event, then an overrun error is generated. This error can be detected after the fetch of the interrupt routine that woke up the Device. Interrupt Event Event Flag Enable Control Bit Exit from Wait Exit from Halt SPI End of Trans- fer Event SPIF SPIE Yes Yes Master Mode Fault Event MODF Yes No Overrun Error OVR Yes No

11.4.8 Register Description

Serial Peripheral Interrupt Enable. This bit is set and cleared by software. Serial Peripheral Output Enable. Note: This bit has no effect in slave mode. tions of the MISO and MOSI pins are reversed. Bit 3 = CPOL Clock Polarity. This bit is set and cleared by software. CPHA settings as the master. Bits 1:0 = SPR[1:0] Serial Clock Frequency. Note: These 2 bits have no effect in slave mode. Table 16. SPI Master mode SCK Frequency

SERIAL PERIPHERAL INTERFACE (Cont’d) CONTROL/STATUS REGISTER (SPICSR) Read/Write (some bits Read Only) Reset Value: 0000 0000 (00h) Bit 7 = SPIF Serial Peripheral Data Transfer Flag (Read only). This bit is set by hardware when a transfer has been completed. An interrupt is generated if SPIE=1 in the SPICR register. It is cleared by a software sequence (an access to the SPICSR register followed by a write or a read to the SPIDR register). 0: Data transfer is in progress or the flag has been cleared. 1: Data transfer between the Device and an exter- nal device has been completed. Note: While the SPIF bit is set, all writes to the SPIDR register are inhibited until the SPICSR reg- ister is read. Bit 6 = WCOL Write Collision status (Read only). This bit is set by hardware when a write to the SPIDR register is done during a transmit se- quence. It is cleared by a software sequence (see Figure 47). 0: No write collision occurred 1: A write collision has been detected Bit 5 = OVR S PI Overrun error (Read only). This bit is set by hardware when the byte currently being received in the shift register is ready to be transferred into the SPIDR register while SPIF = 1 (See Section 11.4.5.2). An interrupt is generated if SPIE = 1 in SPICSR register. The OVR bit is cleared by software reading the SPICSR register. 0: No overrun error 1: Overrun error detected Bit 4 = MODF Mode Fault flag (Read only). This bit is set by hardware when the SS pin is pulled low in master mode (see Section 11.4.5.1 Master Mode Fault (MODF)). An SPI interrupt can be generated if SPIE=1 in the SPICSR register. This bit is cleared by a software sequence (An ac- cess to the SPICSR register while MODF=1 fol- lowed by a write to the SPICR register). 0: No master mode fault detected 1: A fault in master mode has been detected Bit 3 = Reserved, must be kept cleared. Bit 2 = SOD SPI Output Disable. This bit is set and cleared by software. When set, it disables the alternate function of the SPI output (MOSI in master mode / MISO in slave mode) 0: SPI output enabled (if SPE=1) 1: SPI output disabled Bit 1 = SSM SS Management. This bit is set and cleared by software. When set, it disables the alternate function of the SPI SS pin and uses the SSI bit value instead. See Section 11.4.3.2 Slave Select Management. 0: Hardware management (SS managed by exter- nal pin) 1: Software management (internal SS signal con- trolled by SSI bit. External SS pin free for gener- al-purpose I/O) Bit 0 = SSI SS Internal Mode. This bit is set and cleared by software. It acts as a ‘chip select’ by controlling the level of the SS slave select signal when the SSM bit is set. 0 : Slave selected 1 : Slave deselected DATA I/O REGISTER (SPIDR) Read/Write Reset Value: Undefined The SPIDR register is used to transmit and receive data on the serial bus. In a master device, a write to this register will initiate transmission/reception of another byte. Notes: During the last clock cycle the SPIF bit is set, a copy of the received data byte in the shift register is moved to a buffer. When the user reads the serial peripheral data I/O register, the buffer is actually being read. While the SPIF bit is set, all writes to the SPIDR register are inhibited until the SPICSR register is read. Warning: A write to the SPIDR register places data directly into the shift register for transmission. A read to the SPIDR register returns the value lo- cated in the buffer and not the content of the shift register (see Figure 42). SPIF WCOL OVR MODF - SOD SSM SSI D7 D6 D5 D4 D3 D2 D1 D0

Table 17. SPI Register Map and Reset Values

11.5.1 Introduction

levels from up to 7 different sources. through a Control/Status Register.

11.5.2 Main Features

The block diagram is shown in Figure 49.

11.5.3 Functional Description

11.5.3.1 Analog Power Supply

loaded or badly decoupled power supply lines. Figure 49. ADC Block Diagram

10-BIT A/D CONVERTER (ADC) (Cont’d)

11.5.3.2 Input Voltage Amplifier

The input voltage can be amplified by a factor of 8 by enabling the AMPSEL bit in the ADCDRL regis- ter. When the amplifier is enabled, the input range is 0V to VDD /8. For example, if VDD = 5V, then the ADC can con- vert voltages in the range 0V to 430mV with an ideal resolution of 0.6mV (equivalent to 13-bit res- olution with reference to a V SS to VDD range). For more details, refer to the Electrical character- istics section. Note: The amplifier is switched on by the ADON bit in the ADCCSR register, so no additional start- up time is required when the amplifier is selected by the AMPSEL bit.

11.5.3.3 Digital A/D Conversion Result

The conversion is monotonic, meaning that the re- sult never decreases if the analog input does not and never increases if the analog input does not. If the input voltage (V AIN) is greater than VDDA (high-level voltage reference) then the conversion result is FFh in the ADCDRH register and 03h in the ADCDRL register (without overflow indication). If the input voltage (VAIN) is lower than VSSA (low- level voltage reference) then the conversion result in the ADCDRH and ADCDRL registers is 00 00h. The A/D converter is linear and the digital result of the conversion is stored in the ADCDRH and AD- CDRL registers. The accuracy of the conversion is described in the Electrical Characteristics Section. R AIN is the maximum recommended impedance for an analog input signal. If the impedance is too high, this will result in a loss of accuracy due to leakage and sampling not being completed in the alloted time.

11.5.3.4 A/D Conversion

The analog input ports must be configured as in- put, no pull-up, no interrupt. Refer to the «I/O ports» chapter. Using these pins as analog inputs does not affect the ability of the port to be read as a logic input. In the ADCCSR register: – Select the CS[2:0] bits to assign the analog channel to convert. ADC Conversion mode In the ADCCSR register: Set the ADON bit to enable the A/D converter and to start the conversion. From this time on, the ADC performs a continuous conversion of the selected channel. When a conversion is complete: – The EOC bit is set by hardware. – The result is in the ADCDR registers. A read to the ADCDRH resets the EOC bit. To read the 10 bits, perform the following steps: 1. Poll EOC bit 2. Read ADCDRL 3. Read ADCDRH. This clears EOC automati- cally. To read only 8 bits, perform the following steps: 1. Poll EOC bit 2. Read ADCDRH. This clears EOC automati- cally.

11.5.4 Low Power Modes

Note: The A/D converter may be disabled by re- setting the ADON bit. This feature allows reduced power consumption when no conversion is need- ed and between single shot conversions.

11.5.5 Interrupts

None. Mode Description WAIT No effect on A/D Converter HALT A/D Converter disabled. After wakeup from Halt mode, the A/D Converter requires a stabilization time t STAB (see Electrical Characteristics) before accurate conversions can be performed.

10-BIT A/D CONVERTER (ADC) (Cont’d)

11.5.6 Register Description

CONTROL/STATUS REGISTER (ADCCSR) Read/Write (Except bit 7 read only) Reset Value: 0000 0000 (00h) Bit 7 = EOC End of Conversion This bit is set by hardware. It is cleared by soft- ware reading the ADCDRH register. 0: Conversion is not complete 1: Conversion complete Bit 6 = SPEED ADC clock selection This bit is set and cleared by software. It is used together with the SLOW bit to configure the ADC clock speed. Refer to the table in the SLOW bit de- scription. Bit 5 = ADON A/D Converter on This bit is set and cleared by software. 0: A/D converter and amplifier are switched off 1: A/D converter and amplifier are switched on Bit 4:3 = Reserved. Must be kept cleared. Bit 2:0 = CH[2:0] Channel Selection These bits are set and cleared by software. They select the analog input to convert. *The number of channels is device dependent. Refer to the device pinout description. DATA REGISTER HIGH (ADCDRH) Read Only Reset Value: xxxx xxxx (xxh) Bit 7:0 = D[9:2] MSB of Analog Converted Value AMP CONTROL/DATA REGISTER LOW (AD- CDRL) Read/Write Reset Value: 0000 00xx (0xh) Bit 7:5 = Reserved. Forced by hardware to 0. Bit 4 = AMPCAL Amplifier Calibration Bit This bit is set and cleared by software. 0: Calibration off 1: Calibration on. The input voltage of the amp is set to 0V. Bit 3 = SLOW Slow mode This bit is set and cleared by software. It is used together with the SPEED bit to configure the ADC clock speed as shown on the table below. Bit 2 = AMPSEL Amplifier Selection Bit This bit is set and cleared by software. 0: Amplifier is not selected 1: Amplifier is selected Note: When AMPSEL=1 it is mandatory that fADC be less than or equal to 2 MHz. Bit 1:0 = D[1:0] LSB of Analog Converted Value EOC SPEED ADON 0 CH3 CH2 CH1 CH0 Channel Pin* CH2 CH1 CH0 AIN0 0 0 0 AIN1 0 0 1 AIN2 0 1 0 AIN3 0 1 1 AIN4 1 0 0 AIN5 1 0 1 AIN6 1 1 0 D9 D8 D7 D6 D5 D4 D3 D2

000 AMP

Table 18. ADC Register Map and Reset Values

12 INSTRUCTION SET

12.1 ST7 ADDRESSING MODES

Table 19. ST7 Addressing Mode Overview

ST7 ADDRESSING MODES (Cont’d)

12.1.1 Inherent

All Inherent instructions consist of a single byte. The opcode fully specifies all the required informa- tion for the CPU to process the operation.

12.1.2 Immediate

Immediate instructions have two bytes, the first byte contains the opcode, the second byte con- tains the operand value.

12.1.3 Direct

In Direct instructions, the operands are referenced by their memory address. The direct addressing mode consists of two sub- modes: Direct (short) The address is a byte, thus requires only one byte after the opcode, but only allows 00 - FF address- ing space. Direct (long) The address is a word, thus allowing 64 Kbyte ad- dressing space, but requires 2 bytes after the op- code.

12.1.4 Indexed (No Offset, Short, Long)

In this mode, the operand is referenced by its memory address, which is defined by the unsigned addition of an index register (X or Y) with an offset. The indirect addressing mode consists of three sub-modes: Indexed (No Offset) There is no offset, (no extra byte after the opcode), and allows 00 - FF addressing space. Indexed (Short) The offset is a byte, thus requires only one byte af- ter the opcode and allows 00 - 1FE addressing space. Indexed (long) The offset is a word, thus allowing 64 Kbyte ad- dressing space and requires 2 bytes after the op- code.

12.1.5 Indirect (Short, Long)

The required data byte to do the operation is found by its memory address, located in memory (point- er). The pointer address follows the opcode. The indi- rect addressing mode consists of two sub-modes: Indirect (short) The pointer address is a byte, the pointer size is a byte, thus allowing 00 - FF addressing space, and requires 1 byte after the opcode. Indirect (long) The pointer address is a byte, the pointer size is a word, thus allowing 64 Kbyte addressing space, and requires 1 byte after the opcode. Inherent Instruction Function NOP No operation TRAP S/W Interrupt WFI Wait For Interrupt (Low Power Mode) HALT Halt Oscillator (Lowest Power Mode) RET Sub-routine Return IRET Interrupt Sub-routine Return SIM Set Interrupt Mask RIM Reset Interrupt Mask SCF Set Carry Flag RCF Reset Carry Flag RSP Reset Stack Pointer LD Load CLR Clear PUSH/POP Push/Pop to/from the stack INC/DEC Increment/Decrement TNZ Test Negative or Zero CPL, NEG 1 or 2 Complement MUL Byte Multiplication SLL, SRL, SRA, RLC, RRC Shift and Rotate Operations SWAP Swap Nibbles Immediate Instruction Function LD Load CP Compare BCP Bit Compare AND, OR, XOR Logical Operations ADC, ADD, SUB, SBC Arithmetic Operations

12.1.6 Indirect Indexed (Short, Long)

er address follows the opcode. and requires 1 byte after the opcode. and requires 1 byte after the opcode. Table 20. Instructions Supporting Direct,

12.1.7 Relative Mode (Direct, Indirect)

register value by adding an 8-bit signed offset to it. The offset follows the opcode.

12.2 INSTRUCTION GROUPS

The ST7 family devices use an Instruction Set consisting of 63 instructions. The instructions may be subdivided into 13 main groups as illustrated in the following table: Using a pre-byte The instructions are described with one to four bytes. In order to extend the number of available op- codes for an 8-bit CPU (256 opcodes), three differ- ent prebyte opcodes are defined. These prebytes modify the meaning of the instruction they pre- cede. The whole instruction becomes: PC-2 End of previous instruction PC-1 Prebyte PC Opcode PC+1 Additional word (0 to 2) according to the number of bytes required to compute the effective address These prebytes enable instruction in Y as well as indirect addressing modes to be implemented. They precede the opcode of the instruction in X or the instruction using direct addressing mode. The prebytes are: PDY 90 Replace an X based instruction using immediate, direct, indexed, or inherent addressing mode by a Y one. PIX 92 Replace an instruction using direct, di- rect bit, or direct relative addressing mode to an instruction using the corre- sponding indirect addressing mode. It also changes an instruction using X indexed addressing mode to an instruc- tion using indirect X indexed addressing mode. PIY 91 Replace an instruction using X indirect indexed addressing mode by a Y one. Load and Transfer LD CLR Stack operation PUSH POP RSP Increment/Decrement INC DEC Compare and Tests CP TNZ BCP Logical operations AND OR XOR CPL NEG Bit Operation BSET BRES Conditional Bit Test and Branch BTJT BTJF Arithmetic operations ADC ADD SUB SBC MUL Shift and Rotates SLL SRL SRA RLC RRC SWAP SLA Unconditional Jump or Call JRA JRT JRF JP CALL CALLR NOP RET Conditional Branch JRxx Interruption management TRAP WFI HALT IRET Condition Code Flag modification SIM RIM SCF RCF

INSTRUCTION GROUPS (Cont’d) Mnemo Description Function/Example Dst Src H I N Z C ADC Add with Carry A = A + M + C A M H N Z C ADD Addition A = A + M A M H N Z C AND Logical And A = A . M A M N Z BCP Bit compare A, Memory tst (A . M) A M N Z BRES Bit Reset bres Byte, #3 M BSET Bit Set bset Byte, #3 M BTJF Jump if bit is false (0) btjf Byte, #3, Jmp1 M C BTJT Jump if bit is true (1) btjt Byte, #3, Jmp1 M C CALL Call subroutine CALLR Call subroutine relative CLR Clear reg, M 0 1 CP Arithmetic Compare tst(Reg - M) reg M N Z C CPL One Complement A = FFH-A reg, M N Z 1 DEC Decrement dec Y reg, M N Z HALT Halt 0 IRET Interrupt routine return Pop CC, A, X, PC H I N Z C INC Increment inc X reg, M N Z JRA Jump relative always JRT Jump relative JRF Never jump jrf * JRIH Jump if ext. interrupt = 1 JRIL Jump if ext. interrupt = 0 JRH Jump if H = 1 H = 1 ? JRNH Jump if H = 0 H = 0 ? JRM Jump if I = 1 I = 1 ? JRNM Jump if I = 0 I = 0 ? JRMI Jump if N = 1 (minus) N = 1 ? JRPL Jump if N = 0 (plus) N = 0 ? JREQ Jump if Z = 1 (equal) Z = 1 ? JRNE Jump if Z = 0 (not equal) Z = 0 ? JRC Jump if C = 1 C = 1 ? JRNC Jump if C = 0 C = 0 ? JRULT Jump if C = 1 Unsigned < JRUGE Jump if C = 0 Jmp if unsigned >= JRUGT Jump if (C + Z = 0) Unsigned >

INSTRUCTION GROUPS (Cont’d) Mnemo Description Function/Example Dst Src H I N Z C JRULE Jump if (C + Z = 1) Unsigned <= LD Load dst <= src reg, M M, reg N Z MUL Multiply X,A = X * A A, X, Y X, Y, A 0 0 NEG Negate (2's compl) neg $10 reg, M N Z C NOP No Operation OR OR operation A = A + M A M N Z POP Pop from the Stack pop reg reg M pop CC CC M H I N Z C PUSH Push onto the Stack push Y M reg, CC RCF Reset carry flag C = 0 0 RET Subroutine Return RIM Enable Interrupts I = 0 0 RLC Rotate left true C C <= Dst <= C reg, M N Z C RRC Rotate right true C C => Dst => C reg, M N Z C RSP Reset Stack Pointer S = Max allowed SBC Subtract with Carry A = A - M - C A M N Z C SCF Set carry flag C = 1 1 SIM Disable Interrupts I = 1 1 SLA Shift left Arithmetic C <= Dst <= 0 reg, M N Z C SLL Shift left Logic C <= Dst <= 0 reg, M N Z C SRL Shift right Logic 0 => Dst => C reg, M 0 Z C SRA Shift right Arithmetic Dst7 => Dst => C reg, M N Z C SUB Subtraction A = A - M A M N Z C SWAP SWAP nibbles Dst[7..4] <=> Dst[3..0] reg, M N Z TNZ Test for Neg & Zero tnz lbl1 N Z TRAP S/W trap S/W interrupt 1 WFI Wait for Interrupt 0 XOR Exclusive OR A = A XOR M A M N Z

13 ELECTRICAL CHARACTERISTICS

13.1 PARAMETER CONDITIONS

13.1.1 Minimum and Maximum values

times the standard deviation (mean±3Σ).

13.1.2 Typical values

guidelines and are not tested.

13.1.3 Typical curves

given only as design guidelines and are not tested.

13.1.4 Loading capacitor

measurement are shown in Figure 50. Figure 50. Pin loading conditions

13.1.5 Pin input voltage

vice is described in Figure 51. Figure 51. Pin input voltage

13.2 ABSOLUTE MAXIMUM RATINGS

Stresses above those listed as “absolute maxi- mum ratings” may cause permanent damage to the device. This is a stress rating only and func- tional operation of the device under these condi- tions is not implied. Exposure to maximum rating conditions for extended periods may affect device reliability.

13.2.1 Voltage Characteristics

13.2.2 Current Characteristics

13.2.3 Thermal Characteristics

Notes: 1. Directly connecting the RESET and I/O pins to VDD or VSS could damage the device if an unintentional internal reset is generated or an unexpected change of the I/O configuration occurs (for example, due to a corrupted program counter). To guarantee safe operation, this connection has to be done through a pull-up or pull-down resistor (typical: 4.7kΩ for RESET , 10kΩ for I/Os). Unused I/O pins must be tied in the same way to VDD or VSS according to their reset configuration. 2. When the current limitation is not possible, the VIN absolute maximum rating must be respected, otherwise refer to IINJ(PIN) specification. A positive injection is induced by VIN>V DD while a negative injection is induced by VIN<V SS . 3. All power (VDD ) and ground (VSS ) lines must always be connected to the external supply. 4. Negative injection disturbs the analog performance of the device. In particular, it induces leakage currents throughout the device including the analog inputs. To avoid undesirable effects on the analog functions, care must be taken: - Analog input pins must have a negative injection less than 0.8 mA (assuming that the impedance of the analog voltage is lower than the specified limits) - Pure digital pins must have a negative injection less than 1.6mA. In addition, it is recommended to inject the current as far as possible from the analog input pins. 5. When several inputs are submitted to a current injection, the maximum ΣIINJ(PIN) is the absolute sum of the positive and negative injected currents (instantaneous values). These results are based on characterisation with ΣIINJ(PIN) maxi- mum current injection on four I/O port pins of the device. Symbol Ratings Maximum value Unit VDD - VSS Supply voltage 7.0 V VIN Input voltage on any pin 1) & 2) VSS -0.3 to VDD +0.3 VESD(HBM) Electrostatic discharge voltage (Human Body Model) see section 13.7.3 on page 104 VESD(MM) Electrostatic discharge voltage (Machine Model) Symbol Ratings Maximum value Unit IVDD Total current into VDD power lines (source) 3) 150 mA IVSS Total current out of VSS ground lines (sink) 3) 150 IIO Output current sunk by any standard I/O and control pin 25 Output current sunk by any high sink I/O pin 50 Output current source by any I/Os and control pin - 25 I INJ(PIN) 2) & 4) Injected current on ISPSEL pin ± 5 Injected current on RESET pin ± 5 Injected current on OSC1 and OSC2 pins ± 5 Injected current on any other pin 5) ± 5 ΣIINJ(PIN) 2) Total injected current (sum of all I/O and control pins) 5) ± 20 Symbol Ratings Value Unit TSTG Storage temperature range -65 to +150 °C TJ Maximum junction temperature (see Table 21, “THERMAL CHARACTERISTICS,” on page 121)

13.3 OPERATING CONDITIONS

13.3.1 General Operating Conditions: Suffix 6 Devices

TA = -40 to +85°C unless otherwise specified. Figure 52. fCLKIN Maximum Operating Frequency Versus VDD Supply Voltage

13.3.2 Operating Conditions with Low Voltage Detector (LVD)

TA = -40 to 125°C, unless otherwise specified Note: 1. Not tested in production. 2. Not tested in production. The V DD rise time rate condition is needed to insure a correct device power-on and LVD reset. When the VDD slope is outside these values, the LVD may not ensure a proper reset of the MCU.

13.3.3 Auxiliary Voltage Detector (AVD) Thresholds

TA = -40 to 125°C, unless otherwise specified Note: 1. Not tested in production.

13.3.4 Internal RC Oscillator and PLL

The ST7 internal clock can be supplied by an internal RC oscillator and PLL (selectable by option byte). Symbol Parameter Conditions Min Typ Max Unit VIT+(LVD) Reset release threshold (VDD rise) High Threshold Med. Threshold Low Threshold 4.00 3.40 1) 2.65 1) 4.25 3.60 2.90 4.50 3.80 3.15 V V IT-(LVD) Reset generation threshold (VDD fall) High Threshold Med. Threshold Low Threshold 3.80 3.20 2.40 4.05 3.40 2.70 4.30 3.65 1) 2.901) Vhys LVD voltage threshold hysteresis VIT+(LVD)-VIT-(LVD) 200 mV VtPOR VDD rise time rate 2) 20 20000 µs/V tg(VDD) Filtered glitch delay on VDD Not detected by the LVD 150 ns IDD(LVD ) LVD/AVD current consumption 245 µA Symbol Parameter Conditions Min Typ Max Unit VIT+(AVD) 1=>0 AVDF flag toggle threshold (VDD rise) High Threshold Med. Threshold Low Threshold 4.40 3.901) 3.201) 4.70 4.10 3.40 5.00 4.30 3.60 V V IT-(AVD) 0=>1 AVDF flag toggle threshold (VDD fall) High Threshold Med. Threshold Low Threshold 4.30 3.70 2.90 4.60 3.90 3.20 4.90 4.101) 3.401) Vhys AVD voltage threshold hysteresis VIT+(AVD)-VIT-(AVD) 150 mV ΔVIT- Voltage drop between AVD flag set and LVD reset activation VDD fall 0.45 V Symbol Parameter Conditions Min Typ Max Unit VDD(RC) Internal RC Oscillator operating voltage 2.4 5.5 VVDD(x4PLL) x4 PLL operating voltage 2.4 3.3 VDD(x8PLL) x8 PLL operating voltage 3.3 5.5 tSTARTUP PLL Startup time 60 PLL input clock (fPLL) cycles

OPERATING CONDITIONS (Cont’d) The RC oscillator and PLL characteristics are temperature-dependent and are grouped in four tables.

13.3.4.1 Devices with ‘”6” order code suffix (tested for T

A = -40 to +85°C) @ VDD = 4.5 to 5.5V Notes: 1. Data based on characterization results, not tested in production 2. RCCR0 is a factory-calibrated setting for 1000kHz with ±0.2 accuracy @ T A =25°C, VDD =5V. See “INTERNAL RC OS- CILLATOR ADJUSTMENT” on page 23 3. Guaranteed by design. 4. Averaged over a 4ms period. After the LOCKED bit is set, a period of t STAB is required to reach ACCPLL accuracy. 5. After the LOCKED bit is set ACCPLL is max. 10% until tSTAB has elapsed. See Figure 12 on page 24. Symbol Parameter Conditions Min Typ Max Unit fRC Internal RC oscillator fre- quency RCCR = FF (reset value), TA=25°C,VDD =5V 760 kHzRCCR = RCCR0 2 ),TA=25°C,VDD =5V 1000 ACC RC Accuracy of Internal RC oscillator with RCCR=RCCR0 TA=25°C,VDD =4.5 to 5.5V -1 +1% TA=-40 to +85°C,VDD =5V -5 +2 % TA=0 to +85°C,VDD =4.5 to 5.5V -2 1) +21) % IDD(RC) RC oscillator current con- sumption TA=25°C,VDD =5V 970 1) µA tsu(RC) RC oscillator setup time TA=25°C,VDD =5V 10 2) µs fPLL x8 PLL input clock 1 1) MHz tLOCK PLL Lock time5) 2m s tSTAB PLL Stabilization time5) 4m s ACC PLL x8 PLL Accuracy fRC = 1MHz@T A=25°C,VDD =4.5 to 5.5V 0.1 4) % fRC = 1MHz@T A=-40 to +85°C,VDD =5V 0.1 4) % tw(JIT) PLL jitter period f RC = 1MHz 8 3) kHz JITPLL PLL jitter (ΔfCPU /fCPU )1 3) % IDD(PLL) PLL current consumption TA=25°C 600 1) µA

OPERATING CONDITIONS (Cont’d) Notes: 1. Data based on characterization results, not tested in production 2. RCCR1 is a factory-calibrated setting for 700MHz with ±0.2 accuracy @ TA =25°C, VDD =3V. See “INTERNAL RC OS- CILLATOR ADJUSTMENT” on page 23. 3. Guaranteed by design. 4. Averaged over a 4ms period. After the LOCKED bit is set, a period of tSTAB is required to reach ACCPLL accuracy 5. After the LOCKED bit is set ACCPLL is max. 10% until tSTAB has elapsed. See Figure 12 on page 24. Symbol Parameter Conditions Min Typ Max Unit fRC Internal RC oscillator fre- quency RCCR = FF (reset value), TA=25°C, VDD = 3.0V 560 kHzRCCR=RCCR1 2) ,TA=25°C,VDD = 3V 700 ACC RC Accuracy of Internal RC oscillator when calibrated with RCCR=RCCR1 1)2) TA=25°C,VDD =3V -2 +2 % TA=25°C,VDD =2.7 to 3.3V -25 +25 % TA=-40 to +85°C,VDD =3V -15 15 % IDD(RC) RC oscillator current con- sumption TA=25°C,VDD =3V 700 1) µA tsu(RC) RC oscillator setup time TA=25°C,VDD =3V 10 2) µs fPLL x4 PLL input clock 1 1) MHz tLOCK PLL Lock time5) 2m s tSTAB PLL Stabilization time5) 4m s ACC PLL x4 PLL Accuracy fRC = 1MHz@T A=25°C,VDD =2.7 to 3.3V 0.1 4) % fRC = 1MHz@T A=40 to +85°C,VDD = 3V 0.1 4) % tw(JIT) PLL jitter period f RC = 1MHz 8 3) kHz JITPLL PLL jitter (ΔfCPU /fCPU )1 3) % IDD(PLL) PLL current consumption TA=25°C 190 1) µA

13.4 SUPPLY CURRENT CHARACTERISTICS

13.4.1 Supply Current

  1. CPU running with memory access, all I/O pins in input mode with a static value at VDD or VSS (no load), all peripherals

in reset state; clock input (CLKIN) driven by external square wave, LVD disabled.

  1. All I/O pins in input mode with a static value at VDD or VSS (no load), all peripherals in reset state; clock input (CLKIN)

driven by external square wave, LVD disabled.

  1. SLOW mode selected with fCPU based on fOSC divided by 32. All I/O pins in input mode with a static value at VDD or

VSS (no load), all peripherals in reset state; clock input (CLKIN) driven by external square wave, LVD disabled.

  1. SLOW-WAIT mode selected with fCPU based on fOSC divided by 32. All I/O pins in input mode with a static value at

VDD or VSS (no load), all peripherals in reset state; clock input (CLKIN) driven by external square wave, LVD disabled.

  1. All I/O pins in input mode with a static value at VDD or VSS (no load). Data tested in production at VDD max. and fCPU
  2. This consumption refers to the Halt period only and not the associated run period which is software dependent.

Figure 60. Typical IDD in RUN vs. fCPU Figure 61. Typical IDD in SLOW vs. fCPU

8 MHz

4 MHz

1 MHz

250 KHz

125 KHz

62.5 Khz

Figure 62. Typical IDD in WAIT vs. fCPU Figure 63. Typical IDD in SLOW-WAIT vs. fCPU Figure 64. Typical IDD in AWUFH mode Figure 65. Typical IDD vs. Temperature

13.4.2 On-chip peripherals

  1. Data based on a differential IDD measurement between reset configuration (timer stopped) and a timer running in PWM
  2. Data based on a differential IDD measurement between reset configuration and a permanent SPI master communica-

tion (data sent equal to 55h).

  1. Data based on a differential IDD measurement between reset configuration and continuous A/D conversions with am-

13.5 CLOCK AND TIMING CHARACTERISTICS

Subject to general operating conditions for VDD , fOSC , and TA .

13.5.1 General Timings

Notes: 1. Guaranteed by Design. Not tested in production. 2. Data based on typical application software. 3. Time measured between interrupt event and interrupt vector fetch. Dt c(INST) is the number of tCPU cycles needed to fin- ish the current instruction execution.

13.5.2 Auto Wakeup from Halt Oscillator (AWU)

Symbol Parameter 1) Conditions Min Typ 2) Max Unit tc(INST) Instruction cycle time f CPU =8MHz 2 3 12 t CPU 250 375 1500 ns tv(IT) Interrupt reaction time 3) tv(IT) = Δ tc(INST) + 10 fCPU =8MHz 10 22 t CPU 1.25 2.75 µs Symbol Parameter Conditions Min Typ Max Unit fAWU AWU Oscillator Frequency 50 125 250 kHz tRCSRT AWU Oscillator startup time 50 µs

13.6 MEMORY CHARACTERISTICS

TA = -40°C to 125°C, unless otherwise specified

13.6.1 RAM and Hardware Registers

13.6.2 FLASH Program Memory

13.6.3 EEPROM Data Memory

Notes: 1. Minimum VDD supply voltage without losing data stored in RAM (in HALT mode or under RESET) or in hardware reg- isters (only in HALT mode). Guaranteed by construction, not tested in production. 2. Up to 32 bytes can be programmed at a time. 3. The data retention time increases when the T A decreases. 4. Data based on reliability test results and monitored in production. 5. Data based on characterization results, not tested in production. 6. Guaranteed by Design. Not tested in production. 7. Design target value pending full product characterization. Symbol Parameter Conditions Min Typ Max Unit V RM Data retention mode 1) HALT mode (or RESET) 1.6 V Symbol Parameter Conditions Min Typ Max Unit VDD Operating voltage for Flash write/erase 2.4 5.5 V tprog Programming time for 1~32 bytes 2) TA=−40 to +85°C 5 10 ms Programming time for 1.5 kBytes TA=+25°C 0.24 0.48 s tRET Data retention 4) TA=+55°C3) 20 years N RW Write erase cycles TA=+25°C 10K 7) cycles IDD Supply current Read / Write / Erase modes fCPU = 8MHz, VDD = 5.5V 2.66) mA No Read/No Write Mode 100 µA Power down mode / HALT 0 0.1 µA Symbol Parameter Conditions Min Typ Max Unit tprog Programming time for 1~32 bytesTA=−40 to +85°C 5 10 ms tret Data retention 4) TA=+55°C 3) 20 years N RW Write erase cycles TA=+25°C 300K 7) cycles

13.7 EMC CHARACTERISTICS

sis during product characterization.

13.7.1 Functional EMS

until a failure occurs (indicated by the LEDs). conforms with the IEC 1000-4-2 standard. Figure 66. EMC Recommended power supply connection

  1. Data based on characterization results, not tested in production.
  2. The suggested 10µF and 0.1µF decoupling capacitors on the power supply lines are proposed as a good price vs. EMC

dations are given in other sections (I/Os, RESET, OSCx pin characteristics).

EMC CHARACTERISTICS (Cont’d)

13.7.2 Electro Magnetic Interference (EMI)

Based on a simple application running on the product (toggling 2 LEDs through the I/O ports), the product is monitored in terms of emission. This emission test is in line with the norm SAE J 1752/3 which specifies the board and the loading of each pin. Note 1. Data based on characterization results, not tested in production. 13.7.3 7Absolute Electrical Sensitivity Based on three different tests (ESD, LU and DLU) using specific measurement methods, the product is stressed in order to determine its performance in terms of electrical sensitivity. For more details, re- fer to the AN1181 ST7 application note.

13.7.3.1 Electro-Static Discharge (ESD)

Electro-Static Discharges (3 positive then 3 nega- tive pulses separated by 1 second) are applied to the pins of each sample according to each pin combination. The sample size depends of the number of supply pins of the device (3 parts*(n+1) supply pin). Two models are usually simulated: Human Body Model and Machine Model. This test conforms to the JESD22-A114A/A115A standard. See Figure 67 and the following test sequences. Human Body Model Test Sequence – C L is loaded through S1 by the HV pulse gener- ator. – S1 switches position from generator to R. – A discharge from CL through R (body resistance) to the ST7 occurs. – S2 must be closed 10 to 100ms after the pulse delivery period to ensure the ST7 is not left in charge state. S2 must be opened at least 10ms prior to the delivery of the next pulse. Machine Model Test Sequence – C L is loaded through S1 by the HV pulse gener- ator. – S1 switches position from generator to ST7. – A discharge from C L to the ST7 occurs. – S2 must be closed 10 to 100ms after the pulse delivery period to ensure the ST7 is not left in charge state. S2 must be opened at least 10ms prior to the delivery of the next pulse. – R (machine resistance), in series with S2, en- sures a slow discharge of the ST7. Absolute Maximum Ratings Symbol Ratings Conditions Maximum value 1) Unit VESD(HBM) Electro-static discharge voltage (Human Body Model) TA=+25°C 4000 V VESD(MM) Electro-static discharge voltage (Machine Model) TA=+25°C TBD

Figure 67. Typical Equivalent ESD Circuits

  1. Data based on characterization results, not tested in production.

13.7.3.2 Static and Dynamic Latch-Up

on 10 parts to assess the latch-up performance. refer to the AN1181 ST7 application note. Figure 68. Simplified Diagram of the ESD Generator for DLU

  1. Class description: A Class is an STMicroelectronics internal specification. All its limits are higher than the JEDEC spec-

JEDEC criteria (international standard).

  1. Schaffner NSG435 with a pointed test finger.

13.7.4 ESD Pin Protection Strategy

or heating within their structure. Figure 69. Positive Stress on a Standard Pad vs. VSS Figure 70. Negative Stress on a Standard Pad vs. VDD

13.8 I/O PORT PIN CHARACTERISTICS

13.8.1 General Characteristics

Subject to general operating conditions for VDD , fOSC , and TA unless otherwise specified.

  1. Data based on characterization results, not tested in production.
  2. Configuration not recommended, all unused pins must be kept at a fixed voltage: using the output mode of the I/O for

characteristics, not tested in production.

  1. The RPU pull-up equivalent resistor is based on a resistive transistor (corresponding IPU current characteristics de-
  2. To generate an external interrupt, a minimum pulse width has to be applied on an I/O port pin configured as an external

Figure 71. Two typical Applications with unused I/O Pin Figure 72. Typical IPU vs. VDD with VIN=V SS

13.8.2 Output Driving Current

DD , fCPU , and TA unless otherwise specified.

  1. The IIO current sunk must always respect the absolute maximum rating specified in Section 13.2.2 and the sum of IIO

(I/O ports and control pins) must not exceed IVSS .

  1. The IIO current sourced must always respect the absolute maximum rating specified in Section 13.2.2 and the sum of

IIO (I/O ports and control pins) must not exceed IVDD .

  1. Not tested in production, based on characterization results.

Figure 73. Typical VOL at VDD =2.4V (standard) Figure 74. Typical VOL at VDD =2.7V (standard)

13.9 CONTROL PIN CHARACTERISTICS

13.9.1 Asynchronous RESET Pin

Figure 88. Typical Application with RESET pin 6)7)8)

  1. Data based on characterization results, not tested in production.
  2. The IIO current sunk must always respect the absolute maximum rating specified in Section 13.2.2 and the sum of IIO

(I/O ports and control pins) must not exceed IVSS .

  1. The RON pull-up equivalent resistor is based on a resistive transistor. Specified for voltages on RESET pin between
  2. To guarantee the reset of the device, a minimum pulse has to be applied to the RESET pin. All short pulses applied on

RESET pin with a duration below th(RSTL)in can be ignored.

  1. The reset network (the resistor and two capacitors) protects the device against parasitic resets especially in noisy en-
  2. The output of the external reset circuit must have an open-drain output to drive the ST7 reset pad. Otherwise the device

can be damaged when the ST7 generates an internal reset (LVD or watchdog).

  1. Whatever the reset source is (internal or external), the user must ensure that the level on the RESET pin can go below
  2. Because the reset circuit is designed to allow the internal RESET to be output in the RESET pin, the user must ensure

ified for IINJ(RESET) in section 13.2.2 on page 92.

13.10 COMMUNICATION INTERFACE CHARACTERISTICS

13.10.1 SPI - Serial Peripheral Interface

fOSC , and TA unless otherwise specified. Figure 89. SPI Slave Timing Diagram with CPHA=0 3)

  1. Data based on design simulation and/or characterisation results, not tested in production.
  2. When no communication is on-going the data output line of the SPI (MOSI in master mode, MISO in slave mode) has

its alternate function capability released. In this case, the pin status depends on the I/O port configuration.

  1. Measurement points are done at CMOS levels: 0.3xVDD and 0.7xVDD .

Subject to general operating condition for VDD , fOSC , and TA unless otherwise specified. Figure 92. Typical Application with ADC

  1. Unless otherwise specified, typical data are based on TA=25°C and VDD -VSS =5V. They are given only as design guide-
  2. When VDDA and VSSA pins are not available on the pinout, the ADC refers to VDD and VSS .
  3. Any added external serial resistor will downgrade the ADC accuracy (especially for resistance greater than 10kΩ ). Data

based on characterization results, not tested in production.

  1. The stabilization time of the AD converter is masked by the first tLOAD . The first conversion after the enable is then

1) Data based on characterization results over the whole temperature range, monitored in production. performed on any analog input. current on digital input pins degrades ADC accuracy especially if performed on a pin close to the analog input pins. Figure 93. ADC Accuracy Characteristics with amplifier disabled between the actual and the ideal transfer curves. transition and the first ideal one. transition and the last actual one. between actual steps and the ideal one.

Figure 94. ADC Accuracy Characteristics with amplifier enabled to 2 MHz. (if fCPU =8MHz. then SPEED=0, SLOW=1). between the actual and the ideal transfer curves. transition and the first ideal one. transition and the last actual one. between actual steps and the ideal one.

ADC CHARACTERISTICS (Cont’d) Notes: 1) Data based on characterization results over the whole temperature range, not tested in production. 2) For precise conversion results it is recommended to calibrate the amplifier at the following two points: – offset at V INmin = 0V – gain at full scale (for example VIN=250mV) 3) Monotonicity guaranteed if VIN increases or decreases in steps of min. 5mV. Symbol Parameter Conditions Min Typ Max Unit VDD(AMP) Amplifier operating voltage 4.5 5.5 V VIN Amplifier input voltage V DD =5V 62.5 430 mV VOFFSET Amplifier offset voltage 175 mV VSTEP Step size for monotonicity3) 5m V Linearity Output Voltage Response Linear Gain factor Amplified Analog input Gain2) 8 Vmax Output Linearity Max Voltage VINmax = 430mV, VDD =5V V Vmin Output Linearity Min Voltage V

14 PACKAGE CHARACTERISTICS

14.1 PACKAGE MECHANICAL DATA

Figure 95. 20-Pin Plastic Small Outline Package, 300-mil Width Figure 96. 20-Pin Plastic Dual In-Line Package, 300-mil Width

Table 21. THERMAL CHARACTERISTICS

  1. The power dissipation is obtained from the formula PD =PINT+P PORT where PINT is the chip internal power (IDD xVDD )

and PPORT is the port power dissipation determined by the user.

  1. The average chip-junction temperature can be obtained from the formula TJ = TA + PD x RthJA.

14.2 SOLDERING AND GLUEABILITY INFORMATION

Recommended soldering information given only as design guidelines. Figure 97. Recommended Wave Soldering Profile (with 37% Sn and 63% Pb) Figure 98. Recommended Reflow Soldering Oven Profile (MID JEDEC)

15 DEVICE CONFIGURATION AND ORDERING INFORMATION

Each device is available for production in a user programmable version (FLASH). FLASH devices are shipped to customers with a default content (FFh). This implies that FLASH devices have to be configured by the customer using the Option Bytes.

15.1 OPTION BYTES

The two option bytes allow the hardware configu- ration of the microcontroller to be selected. The option bytes can be accessed only in pro- gramming mode (for example using a standard ST7 programming tool). OPTION BYTE 0 OPT7 = Reserved, must always be 1. OPT6:4 = OSCRANGE[2:0] Oscillator range When the internal RC oscillator is not selected (Option OSC=1), these option bits select the range of the resonator oscillator current source or the ex- ternal clock source. Note: When the internal RC oscillator is selected, the OSCRANGE option bits must be kept at their default value in order to select the 256 clock cycle delay (see Section 7.5). OPT3:2 = SEC[1:0] Sector 0 size definition These option bits indicate the size of sector 0 ac- cording to the following table. OPT1 = FMP_R Read-out protection This option indicates if the FLASH program mem- ory and Data EEPROM is protected against pira- cy. The read-out protection blocks access to the program and data areas in any mode except user mode and IAP mode. Erasing the option bytes when the FMP_R option is selected will cause the whole memory to be erased first and the device can be reprogrammed. Refer to the ST7 Flash Programming Reference Manual and section 4.5 on page 14 for more details 0: Read-out protection off 1: Read-out protection on OPT0 = FMP_W FLASH write protection This option indicates if the FLASH program mem- ory is write protected. Warning: When this option is selected, the pro- gram memory (and the option bit itself) can never be erased or programmed again. 0: Write protection off 1: Write protection on OSCRANGE 210 Typ. frequency range with Resonator LP 1~2MHz 0 0 0 MP 2~4MHz 0 0 1 MS 4~8MHz 0 1 0 HS 8~16MHz 0 1 1 VLP 32.768kHz 1 0 0 External Clock source: CLKIN on OSC1 1 0 1 on PB4 1 1 1 Reserved 1 1 0 Sector 0 Size SEC1 SEC0 0.5k 00 1k 01 2k 10 4k 11 OPTION BYTE 0 OPTION BYTE 1 Res. OSCRANGE 2:0 SEC1 SEC0 FMP R FMP W PLL x4x8 PLL OFF PLL32 OFF OSC LVD1 LVD0 WDG SW WDG HALT Default Value 111111001 1 1 0 1111

OPT7 = PLLx4x8 PLL Factor selection. OPT5 = PLL32OFF 32MHz PLL disable. lected threshold as shown in Table 22. Table 22. LVD Threshold Configuration This option bit selects the watchdog type. Table 23. List of valid option combinations

15.2 DEVICE ORDERING INFORMATION

Table 24. Supported part numbers

15.3 DEVELOPMENT TOOLS

ers, emulators and gang programmers. Table 25. STMicroelectronics Tools Features

  1. In-Circuit Programming (ICP) interface for FLASH devices.

Table 26. Dedicated STMicroelectronics Development Tools

15.4 ST7 APPLICATION NOTES

IDENTIFICATION DESCRIPTION EXAMPLE DRIVERS AN 969 SCI COMMUNICATION BETWEEN ST7 AND PC AN 970 SPI COMMUNICATION BETWEEN ST7 AND EEPROM AN 971 I²C COMMUNICATING BETWEEN ST7 AND M24CXX EEPROM AN 972 ST7 SOFTWARE SPI MASTER COMMUNICATION AN 973 SCI SOFTWARE COMMUNICATION WITH A PC USING ST72251 16-BIT TIMER AN 974 REAL TIME CLOCK WITH ST7 TIMER OUTPUT COMPARE AN 976 DRIVING A BUZZER THROUGH ST7 TIMER PWM FUNCTION AN 979 DRIVING AN ANALOG KEYBOARD WITH THE ST7 ADC AN 980 ST7 KEYPAD DECODING TECHNIQUES, IMPLEMENTING WAKE-UP ON KEYSTROKE AN1017 USING THE ST7 UNIVERSAL SERIAL BUS MICROCONTROLLER AN1041 USING ST7 PWM SIGNAL TO GENERATE ANALOG OUTPUT (SINUSOID) AN1042 ST7 ROUTINE FOR I²C SLAVE MODE MANAGEMENT AN1044 MULTIPLE INTERRUPT SOURCES MANAGEMENT FOR ST7 MCUS AN1045 ST7 S/W IMPLEMENTATION OF I²C BUS MASTER AN1046 UART EMULATION SOFTWARE AN1047 MANAGING RECEPTION ERRORS WITH THE ST7 SCI PERIPHERALS AN1048 ST7 SOFTWARE LCD DRIVER AN1078 PWM DUTY CYCLE SWITCH IMPLEMENTING TRUE 0% & 100% DUTY CYCLE AN1082 DESCRIPTION OF THE ST72141 MOTOR CONTROL PERIPHERAL REGISTERS AN1083 ST72141 BLDC MOTOR CONTROL SOFTWARE AND FLOWCHART EXAMPLE AN1105 ST7 PCAN PERIPHERAL DRIVER AN1129 PERMANENT MAGNET DC MOTOR DRIVE. AN1130 AN INTRODUCTION TO SENSORLESS BRUSHLESS DC MOTOR DRIVE APPLICATIONS WITH THE ST72141 AN1148 USING THE ST7263 FOR DESIGNING A USB MOUSE AN1149 HANDLING SUSPEND MODE ON A USB MOUSE AN1180 USING THE ST7263 KIT TO IMPLEMENT A USB GAME PAD AN1276 BLDC MOTOR START ROUTINE FOR THE ST72141 MICROCONTROLLER AN1321 USING THE ST72141 MOTOR CONTROL MCU IN SENSOR MODE AN1325 USING THE ST7 USB LOW-SPEED FIRMWARE V4.X AN1445 USING THE ST7 SPI TO EMULATE A 16-BIT SLAVE AN1475 DEVELOPING AN ST7265X MASS STORAGE APPLICATION AN1504 STARTING A PWM SIGNAL DIRECTLY AT HIGH LEVEL USING THE ST7 16-BIT TIMER PRODUCT EVALUATION AN 910 PERFORMANCE BENCHMARKING AN 990 ST7 BENEFITS VERSUS INDUSTRY STANDARD AN1077 OVERVIEW OF ENHANCED CAN CONTROLLERS FOR ST7 AND ST9 MCUS AN1086 U435 CAN-DO SOLUTIONS FOR CAR MULTIPLEXING AN1150 BENCHMARK ST72 VS PC16 AN1151 PERFORMANCE COMPARISON BETWEEN ST72254 & PC16F876 AN1278 LIN (LOCAL INTERCONNECT NETWORK) SOLUTIONS PRODUCT MIGRATION AN1131 MIGRATING APPLICATIONS FROM ST72511/311/214/124 TO ST72521/321/324 AN1322 MIGRATING AN APPLICATION FROM ST7263 REV.B TO ST7263B AN1365 GUIDELINES FOR MIGRATING ST72C254 APPLICATION TO ST72F264 PRODUCT OPTIMIZATION

AN 982 USING ST7 WITH CERAMIC RESONATOR AN1014 HOW TO MINIMIZE THE ST7 POWER CONSUMPTION AN1015 SOFTWARE TECHNIQUES FOR IMPROVING MICROCONTROLLER EMC PERFORMANCE AN1040 MONITORING THE VBUS SIGNAL FOR USB SELF-POWERED DEVICES AN1070 ST7 CHECKSUM SELF-CHECKING CAPABILITY AN1324 CALIBRATING THE RC OSCILLATOR OF THE ST7FLITE0 MCU USING THE MAINS AN1477 EMULATED DATA EEPROM WITH XFLASH MEMORY AN1502 EMULATED DATA EEPROM WITH ST7 HDFLASH MEMORY AN1529 EXTENDING THE CURRENT & VOLTAGE CAPABILITY ON THE ST7265 VDDF SUPPLY AN1530 ACCURATE TIMEBASE FOR LOW-COST ST7 APPLICATIONS WITH INTERNAL RC OSCIL- LATOR PROGRAMMING AND TOOLS AN 978 KEY FEATURES OF THE STVD7 ST7 VISUAL DEBUG PACKAGE AN 983 KEY FEATURES OF THE COSMIC ST7 C-COMPILER PACKAGE AN 985 EXECUTING CODE IN ST7 RAM AN 986 USING THE INDIRECT ADDRESSING MODE WITH ST7 AN 987 ST7 SERIAL TEST CONTROLLER PROGRAMMING AN 988 STARTING WITH ST7 ASSEMBLY TOOL CHAIN AN 989 GETTING STARTED WITH THE ST7 HIWARE C TOOLCHAIN AN1039 ST7 MATH UTILITY ROUTINES AN1064 WRITING OPTIMIZED HIWARE C LANGUAGE FOR ST7 AN1071 HALF DUPLEX USB-TO-SERIAL BRIDGE USING THE ST72611 USB MICROCONTROLLER AN1106 TRANSLATING ASSEMBLY CODE FROM HC05 TO ST7 AN1179 PROGRAMMING ST7 FLASH MICROCONTROLLERS IN REMOTE ISP MODE (IN-SITU PRO- GRAMMING) AN1446 USING THE ST72521 EMULATOR TO DEBUG A ST72324 TARGET APPLICATION AN1478 PORTING AN ST7 PANTA PROJECT TO CODEWARRIOR IDE AN1527 DEVELOPING A USB SMARTCARD READER WITH ST7SCR AN1575 ON-BOARD PROGRAMMING METHODS FOR XFLASH AND HDFLASH ST7 MCUS IDENTIFICATION DESCRIPTION

16 IMPORTANT NOTES

16.1 EXECUTION OF BTJX INSTRUCTION

When testing the address $FF with the "BTJT" or "BTJF" instructions, the CPU may perform an incorrect operation when the rel- ative jump is negative and performs an ad- dress page change. To avoid this issue, including when using a C compiler, it is recommended to never use ad- dress $00FF as a variable (using the linker parameter for example).

16.2 ADC CONVERSION SPURIOUS RESULTS

Spurious conversions occur with a rate lower than 50 per m illion. Such conversions happen when the measured voltage is just between 2 consecutive digital values. Workaround A software filter should be implemented to remove erratic conversion results whenever they may cause unwanted consequences.

16.3 A/ D CONVERTER ACCURACY FOR FIRST

When the ADC is enabled after being pow- ered down (for example when waking up from HALT, ACTIVE-HALT or setting the ADON bit in the ADCCSR register), the first conversion (8-bit or 10-bit) accuracy does not meet the accuracy specified in the da- tasheet. Workaround In order to have the accuracy specified in the datasheet, the first conversion after a ADC switch-on has to be ignored.

17 SUMMARY OF CHANGES

Revision Main changes Date 2.0 Modified Caution to pin n°12 (SO20) or pin n°7 (DIP20) in Table 1, “Device Pin Description,” on page 7 Modified note 5 in section 4.4 on page 13 Added “and the device can be reprogrammed” in section 4.5.1 on page 14 Added note on RC oscillator in section 7 on page 23 (main features) and changed section 7.1 on page 23: removed reference to ST7LITE20 in RCCR table Changed Figure 13 on page 25 (CLKIN/2, OSC/2) Added note in section 7.4 on page 26 (external clock source paragraph) Added note in the description of AWUPR[7:0] bits in section 9.6.0.1 on page 45 Added text specifying that the watchdog counter is a free-running downcounter: Section 11.1.2 and section 11.1.3 on page 51 Added note in the description of OSC option bit and in Table 23, “List of valid option combi- nations,” on page 124 Changed section 13.7 on page 103 Changed section 13.3.1 on page 93: f CLKIN instead of fOSC Changed description of WDG HALT option bit (section 15.1 on page 123) Changed description of FMP_R option bit (section 15.1 on page 123) Changed Table 26, “Dedicated STMicroelectronics Development Tools,” on page 126 August-03

Notes: Information furnished is believed to be accurate and reliable. However, STMicroelectronics assumes no responsibility for the consequences of use of such information nor for any infringement of patents or other rights of third parties which may result from its use. No license is granted by implication or otherwise under any patent or patent rights of STMicroelectronics. Specifications mentioned in this publication are subject to change without notice. This publication supersedes and replaces all information previously supplied. STMicroelectronics products are not authorized for use as critical components in life support devices or systems without the express written approval of STMicroelectronics. The ST logo is a registered trademark of STMicroelectronics  2003 STMicroelectronics - All Rights Reserved. Purchase of I2C Components by STMicroelectronics conveys a license under the Philips I2C Patent. Rights to use these components in an I2C system is granted provided that the system conforms to the I2C Standard Specification as defined by Philips. STMicroelectronics Group of Companies Australia - Brazil - Canada - China - Finland - France - Germany - Hong Kong - India - Israel - Italy - Japan Malaysia - Malta - Morocco - Singapore - Spain - Sweden - Switzerland - United Kingdom - U.S.A. http://www.st.com