VRS540-4kB Flash, 128B RAM, 25~40MHz, 8-Bit MCU

Similar documents
VRS550-8kB Flash, 256B RAM, 25~40MHz, 8-Bit MCU VRS560-16kB Flash, 256B RAM, 40MHz, 8-Bit MCU

VRS570 32K Flash, 1kB RAM, 25~40MHz, 8-Bit MCU VRS580 64K Flash, 1kB RAM, 25~40MHz, 8-Bit MCU


Microprocessors 1. The 8051 Instruction Set. Microprocessors 1 1. Msc. Ivan A. Escobar Broitman

Rev. No. History Issue Date Remark

Microcontroller Intel [Instruction Set]

MCS -51 Programmer s Guide and Instruction Set

Embedded Controller Programming

ISSI. IS89C51 CMOS SINGLE CHIP 8-BIT MICROCONTROLLER with 4-Kbytes of FLASH ISSI IS89C51 NOVEMBER 1998 FEATURES GENERAL DESCRIPTION

8-bit Microcontroller with 8K Bytes In-System Programmable Flash AT89S52

EEE3410 Microcontroller Applications Department of Electrical Engineering Lecture 4 The 8051 Architecture

The Timers/Counters The Serial Interface The Interrupt System Reset P0.0-P0.7 P2.0-P2.7. Port 2 Drivers. Port 2 Latch

C51 Family. C51 Family Programmer s Guide and Instruction Set. Summary

8051 Overview and Instruction Set

Digital Blocks Semiconductor IP

Digital Blocks Semiconductor IP

Architecture & Instruction set of 8085 Microprocessor and 8051 Micro Controller

Memory organization Programming model - Program status word - register banks - Addressing modes - instruction set Programming examples.

UNIT 2 THE 8051 INSTRUCTION SET AND PROGRAMMING

8051 Core Specification

Digital Blocks Semiconductor IP

80C51 family programmer s guide and instruction set. 80C51 Family. PROGRAMMER S GUIDE AND INSTRUCTION SET Memory Organization. Philips Semiconductors

MASSEY UNIVERSITY PALMERSTON NORTH CAMPUS

SN8F5000 Family Instruction Set

8XC51RA RB RC Hardware Description

Q. Classify the instruction set of 8051 and list out the instructions in each type.

CS 320. Computer Architecture Core Architecture


Module Contents of the Module Hours COs

Programming of 8085 microprocessor and 8051 micro controller Study material

C51 Family. Architectural Overview of the C51 Family. Summary

INTEGRATED CIRCUITS DATA SHEET. P89C738; P89C739 8-bit microcontrollers Dec 15. Product specification File under Integrated Circuits, IC20

8051 Microcontroller

Microcontroller. Instruction set of 8051

UNIT THE 8051 INSTRUCTION SET AND PROGRAMMING

8-BIT MICROCONTROLLER

7.2.1 Timer 2 Capture LSB... 24

The Final Word on 8051 Microcontroller

MICROPROCESSORS AND MICROCONTROLLERS MATERIAL. Features of 8051:

Preliminary W77C32 8 BIT MICROCONTROLLER GENERAL DESCRIPTION FEATURES

UNIT IV MICROCONTROLLER

Instruction Set Of 8051

UNIT MICROCONTROLLER AND ITS PROGRAMMING

Preliminary W77E58 8 BIT MICROCONTROLLER. Table of Contents-- Publication Release Date: March Revision A1

DR bit RISC Microcontroller. Instructions set details ver 3.10

Three criteria in Choosing a Microcontroller

W77IE58 8-BIT MICROCONTROLLER. Table of Contents-- Publication Release Date: December Revision A2

EE6502- MICROPROCESSOR AND MICROCONTROLLER

Dodatak. Skup instrukcija

MEGAWIN MPC89L516X2. 8-bit micro-controller. Features

Programming Book Microcontroller Kit. Rev 3.0 January, Wichit Sirichote

8051 Microcontroller

W77LE58/W77L058A Data Sheet 8-BIT MICROCONTROLLER. Table of Contents- Publication Release Date: April 17, Revision A7

8051 MICROCONTROLLER

MCS-51 Serial Port A T 8 9 C 5 2 1

W77E058A Data Sheet 8-BIT MICROCONTROLLER. Table of Contents-

Y51 Microcontroller. Technical Manual

SM5964B 8-Bit Micro-controller 64KB with ISP Flash & 1KB RAM embedded

TUTORIAL. Donal Heffernan University of Limerick May Tutorial D.Heffernan 2000,

8051 microcontrollers

8XC151SA and 8XC151SB Hardware Description

CoE3DJ4 Digital Systems Design. Chapter 5: Serial Port Operation

Introduction To MCS-51

Dragonchip. Instruction Set Manual

8051 Microcontroller

TUTORIAL Assembly Language programming (2)

Legacy documentation refer to the Altium Wiki for current information. TSK51x MCU

Timers and interrupts

e-pg Pathshala Subject : Computer Science Paper: Embedded System Module: 8051 Architecture Module No: CS/ES/5 Quadrant 1 e-text

MODULE-1. Short Answer Questions

Microcontrollers can be considered as self-contained systems with a processor, memory and I/O ports.

Application Brief D-005

MICROPROCESSOR & MICROCONTROLLER

Mod-3: Interrupts,Timer operation,serial communication 1

INSTRUCCIONES ARITMETICAS ERROR! MARCADOR NO DEFINIDO.

MPC89E515A. 8-bit micro-controller

The Microcontroller. Lecture Set 3. Major Microcontroller Families. Example Microcontroller Families Cont. Example Microcontroller Families

DS89C420 Ultra High-Speed Microcontroller User s Guide

ULTRA-HIGH-SPEED FLASH MICROCONTROLLER USER S GUIDE

Question Bank Microprocessor and Microcontroller

SUMMER 13 EXAMINATION

Vidyalankar T.E. Sem. V [ETRX] Microprocessors and Microcontrollers I Prelim Question Paper Solution

Microcontroller and Applications

WINTER 14 EXAMINATION

Timer-1 can be run using the internal clock, fosc/12 (timer mode) or from any external source via pin T1 (P3.5) (Counter mode).

P89V52X2. 1. General description. 2. Features. 8-bit 80C51 low power 8 kb flash microcontroller with 256 B RAM, 192 B data EEPROM

8051 MICROCONTROLLER

Serial I-O for Dinesh K. Sharma Electrical Engineering Department I.I.T. Bombay Mumbai (version 14/10/07)

8-bit Microcontroller with 2/4-Kbyte Flash AT89LP2052 AT89LP4052

8051 Timers and Serial Port

8051 Serial Communication

AL8051S 8-BIT MICROCONTROLLER Application Notes


Assembly Language programming (2)

CPEG300 Embedded System Design. Lecture 6 Interrupt System

MICROPROCESSOR LABORATORY MANUAL

UNIT MICROCONTROLLER

ET355 Microprocessors Thursday 6:00 pm 10:20 pm

8051 Microcontrollers

SECTION 1: INTRODUCTION 5 SECTION 2: ORDERING INFORMATION 5 SECTION 3: ARCHITECTURE 5

Transcription:

VRS540-4kB Flash, 28B RAM, 25~40MHz, 8-Bit MCU 34 Ste Catherine Street West, Suite 900, Montreal, Quebec, Canada H3B H4 Tel: (54) 87-2447 http://www.goalsemi.com

P.3 P.2 XTAL NC P0./AD VRS540 Overview The VRS540 is a low cost 8-bit microcontroller based on the standard 80C5 microcontroller family architecture. It s pin-to-pin compatible and a drop-in replacement for most 805 MCUs. It has 4kB of Flash memory and 28 bytes of RAM. The VRS540 includes a UART, three 6-bit timers, a Watchdog timer and power down features. This device is cost effective and aimed for applications requiring small amounts of program and data memories. The VRS540 is available in PLCC-44, QFP-44 and DIP- 40 packages in the industrial temperature range. The Flash memory can be programmed using programmers available from Goal Semiconductor or other 3 rd party commercial programmers. FIGURE : VRS540 FUNCTIONAL DIAGRAM Feature Set General 80C5/80C52 pin compatible 2 clock periods per machine cycle 4kB on-chip Flash memory 28 bytes on-chip data RAM 32 I/O lines: P0-P3 = 8-bit Full duplex serial port (UART) 3, 6-bit Timers/Counters Watch Dog Timer 8-bit Unsigned Division / Multiply BCD arithmetic Direct and Indirect Addressing Two levels of interrupt priority and nested interrupts Power saving modes Code protection function Operates at a clock frequency of up to 25MHz Low EMI (inhibit ALE) Programming voltage: 2V Industrial Temperature range (-40 C to +85 C) 5V and 3V versions available (see Ordering information.) FIGURE 2: VRS540 PLCC AND QFP PINOUT DIAGRAMS 805 PROCESSOR ADDRESS/ DATA BUS P.4 T2EX/P. T2/P.0 NC VDD P0.0/AD0 P0.2/AD2 P0.3/AD3 4k FLASH 28 Bytes of RAM UART PORT 0 PORT PORT 2 8 8 8 P.5 P.6 P.7 RESET RXD/P3.0 NC TXD/P3. #INT0/P3.2 #INT/P3.3 T0/P3.4 T/P3.5 7 6 VRS540 PLCC-44 40 39 7 8 28 29 P0.4/AD4 P0.5/AD5 P0.6/AD6 P0.7/AD7 #EA NC ALE #PSEN P2.7/A5 P2.6/A4 P2.5/A3 2 INTERRUPT INPUTS TIMER 0 PORT 3 8 #WR/P3.6 #RD/P3.7 XTAL2 VSS P2.0/A8 P2./A9 P2.2/A0 P2.3/A P2.4/A2 TIMER TIMER 2 POWER CONTROL P0.4/AD4 P0.5/AD5 P0.6/AD6 P0.7/AD7 #EA NC ALE #PSEN P2.7/A5 P2.6/A4 P2.5/A3 RESET WATCHDOG TIMER P0.3/AD3 P0.2/AD2 P0./AD P0.0/AD0 VDD NC T2/P.0 T2EX/P. P.2 P.3 P.4 33 34 44 VRS540 QFP-44 23 22 2 P2.4/A2 P2.3/A P2.2/A0 P2./A9 P2.0/A8 NC VSS XTAL XTAL2 #RD/P3.7 #WR/P3.6 P.5 P.6 P.7 RESET RXD/P3.0 NC TXD/P3. #INT0/P3.2 #INT/P3.3 T0/P3.4 T/P3.5 34 Ste Catherine Street West, Suite 900, Montreal, Quebec, Canada H3B H4 Tel: (54) 87-2447 http://www.goalsemi.com 2

Pin Descriptions for QFP-44 TABLE : PIN DESCRIPTIONS FOR QFP-44/ QFP - 44 Name I/O Function P.5 I/O Bit 5 of Port 2 P.6 I/O Bit 6 of Port 3 P.7 I/O Bit 7 of Port 4 RES I Reset 5 RXD I Receive Data P3.0 I/O Bit 0 of Port 3 6 NC - No Connect 7 TXD O Transmit Data & P3. I/O Bit of Port 3 8 #INT0 I External Interrupt 0 P3.2 I/O Bit 2 of Port 3 9 #INT I External Interrupt P3.3 I/O Bit 3 of Port 3 0 T0 I Timer 0 P3.4 I/O Bit 4 of Port 3 T I Timer & 3 P3.5 I/O Bit 5 of Port 2 #WR O Ext. Memory Write P3.6 I/O Bit 6 of Port 3 3 #RD O Ext. Memory Read P3.7 I/O Bit 7 of Port 3 4 XTAL2 O Oscillator/Crystal Output 5 XTAL I Oscillator/Crystal In 6 VSS - Ground 7 NC - No Connect 8 P2.0 I/O Bit 0 of Port 2 A8 O Bit 8 of External Memory Address 9 P2. I/O Bit of Port 2 A9 O Bit 9 of External Memory Address 20 P2.2 I/O Bit 2 of Port 2 A0 O Bit 0 of External Memory Address 2 P2.3 I/O Bit 3 of Port 2 & A O Bit of External Memory Address 22 P2.4 I/O Bit 4 of Port 2 A2 O Bit 2 of External Memory Address 23 P2.5 I/O Bit 5 of Port 2 A3 O Bit 3 of External Memory Address QFP - 44 Name I/O Function 24 P2.6 I/O Bit 6 of Port 2 A4 O Bit 4 of External Memory Address 25 P2.7 I/O Bit 7 of Port 2 A5 O Bit 5 of External Memory Address 26 #PSEN O Program Store Enable 27 ALE O Address Latch Enable 28 NC - No Connect 29 #EA I External Access 30 P0.7 I/O Bit 7 Of Port 0 AD7 I/O Data/Address Bit 7 of External Memory 3 P0.6 I/O Bit 6 of Port 0 AD6 I/O Data/Address Bit 6 of External Memory 32 P0.5 I/O Bit 5 of Port 0 AD5 I/O Data/Address Bit 5 of External Memory 33 P0.4 I/O Bit 4 of Port 0 AD4 I/O Data/Address Bit 4 of External Memory 34 P0.3 I/O Bit 3 Of Port 0 AD3 I/O Data/Address Bit 3 of External Memory 35 P0.2 I/O Bit 2 of Port 0 AD2 I/O Data/Address Bit 2 of External Memory 36 P0. I/O Bit of Port 0 & Data AD I/O Address Bit of External Memory 37 P0.0 I/O Bit 0 Of Port 0 & Data AD0 I/O Address Bit 0 of External Memory 38 VDD - VCC 39 NC - No Connect 40 T2 I Timer 2 Clock Out P.0 I/O Bit 0 of Port 4 T2EX I Timer 2 Control P. I/O Bit of Port 42 P.2 I/O Bit 2 of Port 43 P.3 I/O Bit 3 of Port 44 P.4 I/O Bit 4 of Port P0.4/AD4 P0.5/AD5 P0.6/AD6 P0.7/AD7 #EA NC ALE #PSEN P2.7/A5 P2.6/A4 P2.5/A3 P0.3/AD3 P0.2/AD2 P0./AD P0.0/AD0 VDD NC T2/P.0 T2EX/P. P.2 P.3 P.4 33 34 44 VRS540 QFP-44 23 22 2 P2.4/A2 P2.3/A P2.2/A0 P2./A9 P2.0/A8 NC VSS XTAL XTAL2 #RD/P3.7 #WR/P3.6 P.5 P.6 P.7 RESET RXD/P3.0 NC TXD/P3. #INT0/P3.2 #INT/P3.3 T0/P3.4 T/P3.5 34 Ste Catherine Street West, Suite 900, Montreal, Quebec, Canada H3B H4 Tel: (54) 87-2447 http://www.goalsemi.com 3

P.3 P.2 XTAL NC P0./AD VRS540 Pin Descriptions for PLCC-44 TABLE 2: PIN DESCRIPTIONS FOR PLCC-44 PLCC - 44 Name I/O Function NC - No Connect 2 T2 I Timer 2 Clock Out P.0 I/O Bit 0 of Port 3 T2EX I Timer 2 Control P. I/O Bit of Port 4 P.2 I/O Bit 2 of Port 5 P.3 I/O Bit 3 of Port 6 P.4 I/O Bit 4 of Port 7 P.5 I/O Bit 5 of Port 8 P.6 I/O Bit 6 of Port 9 P.7 I/O Bit 7 of Port 0 RES I Reset RXD I Receive Data P3.0 I/O Bit 0 of Port 3 2 NC - No Connect 3 TXD O Transmit Data & P3. I/O Bit of Port 3 4 #INT0 I External Interrupt 0 P3.2 I/O Bit 2 of Port 3 5 #INT I External Interrupt P3.3 I/O Bit 3 of Port 3 6 T0 I Timer 0 P3.4 I/O Bit 4 of Port 3 7 T I Timer & 3 P3.5 I/O Bit 5 of Port 8 #WR O Ext. Memory Write P3.6 I/O Bit 6 of Port 3 9 #RD O Ext. Memory Read P3.7 I/O Bit 7 of Port 3 20 XTAL2 O Oscillator/Crystal Output 2 XTAL I Oscillator/Crystal In 22 VSS - Ground 23 NC - No Connect PLCC - 44 Name I/O Function 24 P2.0 I/O Bit 0 of Port 2 A8 O Bit 8 of External Memory Address 25 P2. I/O Bit of Port 2 A9 O Bit 9 of External Memory Address 26 P2.2 I/O Bit 2 of Port 2 A0 O Bit 0 of External Memory Address 27 P2.3 I/O Bit 3 of Port 2 & A O Bit of External Memory Address 28 P2.4 I/O Bit 4 of Port 2 A2 O Bit 2 of External Memory Address 29 P2.5 I/O Bit 5 of Port 2 A3 O Bit 3 of External Memory Address 30 P2.6 I/O Bit 6 of Port 2 A4 O Bit 4 of External Memory Address 3 P2.7 I/O Bit 7 of Port 2 A5 O Bit 5 of External Memory Address 32 #PSEN O Program Store Enable 33 ALE O Address Latch Enable 34 NC - No Connect 35 #EA I External Access P0.7 I/O Bit 7 Of Port 0 36 Data/Address Bit 7 of External AD7 I/O Memory P0.6 I/O Bit 6 of Port 0 37 Data/Address Bit 6 of External AD6 I/O Memory P0.5 I/O Bit 5 of Port 0 38 Data/Address Bit 5 of External AD5 I/O Memory P0.4 I/O Bit 4 of Port 0 39 Data/Address Bit 4 of External AD4 I/O Memory P0.3 I/O Bit 3 Of Port 0 40 Data/Address Bit 3 of External AD3 I/O Memory P0.2 I/O Bit 2 of Port 0 4 Data/Address Bit 2 of External AD2 I/O Memory 42 P0. I/O Bit of Port 0 & Data AD I/O Address Bit of External Memory 43 P0.0 I/O Bit 0 Of Port 0 & Data AD0 I/O Address Bit 0 of External Memory 44 VDD - VCC P.4 T2EX/P. T2/P.0 NC VDD P0.0/AD0 P0.2/AD2 P0.3/AD3 P.5 P.6 P.7 RESET RXD/P3.0 NC TXD/P3. #INT0/P3.2 #INT/P3.3 T0/P3.4 T/P3.5 7 6 VRS540 PLCC-44 40 39 7 8 28 29 P0.4/AD4 P0.5/AD5 P0.6/AD6 P0.7/AD7 #EA NC ALE #PSEN P2.7/A5 P2.6/A4 P2.5/A3 #WR/P3.6 #RD/P3.7 XTAL2 VSS P2.0/A8 P2./A9 P2.2/A0 P2.3/A P2.4/A2 34 Ste Catherine Street West, Suite 900, Montreal, Quebec, Canada H3B H4 Tel: (54) 87-2447 http://www.goalsemi.com 4

VRS540 DIP40 Pin Descriptions TABLE 3: VRS540 IN DESCRIPTIONS FOR DIP40 PACKAGE DIP40 Name I/O Function T2 I Timer 2 Clock Out P.0 I/O Bit 0 of Port 2 T2EX I Timer 2 Control P. I/O Bit of Port 3 P.2 I/O Bit 2 of Port 4 P.3 I/O Bit 3 of Port 5 P.4 I/O Bit 4 of Port 6 P.5 I/O Bit 5 of Port 7 P.6 I/O Bit 6 of Port 8 P.7 I/O Bit 7 of Port 9 RESET I Reset 0 RXD I Receive Data P3.0 I/O Bit 0 of Port 3 TXD O Transmit Data & P3. I/O Bit of Port 3 2 #INT0 I External Interrupt 0 P3.2 I/O Bit 2 of Port 3 3 #INT I External Interrupt P3.3 I/O Bit 3 of Port 3 4 T0 I Timer 0 P3.4 I/O Bit 4 of Port 3 5 T I Timer & 3 P3.5 I/O Bit 5 of Port 6 #WR O Ext. Memory Write P3.6 I/O Bit 6 of Port 3 7 #RD O Ext. Memory Read P3.7 I/O Bit 7 of Port 3 8 XTAL2 O Oscillator/Crystal Output 9 XTAL I Oscillator/Crystal In 20 VSS - Ground T2 / P.0 T2EX / P. P.2 P.3 P.4 P.5 P.6 P.7 RESET RXD / P3.0 TXD / P3. #INT0 / P3.2 #INT / P3.3 T0 / P3.4 T / P3.5 #WR / P3.6 #RD / P3.7 XTAL2 XTAL VSS 2 3 4 5 6 7 8 9 0 2 3 4 5 6 7 8 9 20 VRS540-DAI40 40 39 38 37 36 35 34 33 32 3 30 29 28 27 26 25 24 23 22 2 VDD P0.0 / AD0 P0. / AD P0.2 / AD2 P0.3 / AD3 P0.4 / AD4 P0.5 / AD5 P0.6 / AD6 P0.7 / AD7 #EA / VPP ALE PSEN P2.7 / A5 P2.6 / A4 P2.5 / A3 P2.4 / A2 P2.3 / A P2.2 / A0 P2. / A9 P2.0 / A8 DIP40 Name I/O Function 2 P2.0 I/O Bit 0 of Port 2 A8 O Bit 8 of External Memory Address 22 P2. I/O Bit of Port 2 A9 O Bit 9 of External Memory Address 23 P2.2 I/O Bit 2 of Port 2 A0 O Bit 0 of External Memory Address 24 P2.3 I/O Bit 3 of Port 2 & A O Bit of External Memory Address 25 P2.4 I/O Bit 4 of Port 2 A2 O Bit 2 of External Memory Address 26 P2.5 I/O Bit 5 of Port 2 A3 O Bit 3 of External Memory Address 27 P2.6 I/O Bit 6 of Port 2 A4 O Bit 4 of External Memory Address 28 P2.7 I/O Bit 7 of Port 2 A5 O Bit 5 of External Memory Address 29 #PSEN O Program Store Enable 30 ALE O Address Latch Enable 3 #EA / External Access I VPP Flash programming voltage input P0.7 I/O Bit 7 Of Port 0 32 Data/Address Bit 7 of External AD7 I/O Memory P0.6 I/O Bit 6 of Port 0 33 Data/Address Bit 6 of External AD6 I/O Memory P0.5 I/O Bit 5 of Port 0 34 Data/Address Bit 5 of External AD5 I/O Memory P0.4 I/O Bit 4 of Port 0 35 Data/Address Bit 4 of External AD4 I/O Memory P0.3 I/O Bit 3 Of Port 0 36 Data/Address Bit 3 of External AD3 I/O Memory P0.2 I/O Bit 2 of Port 0 37 Data/Address Bit 2 of External AD2 I/O Memory 38 P0. I/O Bit of Port 0 & Data AD I/O Address Bit of External Memory 39 P0.0 I/O Bit 0 Of Port 0 & Data AD0 I/O Address Bit 0 of External Memory 40 VDD - Supply input 34 Ste Catherine Street West, Suite 900, Montreal, Quebec, Canada H3B H4 Tel: (54) 87-2447 http://www.goalsemi.com 5

Instruction Set The following two tables describe the instruction set of the VRS540. The instructions are binary code compatible and perform the same functions as the industry standard 805 ones. TABLE 4: LEGEND FOR INSTRUCTION SET TABLE Symbol Function A Accumulator Rn Register R0-R7 Direct Internal register address @Ri Internal register pointed to by R0 or R (except MOVX) rel Two's complement offset byte bit Direct bit address #data 8-bit constant #data 6 6-bit constant addr 6 6-bit destination address addr -bit destination address TABLE 5: VRS540 INSTRUCTION SET Mnemonic Description Size (bytes) Instr. Cycles Arithmetic instructions ADD A, Rn Add register to A ADD A, direct Add direct byte to A 2 ADD A, @Ri Add data memory to A ADD A, #data Add immediate to A 2 ADDC A, Rn Add register to A with carry ADDC A, direct Add direct byte to A with carry 2 ADDC A, @Ri Add data memory to A with carry ADDC A, #data Add immediate to A with carry 2 SUBB A, Rn Subtract register from A with borrow SUBB A, direct Subtract direct byte from A with borrow 2 SUBB A, @Ri Subtract data mem from A with borrow SUBB A, #data Subtract immediate from A with borrow 2 INC A Increment A INC Rn Increment register INC direct Increment direct byte 2 INC @Ri Increment data memory DEC A Decrement A DEC Rn Decrement register DEC direct Decrement direct byte 2 DEC @Ri Decrement data memory INC DPTR Increment data pointer 2 MUL AB Multiply A by B 4 DIV AB Divide A by B 4 DA A Decimal adjust A Logical Instructions ANL A, Rn AND register to A ANL A, direct AND direct byte to A 2 ANL A, @Ri AND data memory to A ANL A, #data AND immediate to A 2 ANL direct, A AND A to direct byte 2 ANL direct, #data AND immediate data to direct byte 3 2 ORL A, Rn OR register to A ORL A, direct OR direct byte to A 2 ORL A, @Ri OR data memory to A ORL A, #data OR immediate to A 2 ORL direct, A OR A to direct byte 2 ORL direct, #data OR immediate data to direct byte 3 2 XRL A, Rn Exclusive-OR register to A XRL A, direct Exclusive-OR direct byte to A 2 XRL A, @Ri Exclusive-OR data memory to A XRL A, #data Exclusive-OR immediate to A 2 XRL direct, A Exclusive-OR A to direct byte 2 XRL direct, #data Exclusive-OR immediate to direct byte 3 2 CLR A Clear A CPL A Compliment A SWAP A Swap nibbles of A RL A Rotate A left RLC A Rotate A left through carry RR A Rotate A right RRC A Rotate A right through carry Mnemonic Description Size (bytes) Instr. Cycles Boolean Instruction CLR C Clear Carry bit CLR bit Clear bit 2 SETB C Set Carry bit to SETB bit Set bit to 2 CPL C Complement Carry bit CPL bit Complement bit 2 ANL C,bit Logical AND between Carry and bit 2 2 ANL C,#bit Logical AND between Carry and not bit 2 2 ORL C,bit Logical ORL between Carry and bit 2 2 ORL C,#bit Logical ORL between Carry and not bit 2 2 MOV C,bit Copy bit value into Carry 2 MOV bit,c Copy Carry value into Bit 2 2 Data Transfer Instructions MOV A, Rn Move register to A MOV A, direct Move direct byte to A 2 MOV A, @Ri Move data memory to A MOV A, #data Move immediate to A 2 MOV Rn, A Move A to register MOV Rn, direct Move direct byte to register 2 2 MOV Rn, #data Move immediate to register 2 MOV direct, A Move A to direct byte 2 MOV direct, Rn Move register to direct byte 2 2 MOV direct, direct Move direct byte to direct byte 3 2 MOV direct, @Ri Move data memory to direct byte 2 2 MOV direct, #data Move immediate to direct byte 3 2 MOV @Ri, A Move A to data memory MOV @Ri, direct Move direct byte to data memory 2 2 MOV @Ri, #data Move immediate to data memory 2 MOV DPTR, #data Move immediate to data pointer 3 2 MOVC A, @A+DPTR Move code byte relative DPTR to A 2 MOVC A, @A+PC Move code byte relative PC to A 2 MOVX A, @Ri Move external data (A8) to A 2 MOVX A, @DPTR Move external data (A6) to A 2 MOVX @Ri, A Move A to external data (A8) 2 MOVX @DPTR, A Move A to external data (A6) 2 PUSH direct Push direct byte onto stack 2 2 POP direct Pop direct byte from stack 2 2 XCH A, Rn Exchange A and register XCH A, direct Exchange A and direct byte 2 XCH A, @Ri Exchange A and data memory XCHD A, @Ri Exchange A and data memory nibble Branching Instructions ACALL addr Absolute call to subroutine 2 2 LCALL addr 6 Long call to subroutine 3 2 RET Return from subroutine 2 RETI Return from interrupt 2 AJMP addr Absolute jump unconditional 2 2 LJMP addr 6 Long jump unconditional 3 2 SJMP rel Short jump (relative address) 2 2 JC rel Jump on carry = 2 2 JNC rel Jump on carry = 0 2 2 JB bit, rel Jump on direct bit = 3 2 JNB bit, rel Jump on direct bit = 0 3 2 JBC bit, rel Jump on direct bit = and clear 3 2 JMP @A+DPTR Jump indirect relative DPTR 2 JZ rel Jump on accumulator = 0 2 2 JNZ rel Jump on accumulator = 0 2 2 CJNE A, direct, rel Compare A, direct JNE relative 3 2 CJNE A, #d, rel Compare A, immediate JNE relative 3 2 CJNE Rn, #d, rel Compare reg, immediate JNE relative 3 2 CJNE @Ri, #d, rel Compare ind, immediate JNE relative 3 2 DJNZ Rn, rel Decrement register, JNZ relative 2 2 DJNZ direct, rel Decrement direct byte, JNZ relative 3 2 Miscellaneous Instruction NOP No operation Rn: Any of the register R0 to R7 @Ri: Indirect addressing using Register R0 or R #data: immediate Data provided with Instruction #data6: Immediate data included with instruction bit: address at the bit level rel: relative address to Program counter from +27 to 28 Addr: -bit address range Addr6: 6-bit address range #d: Immediate Data supplied with instruction 34 Ste Catherine Street West, Suite 900, Montreal, Quebec, Canada H3B H4 Tel: (54) 87-2447 http://www.goalsemi.com 6

Special Function Registers (SFR) Addresses 80h to FFh of the SFR address space can be accessed in direct addressing mode only. The following table lists the VRS540 Special Function Registers. TABLE 6: SPECIAL FUNCTION REGISTERS (SFR) SFR SFR Register Adrs Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit Bit 0 Reset Value P0 80h - - - - - - - - SP 8h - - - - - - - - DPL 82h - - - - - - - - DPH 83h - - - - - - - - Reserved 84h - - - - - - - - PCON 87h SMOD - - - GF GF0 PDOWN IDLE 00000000b TCON 88h TF TR TF0 TR0 IE IT IE0 IT0 00000000b TMOD 89h GATE C/T M. M0. GATE0 C/T0 M.0 M0.0 00000000b TL0 8Ah - - - - - - - - TL 8Bh - - - - - - - - TH0 8Ch - - - - - - - - TH 8Dh - - - - - - - - P 90h - - - - - - - - SCON 98h SM0 SM SM2 REN TB8 RB8 TI RI 00000000b SBUF 99h - - - - - - - - WDTCON 9Fh WDTE - WDCLR - - WDPS2 WDPS WDPS0 0*0**000b P2 A0h - - - - - - - - IE A8h EA - ET2 ES ET EX ET0 EX0 00000000b P3 B0h - - - - - - - - IP B8h - - PT2 PS PT PX PT0 PX0 00000000b SYSCON BFh WDRESET - - - - ALEI 0*****00b T2CON C8h TF2 EXF2 RCLK TCLK EXEN2 TR2 C/T2 CP/RL2 00000000b RCAP2L CAh - - - - - - - - 00000000b RCAP2H CBh - - - - - - - - 00000000b TL2 CCh - - - - - - - - 00000000b TH2 CDh 00000000b PSW D0h CY AC F0 RS RS0 OV - P 00000000b ACC E0h - - - - - - - - B F0h - - - - - - - - 34 Ste Catherine Street West, Suite 900, Montreal, Quebec, Canada H3B H4 Tel: (54) 87-2447 http://www.goalsemi.com 7

Program Memory Structure Program Memory The VRS540 includes 4k of on-chip Flash that can be used as general program memory. FIGURE 3: VRS540 INTERNAL PROGRAM MEMORY FFFh 0000h VRS540 Flash Memory (4k Bytes) Program Status Word Register The register below contains the program status flags. These flags may be read or written to by the user. TABLE 7: PROGRAM STATUS WORD REGISTER (PSW) - SFR DOH 7 6 5 4 3 2 0 CY AC F0 RS RS0 OV - P FIGURE 4: VRS540 DATA MEMORY 7F 00 28 bytes (Can be accessed in indirect and direct addressing mode) FF SFR (Can only be accessed in direct addressing mode) Lower 28 bytes (00h to 7Fh, Bank 0 & Bank ) The lower 28 bytes of data memory (from 00h to 7Fh) can be summarized in the following points: Address range 00h to 7Fh can be accessed in direct and indirect addressing modes. Address range 00h to Fh includes R0-R7 registers area. Address range 20h to 2Fh is bit addressable. Address range 30h to 7Fh is not bit addressable and can be used as general-purpose storage.. FIGURE 5: VRS540 INTERNAL RAM STRUCTURE FFh 80 Bit Mnemonic Description 7 CY Carry Bit 6 AC Auxiliary Carry Bit from bit 3 to 4. 5 F0 User definer flag 4 RS R0-R7 Registers bank select bit 0 3 RS0 R0-R7 Registers bank select bit 2 OV Overflow flag - - 0 P Parity flag 7Fh 30h 2Fh DPH DPL SP P0 87 86 80 Bytes of General Purpose RAM 7F 7E 7D 7C 7B 7A 79 78 SFR Area Direct or Bit Access Only 85 84 83 82 8 80 80h 77 76 75 74 73 72 7 70 RS RS0 Active Bank Address 0 0 0 00h-07h 0 08h-0Fh 0 2 0h-7h 3 8-Fh Data Pointer 20h 8h 0h 08h 00h 0F 0E 0D 0C 0B 0A 09 08 07 06 05 04 03 02 0 00 R7 - Registers Bank 3 R0 R7 - Registers Bank 2 R0 R7 - Registers Bank R0 R7 - Registers Bank 0 R0 The VRS540 has one 6-bit data pointer. The DPTR is accessed through two SFR addresses: DPL located at address 82h and DPH located at address 83h. Data Memory The VRS540 has a total of 28 Bytes of RAM memory, which is configured like the internal memory structure of a standard 805. 34 Ste Catherine Street West, Suite 900, Montreal, Quebec, Canada H3B H4 Tel: (54) 87-2447 http://www.goalsemi.com 8

Description of Peripherals System Control Register The register represented in the following table is used for system control. The WDRESET bit (7) indicates if the system has been reset due to the overflow of the Watch Dog Timer. The bit 0 of the SYSCON register is the ALE output inhibit bit. Setting this bit to will inhibit the Fosc/6 clock signal output to the ALE pin. TABLE 8: SYSTEM CONTROL REGISTER (SYSCON) SFR BFH 7 6 5 4 3 2 0 WDRESET Unused XRAME ALEI Bit Mnemonic Description 7 WDRESET This is the Watch Dog Timer reset bit. It will be set to when the reset signal generated by WDT overflows. 6 Unused - 5 Unused - 4 Unused - 3 Unused - 2 Unused - Unused - 0 ALEI ALE output inhibit bit, which is used to reduce EMI. These power saving modes are controlled by the PDOWN and IDLE bits of the PCON register at address 87h. TABLE 9: POWER CONTROL REGISTER (PCON) - SFR 87H 7 6 5 4 3 2 0 Unused RAM RAM0 Bit Mnemonic Description 7 SMOD : Double the baud rate of the serial port frequency that was generated by Timer. 0: Normal serial port baud rate generated by Timer. 6 5 4 3 GF General Purpose Flag 2 GF0 General Purpose Flag PDOWN Power down mode control bit 0 IDLE Idle mode control bit Power Control Register The VRS540 provides two power saving modes: Idle and Power Down. These two modes serve to reduce the power consumption of the device. In Idle mode, the processor is stopped but the oscillator is still running. The content of the RAM, I/O state and SFR registers are maintained. Timer operation is maintained, as well as the external interrupts. This mode is useful for applications in which stopping the processor to save power is required. The processor will be woken up when an external event, triggering an interrupt, occurs. In Power Down mode, the oscillator of the VRS540 is stopped. This means that all the peripherals are disabled. The content of the RAM and the SFR registers, however, is maintained. The minimum VCC in Power Down mode is 2V. 34 Ste Catherine Street West, Suite 900, Montreal, Quebec, Canada H3B H4 Tel: (54) 87-2447 http://www.goalsemi.com 9

Input/Output Ports The VRS540 has a total of 32 bi-directional I/O lines grouped in four 8-bit I/O ports. These I/Os can be individually configured as input or output. Except for the P0 I/Os, which are the open drain type, each I/O is made of a transistor connected to ground and a weak pull-up resistor. Writing a 0 in a given I/O port bit register will activate the transistor connected to ground, this will bring the I/O to a LOW level. FIGURE 6: INTERNAL STRUCTURE OF ONE OF THE FOUR I/O PORT LINES Read Register Internal Bus Write to Register Q D Flip-Flop Q Output Stage IC Pin Writing a into a given I/O port bit register de-activates the transistor between the pin and ground. In this case the pull-up resistor will bring the corresponding pin to a HIGH level. To use a given I/O as an input, one must write a into its associated port register bit. By default, upon reset all the I/Os are configured as input. General Structure of an I/O Port The following elements establish the link between the core unit and the pins of the microcontroller: Special Function Register (same name as port) Output Stage Amplifier (the structure of this element varies with its auxiliary function) Read Pin Structure of the P, P2, P3 The following figure gives a general idea of the structure P, P2 and P3 ports. Note that the figure below does not show the intermediary logic that connects the output of the register and the output stage together because this logic varies with the auxiliary function of each port. FIGURE 7: GENERAL STRUCTURE OF THE OUTPUT STAGE OF P, P2 AND P3 Read Register From the next figure, one can see that the D flip-flop stores the value received from the internal bus after receiving a write signal from the core. Also, note that the Q output of the flip-flop can be linked to the internal bus by executing a read instruction. This is how one would read the content of the register. It is also possible to link the value of the pin to the internal bus. This is done by the read pin instruction. In short, the user may read the value of the register or the pin. Internal Bus Write to Register Q D Flip-Flop Q Vcc Pull-up Network X IC Pin Read Pin Each line may be used independently as a logical input or output. When used as an input, as mentioned earlier, the corresponding port register bit must be high. 34 Ste Catherine Street West, Suite 900, Montreal, Quebec, Canada H3B H4 Tel: (54) 87-2447 http://www.goalsemi.com 0

Structure of Port 0 The internal structure of P0 is shown below. The auxiliary function of this port requires a particular logic. As opposed to the other ports, P0 is truly bi-directional. In other words, when used as an input, it is considered to be in a floating logical state (high impedance state). This arises from the absence of the internal pull-up resistance. The pull-up resistance is actually replaced by a transistor that is only used when the port functions to access external memory/data bus (EA=0). Port P0 and P2 as Address and Data Bus The output stage may receive data from two sources The outputs of register P0 or the bus address itself multiplexed with the data bus for P0. The outputs of the P2 register or the high part (A8/A5) of the bus address for the P2 port. When used as an I/O port, P0 acts as an open drain port and the use of an external pull-up resistor is likely to be required for most applications. FIGURE 9: P2 PORT STRUCTURE Read Register Address Vcc FIGURE 8: PORT P0 S PARTICULAR STRUCTURE Pull-up Network Internal Bus Q D Flip-Flop IC Pin Read Register Address A0/A7 Control Write to Register Q X Control Vcc Read Pin Internal Bus Write to Register Read Pin Q D Flip-Flop Q X IC Pin When the ports are used as an address or data bus, the special function registers P0 and P2 are disconnected from the output stage. The 8-bits of the P0 register are forced to and the content of the P2 register remains constant. When P0 is used as an external memory bus input (for a MOVX instruction, for example), the outputs of the register are automatically forced to. Auxiliary Port Functions The port I/O pins are shared with the Timer 2 EX and T2 inputs as shown below: Pin Mnemonic Function P.0 T2 Timer 2 counter input P. T2EX Timer2 Auxiliary input P.2 P.3 P.4 P.5 P.6 P.7 34 Ste Catherine Street West, Suite 900, Montreal, Quebec, Canada H3B H4 Tel: (54) 87-2447 http://www.goalsemi.com

Auxiliary P3 Port Functions The Port 3 I/O pins are shared with the UART interface, INT0 and INT interrupts, Timer 0 and Timer inputs and finally the #WR and #RD lines when external memory access is performed. FIGURE 0: P3 PORT STRUCTURE Read Register Internal Bus Write to Register Q D Flip-Flop Q Auxiliary Function: Output Vcc X IC Pin Software Particularities Concerning the Ports Some instructions allow the user to read the logic state of the output pin, while others allow the user to read the content of the associated port register. These instructions are called read-modify-write instructions. A list of these instructions may be found in the table below. Upon execution of these instructions, the content of the port register (at least -bit) is modified. The other read instructions take the present state of the input into account. For example, the instruction ANL P3, #0h obtains the value in the P3 register; performs the desired logic operation with the constant 0h; and recopies the result into the P3 register. When users want to take the present state of the inputs into account, they must first read these states and perform an AND operation between the reading and the constant. Read Pin Auxiliary Function: Input MOV A, P3; State of the inputs in the accumulator ANL A, #0; AND operation between P3 and 0h The following table describes the auxiliary function of the port 3 I/O pins. TABLE 0: P3 AUXILIARY FUNCTION TABLE Pin Mnemonic Function P3.0 RXD Serial Port: Receive data in asynchronous mode. Input and output data in synchronous mode. P3. TXD Serial Port: Transmit data in asynchronous mode. Output clock value in synchronous mode. P3.2 INT0 External Interrupt 0 Timer 0 Control Input P3.3 INT External Interrupt Timer Control Input P3.4 T0 Timer 0 Counter Input P3.5 T Timer Counter Input P3.6 WR Write signal for external memory P3.7 RD Read signal for external memory When the port is used as an output, the register contains information on the state of the output pins. Measuring the state of an output directly on the pin is inaccurate because the electrical level depends mostly on the type of charge that is applied to it. The functions shown below take the value of the register rather than that of the pin. TABLE : LIST OF INSTRUCTIONS THAT READ AND MODIFY THE PORT USING REGISTER VALUES Instruction Function ANL Logical AND ex: ANL P0, A ORL Logical OR ex: ORL P2, #00000B XRL Exclusive OR ex: XRL P, A JBC Jump if the bit of the port is set to 0 CPL Complement one bit of the port INC Increment the port register by DEC Decrement the port register by DJNZ Decrement by and jump if the result is not equal to 0 MOV P., C Copy the held bit C to the port CLR P.x Set the port bit to 0 SETB P.x Set the port bit to 34 Ste Catherine Street West, Suite 900, Montreal, Quebec, Canada H3B H4 Tel: (54) 87-2447 http://www.goalsemi.com 2

Port Operation Timing Writing to a Port (Output) When an operation induces a modification of the content in a port register, the new value is placed at the output of the D flip-flop during the T2 period of the last machine cycle that the instruction needed to execute. It is important to note, however, that the output stage only samples the output of the registers on the P phase of each period. It follows the new value appearing at the output after the T2 period of the following machine cycle. Reading a Port (Input) The reading of an I/O pin takes place: During T9 cycle for P0, P During T0 cycle for P2, P3 When the ports are configured as I/Os In order to get sampled, the signal duration present on the I/O inputs must have a duration longer than Fosc/2. I/O Ports Driving Capability The maximum allowable continuous current that the device can sink on I/O port is defined by the following: Maximum sink current on one given I/O Maximum total sink current for P0 Maximum total sink current for P, 2, 3 Maximum total sink current on all I/O 0mA 26mA 5mA 7mA It is not recommended to exceed the sink current expressed in the above table. Doing so is likely to make the low-level output voltage exceed the device s specification and it is likely to affect the device s reliability. The VRS540 I/O ports are not designed to source current. 34 Ste Catherine Street West, Suite 900, Montreal, Quebec, Canada H3B H4 Tel: (54) 87-2447 http://www.goalsemi.com 3

Timers The VRS540 includes three 6-bit timers: T0, T and T2. The timers can operate in two specific modes: Event counting mode Timer mode When operating in counting mode, the counter is incremented each time an external event, such as a transition in the logical state of the timer input (T0, T, T2 input), is detected. When operating in timer mode, the counter is incremented by the microcontroller s direct clock pulse or by a divided version of this pulse. Timer 0 and Timer Timers 0 and have four modes of operation. These modes allow the user to change the size of the counting register or to authorize an automatic reload when provided with a specific value. Timer can even be used as a baud rate generator to generate communication frequencies for the serial interface. Timer and Timer 0 are configured by the TMOD and TCON registers. TABLE 2: TIMER MODE CONTROL REGISTER (TMOD) SFR 89H 7 6 5 4 3 2 0 GATE C/T M M0 GATE C/T M.0 M0.0 Bit Mnemonic Description 7 GATE : Enables external gate control (pin INT for Counter ). When INT is high, and TRx bit is set (see TCON register), a counter is incremented every falling edge on the TIN input pin. 6 C/T Selects timer or counter operation (Timer ). = A counter operation is performed 0 = The corresponding register will function as a timer. 5 M. Selects mode for Timer/Counter 4 M0. Selects mode for Timer/Counter 3 GATE0 If set, enables external gate control (pin INT0 for Counter 0). When INT0 is high, and TRx bit is set (see TCON register), a counter is incremented every falling edge on the T0IN input pin. 2 C/T0 Selects timer or counter operation (Timer 0). = A counter operation is performed 0 = The corresponding register will function as a timer. M.0 Selects mode for Timer/Counter 0. 0 M0.0 Selects mode for Timer/Counter 0. The table below summarizes the four modes of operation of timers 0 and. The timer-operating mode is selected by the bits M and M0 of the TMOD register. TABLE 3: TIMER/COUNTER MODE DESCRIPTION SUMMARY M M0 Mode Function 0 0 Mode 0 3-bit Counter 0 Mode 6-bit Counter 0 Mode 2 8-bit auto-reload Counter/Timer. The reload value is kept in TH0 or TH, while TL0 or TL is incremented every machine cycle. When TLx overflows, the value of THx is copied to TLx. Mode 3 If Timer M and M0 bits are set to, Timer stops. 34 Ste Catherine Street West, Suite 900, Montreal, Quebec, Canada H3B H4 Tel: (54) 87-2447 http://www.goalsemi.com 4

Timer 0/ Timer Counter / Timer Functions Timing Function When operating as a timer, the counter is automatically incremented at every machine cycle. A flag is raised in the event that an overflow occurs and the counter acquires a value of zero. These flags (TF0 and TF) are located in the TCON register. TABLE 4: TIMER 0 AND CONTROL REGISTER (TCON) SFR 88H 7 6 5 4 3 2 0 TF TR TF0 TR0 IE IT IE0 IT0 Bit Mnemonic Description 7 TF Timer Overflow Flag. Set by hardware on Timer/Counter overflow. Cleared by hardware on Timer/Counter overflow. Cleared by hardware when processor vectors to interrupt routine. 6 TR Timer Run Control Bit. Set/cleared by software to turn Timer/Counter on or off. 5 TF0 Timer 0 Overflow Flag. Set by hardware on Timer/Counter overflow. Cleared by hardware when processor vectors to interrupt routine. 4 TR0 Timer 0 Run Control Bit. Set/cleared by software to turn Timer/Counter on or off. 3 IE Interrupt Edge Flag. Set by hardware when external interrupt edge is detected. Cleared when interrupt processed. 2 IT Interrupt Type Control Bit. Set/cleared by software to specify falling edge/low level triggered external interrupts. IE0 Interrupt 0 Edge Flag. Set by hardware when external interrupt edge is detected. Cleared when interrupt processed. 0 IT0 Interrupt 0 Type control bit. Set/cleared by software to specify falling edge/low level triggered external interrupts. Counting Function When operating as a counter, the timer s register is incremented at every falling edge of the T0, T and T2 signals located at the input of the timer. In this case, the signal is sampled at the T0 phase of each machine cycle for Timer 0, Timer and T9 for Timer 2. When the sampler sees a high immediately followed by a low in the next machine cycle, the counter is incremented. Two machine cycles are required to detect and record an event. This reduces the counting frequency by a factor of 24 (24 times less than the oscillator s frequency). Operating Modes The user may change the operating mode by varying the M and M0 bits of the TMOD SFR. Mode 0 A schematic representation of this mode of operation can be found below in Figure 0. From the figure, we notice that the timer operates as an 8-bit counter preceded by a divide-by-32 prescaler made of the 5LSB of TL. The register of the counter is configured to be 3 bits long. When an overflow causes the value of the register to roll over to 0, the TFx interrupt signal goes to. The count value is validated as soon as TRx goes to and the GATE bit is 0, or when INTx is. FIGURE : TIMER/COUNTER MODE 0: 3-BIT COUNTER CLK 2 TPIN TR GATE INT PIN Mode 0 C/T =0 C/T = 0 4 7 Mode 0 Mode TL TH 0 7 Mode is almost identical to Mode 0. They differ in that, in Mode, the counter uses the full 6-bits and has no prescaler. Mode 2 In this mode, the register of the timer is configured as an 8-bit automatically re-loadable counter. In Mode 2, it is the lower byte TLx that is used as the counter. In the event of a counter overflow, the TFx flag is set to and the value contained in THx, which is preset by software, is reloaded into the TLx counter. The value of THx remains unchanged. Control CLK TF INT 34 Ste Catherine Street West, Suite 900, Montreal, Quebec, Canada H3B H4 Tel: (54) 87-2447 http://www.goalsemi.com 5

FIGURE 2: TIMER/COUNTER MODE 2: 8-BIT AUTOMATIC RELOAD CLK 2 0 C/T =0 TL 0 7 C/T= T Pin Control Reload 0 7 TH TR GATE INT0 PIN TF INT Mode 3 In Mode 3, Timer is blocked as if its control bit, TR, was set to 0. In this mode, Timer 0 s registers TL0 and TH0 are configured as two separate 8-bit counters. Also, the TL0 counter uses Timer 0 s control bits C/T, GATE, TR0, INT0, TF0 and the TH0 counter is held in Timer Mode (counting machine cycles) and gains control over TR and TF from Timer. At this point, TH0 controls the Timer interrupt. FIGURE 3: TIMER/COUNTER 0 MODE 3 CLK TH0 0 7 Control TR TF INTERRUPT CLK 2 0 C/T =0 CLK TL0 0 7 C/T = T0PIN Control TF0 INTERRUPT TR0 GATE INT0 PIN 34 Ste Catherine Street West, Suite 900, Montreal, Quebec, Canada H3B H4 Tel: (54) 87-2447 http://www.goalsemi.com 6

Timer 2 Timer 2 of the VRS540 is a 6-bit Timer/Counter. Similar to timers 0 and, Timer 2 can operate either as an event counter or as a timer. The user may switch functions by writing to the C/T2 bit located in the T2CON special function register. Timer 2 has three operating modes: Auto-Load Capture, and Baud Rate Generator. The T2CON SFR configures the modes of operation of Timer 2. The next table describes each bit in the T2CON special function register. TABLE 5: TIMER 2 CONTROL REGISTER (T2CON) SFR C8H 7 6 5 4 3 2 0 TF2 EXF2 RCLK TCLK EXEN2 TR2 C/T2 CP/RL2 Bit Mnemonic Description 7 TF2 Timer 2 Overflow Flag: Set by an overflow of Timer 2 and must be cleared by software. TF2 will not be set when either RCLK = or TCLK =. 6 EXF2 Timer 2 external flag change in state occurs when either a capture or reload is caused by a negative transition on T2EX and EXEN2=. When Timer 2 is enabled, EXF= will cause the CPU to Vector to the Timer 2 interrupt routine. Note that EXF2 must be cleared by software. 5 RCLK Serial Port Receive Clock Source. : Causes Serial Port to use Timer 2 overflow pulses for its receive clock in modes and 3. 0: Causes Timer overflow to be used for the Serial Port receive clock. 4 TCLK Serial Port Transmit Clock. : Causes Serial Port to use Timer 2 overflow pulses for its transmit clock in modes and 3. 0: Causes Timer overflow to be used for the Serial Port transmit clock. 3 EXEN2 Timer 2 External Mode Enable. : Allows a capture or reload to occur as a result of a negative transition on T2EX if Timer 2 is not being used to clock the Serial Port. 0: Causes Timer 2 to ignore events at T2EX. 2 TR2 Start/Stop Control for Timer 2. : Start Timer 2 0: Stop Timer 2 Timer or Counter Select (Timer 2) C/T2 : External event counter falling edge triggered. 0: Internal Timer (OSC/2) 0 CP/RL2 Capture/Reload Select. : Capture of Timer 2 value into RCAP2H, RCAP2L is performed if EXEN2= and a negative transitions occurs on the T2EX pin. The capture mode requires RCLK and TCLK to be 0. 0: Auto-reload reloads will occur either with Timer 2 overflows or negative transitions at T2EX when EXEN2=. When either RCK = or TCLK =, this bit is ignored and the timer is forced to auto-reload on Timer 2 overflow. As shown below, there are different possible combinations of control bits that may be used for the mode selection of Timer 2. TABLE 6: TIMER 2 MODE SELECTION BITS RCLK + TCLK CP/RL2 TR2 MODE 0 0 6-bit Auto- Reload Mode 0 6-bit Capture Mode X Baud Rate Generator Mode X X 0 Off The details of each mode are described below. Capture Mode In Capture Mode the EXEN2 bit value defines if the external transition on the T2EX pin will be able to trigger the capture of the timer value. When EXEN2 = 0, Timer 2 acts as a 6-bit timer or counter, which, upon overflowing, will set bit TF2 (Timer 2 overflow bit). This overflow can be used to generate an interrupt. FIGURE 4: TIMER 2 IN CAPTURE MODE T2 Pin F OSC 2 T2 EX Pin C/T2 EXEN2 0 TIMER COUNTER TR2 0 TL2 7 0 TH2 7 0 7 0 7 RCAP2L RCAP2H EXF2 TF2 Timer 2 Interrupt 34 Ste Catherine Street West, Suite 900, Montreal, Quebec, Canada H3B H4 Tel: (54) 87-2447 http://www.goalsemi.com 7

When EXEN2 =, the above still applies. In addition, it is possible to allow a to 0 transition at the T2EX input to cause the current value stored in the Timer 2 registers (TL2 and TH2) to be captured into the RCAP2L and RCAP2H registers. Furthermore, the transition at T2EX causes bit EXF2 in T2CON to be set, and EXF2, like TF2, can generate an interrupt. Note that both EXF2 and TF2 share the same interrupt vector. Auto-Reload Mode In this mode, there are also two options. The user may choose either option by writing to bit EXEN2 in T2CON. If EXEN2 = 0, when Timer 2 rolls over, it not only sets TF2, but also causes the Timer 2 registers to be reloaded with the 6-bit value in the RCAP2L and RCAP2H registers previously initialised. In this mode, Timer 2 can be used as a baud rate generator source for the serial port. Baud Rate Generator Mode The baud rate generator mode is activated when RCLK is set to and/or TCLK is set to. This mode will be described in the serial port section. FIGURE 6: TIMER 2 IN AUTOMATIC BAUD GENERATOR MODE T2 Pin F OSC 2 T2 EX Pin C/T2 EXEN2 0 TIMER COUNTER TR2 Timer Overflow 2 0 TL2 7 0 7 RCAP2L 0 SMOD 0 TCLK 0 TH2 7 0 7 RCAP2H 0 RCLK EXF2 6 6 TX Clock RX Clock Timer 2 Interrupt Request If EXEN2=, then Timer 2 still performs the above operation, but a to 0 transition at the external T2EX input will also trigger an anticipated reload of the Timer 2 with the value stored in RCAP2L, RCAP2H and set EXF2. FIGURE 5: TIMER 2 IN AUTO-RELOAD MODE F OSC 2 C/T2 0 TIMER 0 TL2 7 0 TH2 7 COUNTER T2 Pin TR2 0 7 RCAP2L 0 7 RCAP2H TF2 T2 EX Pin EXF2 EXEN2 Timer 2 Interrupt 34 Ste Catherine Street West, Suite 900, Montreal, Quebec, Canada H3B H4 Tel: (54) 87-2447 http://www.goalsemi.com 8

Serial Port The serial port included in the VRS540 can operate in full duplex; in other words, it can transmit and receive data simultaneously. This occurs at the same speed if one timer is assigned as the clock source for both transmission and reception, and at different speeds if transmission and reception are each controlled by their own timer. The serial port receive is buffered, which means that it can begin reception of a byte even if the one previously received byte has not been retrieved from the receive register by the processor. However, if the first byte still has not been read by the time reception of the second byte is complete, the byte present in the receive buffer will be lost. One SFR register, SBUF, gives access to the transmit and receive registers of the serial port. When users read from the SBUF register, they will access the receive register. When users write to the SBUF, the transmit register will be loaded. Serial Port Control Register The serial port control register and status register SCON contain the 9 th data bit for transmit and receive (TB8 and RB8) and all the mode selection bits. SCON also contains the serial port interrupt bits (TI and RI). TABLE 7: SERIAL PORT CONTROL REGISTER (SCON) SFR 98H 7 6 5 4 3 2 0 SM0 SM SM2 REN TB8 RB8 TI RI Bit Mnemonic Description 7 SM0 Bit to select mode of operation (see table below) 6 SM Bit to select mode of operation (see table below) 5 SM2 Multiprocessor communication is possible in modes 2 and 3. 3 TB8 9 th data bit transmitted in modes 2 and 3 This bit must be set by software and cleared by software. 2 RB8 9 th data bit received in modes 2 and 3. In Mode, if SM2 = 0, RB8 is the stop bit that was received. In Mode 0, this bit is not used. This bit must be cleared by software. TI Transmission Interrupt flag. Automatically set to when: The 8 th bit has been sent in Mode 0. Automatically set to when the stop bit has been sent in the other modes. This bit must be cleared by software. 0 RI Reception Interrupt flag TABLE 8: SERIAL PORT MODES OF OPERATION Automatically set to when: The 8 th bit has been received in Mode 0. Automatically set to when the stop bit has been sent in the other modes (see SM2 exception). This bit must be cleared by software. SM0 SM Mode Description Baud Rate 0 0 0 Shift Register F osc /2 0 8-bit UART Variable 0 2 9-bit UART F osc /64 or F osc /32 3 9-bit UART Variable Modes of Operation The VRS540 serial port can operate in four different modes. In all four modes, a transmission is initiated by an instruction that uses the SBUF SFR as a destination register. In Mode 0, reception is initiated by setting RI to 0 and REN to. An incoming start bit initiates reception in the other modes provided that REN is set to. The following paragraphs describe the four modes. In modes 2 or 3 if SM2 is set to, RI will not be activated if the received 9 th data bit (RB8) is 0. In Mode, if SM2 = then RI will not be activated if a valid stop bit was not received. 4 REN Serial Reception Enable Bit This bit must be set by software and cleared by software. : Serial reception enabled 0: Serial reception disabled 34 Ste Catherine Street West, Suite 900, Montreal, Quebec, Canada H3B H4 Tel: (54) 87-2447 http://www.goalsemi.com 9

Mode 0 In this mode, the serial data exits and enters through the RXD pin. TXD is used to output the shift clock. The signal is composed of 8 data bits starting with the LSB. The baud rate in this mode is /2 the oscillator frequency. The SEND signal enables the output of the shift register to the alternate output function line of P3.0 and enables SHIFT CLOCK to the alternate output function line of P3.. SHIFT CLOCK is high during T, T2 and T, T2 and T3, T4 of every machine cycle and low during T5, T6, T7, T8, T9 and T0. At T2 of every machine cycle in which SEND is active, the contents of the transmit shift register are shifted to the right by one position. Write to SBUF Fosc/2 S Q D CLK Start TX Clock Internal Bus SBUF ZERO DETECTOR TX Control Unit TI Shift Shift Send Serial Port Interrupt Shift Clock RXD P3.0 TXD P3. Zeros come in from the left as data bits shift out to the right. The TX control block sends its final shift and deactivates SEND while setting T after one condition is fulfilled: When the MSB of the data byte is at the output position of the shift register; the that was initially loaded into the 9 th position is just to the left of the MSB; and all positions to the left of that contain zeros. Once these conditions are met, the de-activation of SEND and the setting of T occur at T of the 0 th machine cycle after the write to SBUF pulse. RI REN RX Clock RI RX Control Unit Receive Start Shift 0 Reception in Mode 0 RXD P3.0 Input Function Shift Register SBUF RXD P3.0 READ SBUF When REN and R are set to and 0 respectively, reception is initiated. The bits 0 are written to the receive shift register at T2 of the next machine cycle by the RX control unit. In the following phase, the RX control unit will activate RECEIVE. FIGURE 7: SERIAL PORT MODE 0 BLOCK DIAGRAM Transmission in Mode 0 Internal Bus Any instruction that uses SBUF as a destination register may initiate a transmission. The write to SBUF signal also loads a into the 9 th position of the transmit shift register and tells the TX control block to begin a transmission. The internal timing is such that one full machine cycle will elapse between a write to SBUF instruction and the activation of SEND. SHIFT CLOCK to the alternate output function line of P3. is enabled by RECEIVE. At every machine cycle, SHIFT CLOCK makes transitions at T5 and T. The contents of the receive shift register are shifted one position to the left at T2 of every machine in which RECEIVE is active. The value that comes in from the right is the value that was sampled at the P3.0 pin at T0 of the same machine cycle. s are shifted out to the left as data bits are shifted in from the right. The RX control block is flagged to do one last shift and load SBUF when the 0 that was initially loaded into the rightmost position arrives at the leftmost position in the shift register. 34 Ste Catherine Street West, Suite 900, Montreal, Quebec, Canada H3B H4 Tel: (54) 87-2447 http://www.goalsemi.com 20

Mode For an operation in Mode, 0 bits are transmitted through TXD or received through RXD. The transactions are composed of: a Start bit (Low), 8 data bits (LSB first) and one Stop bit (high). The reception is completed once the Stop bit sets the RB8 flag in the SCON register. Either Timer or Timer 2 controls the baud rate in this mode. The following diagram shows the serial port structure when configured in Mode. FIGURE 8: SERIAL PORT MODE AND 3 BLOCK DIAGRAM Timer Overflow 2 SMOD RCLK 0 Write to SBUF 0 0 Timer 2 Overflow TCLK 6-0 Transition Detector RXD S D CLK Start Q Start TX Clock 6 Bit Detector RX Clock LOAD SBUF Transmission in Mode Internal Bus SBUF ZERO DETECTOR TX Control Unit TI RI Shift RX Control Unit 9-Bit Shift Register SBUF Internal Bus Data Send Serial Port Interrupt Shift Load SBUF SHIFT READ SBUF Transmission is initiated by any instruction that makes use of SBUF as a destination register. The 9 th bit position of the transmit shift register is loaded by the write to SBUF signal. This event also flags the TX Control Unit that a transmission has been requested. It is after the next rollover in the divide-by-6 counter when transmission actually begins at T of the machine cycle. It follows that the bit times are synchronized to the divide-by-6 counter and not to the write to SBUF signal. TXD When a transmission begins, it places the start bit at TXD. Data transmission is activated one bit time later. This activation enables the output bit of the transmit shift register to TXD. One bit time after that, the first shift pulse occurs. In this mode, zeros are clocked in from the left as data bits are shifted out to the right. When the most significant bit of the data byte is at the output position of the shift register, the that was initially loaded into the 9 th position is to the immediate left of the MSB, and all positions to the left of that contain zeros. This condition flags the TX Control Unit to shift one more time. Reception in Mode One to zero transitions at RXD initiate reception. It is for this reason that RXD is sampled at a rate of 6 multiplied by the baud rate that has been established. When a transition is detected, FFh is written into the input shift register and the divide-by-6 counter is immediately reset. The divide-by-6 counter is reset in order to align its rollovers with the boundaries of the incoming bit times. In total, there are 6 states in the counter. During the 7 th, 8 th and 9 th counter states of each bit time; the bit detector samples the value of RXD. The accepted value is the value that was seen in at least two of the three samples. The purpose of doing this is for noise rejection. If the value accepted during the first bit time is not zero, the receive circuits are reset and the unit goes back to searching for another one to zero transition. Doing this rejects all false start bits. If the start bit is valid, it is shifted into the input shift register, and the reception of the rest of the frame will proceed. For a receive operation, the data bits come in from the right as s shift out on the left. As soon as the start bit arrives at the leftmost position in the shift register, (9- bit register), it tells the RX control block to perform one last shift operation: to set RI and to load SBUF and RB8. The signal to load SBUF and RB8, and to set RI, will be generated if, and only if, the following conditions are met at the time the final shift pulse is generated: - Either SM2 = 0 or the received stop bit = - RI = 0 34 Ste Catherine Street West, Suite 900, Montreal, Quebec, Canada H3B H4 Tel: (54) 87-2447 http://www.goalsemi.com 2