Professional Documents
Culture Documents
HT46RB70 (1) PARA M AUDIO KEYRING 49
HT46RB70 (1) PARA M AUDIO KEYRING 49
Features
· Operating voltage: · 8 channels 10-bit resolution A/D converter
fSYS=6MHz: 2.2V~5.5V · 4-channel 8-bit PWM output shared with
fSYS=12MHz: 2.7V~5.5V four I/O lines
· 38 bidirectional I/O lines (max.) · SIO (synchronous serial I/O) function
· 1 interrupt input shared with an I/O line · Supports Interrupt, Control, Bulk transfer
· Two 16-bit programmable timer/event counter with · USB 1.1 full speed function compatible
overflow interrupt · 6 endpoints supported (endpoint 0 included)
· Only crystal oscillator (6MHz or 12MHz)
· Total FIFO size is 160 byte
· Watchdog Timer (8, 8, 8, 64, 8, 64 for EP0~EP5)
· 8192´16 program memory · Bit manipulation instruction
· 384´8 data memory RAM · 16-bit table read instruction
· HALT function and wake-up feature reduce power · 63 powerful instructions
consumption · All instructions in one or two machine cycles
· Up to 0.33ms instruction cycle with 12MHz system · Low voltage reset function
clock at VDD=5V · 28-pin SOP/SKDIP, 48-pin SSOP package
· 16-level subroutine nesting
General Description
This device is an 8-bit high performance RISC touch-pads, PS II joysticks, XBOX joysticks, USB Mice
architecture microcontroller designed for USB product keyboards and joystick. A HALT feature is included to
applications. It is particularly suitable for use in products reduce power consumption.
such as USB and/or SPI touch-panels, USB and/or SPI
Block Diagram
U S B D + U S B D - V 3 3 O
T M R 0 C M P r e s c a le r fS Y S
U S B 1 .1 U
F u ll S p e e d T M R 0 X P C 1 /T M R 0
In te rru p t
C ir c u it
T M R 1 C M fS Y S /4
S T A C K U
T M R 1 X P C 2 /T M R 1
P ro g ra m P ro g ra m IN T C
R O M C o u n te r
E N /D IS
W D T S
M fS Y S /4
In s tr u c tio n W D T P r e s c a le r W D T U
R e g is te r M D A T A X W D T O S C
M P
U M e m o ry
X P A 6
P A 7
P A C P o rt A
P A 0 ~ P A 7
P A
In s tr u c tio n M U X
D e c o d e r
P B C P o rt B
P B 0 /A N 0 ~ P B 7 /A N 7
A L U S T A T U S
P B
T im in g S h ifte r A /D C o n v e rte r
G e n e ra to r
P C C P o rt C
P C 0 /IN T
O S C 2 O S C 1 A C C P C P C 3 ~ P C 7
R E S
V D D
V S S P D C P o rt D P D 0 /P W M 0 ~ P D 3 /P W M 3 ,
A V D D P D 4 ~ P D 7
P D
A V S S
P W M
P E C P o rt E
P E 4 ~ P E 5
P E P E 0 /S C S
P E 1 /C L K
P E 2 /S D I
S e r ia l P E 3 /S D O
In te rfa c e
Pin Assignment
P A 3 1 4 8 P A 4
P A 2 2 4 7 P A 5
P A 1 3 4 6 P A 6
P A 0 4 4 5 P A 7
P D 3 /P W M 3 5 4 4 P D 4
P D 2 /P W M 2 6 4 3 P D 5
P D 1 /P W M 1 7 4 2 P D 6
P D 0 /P W M 0 8 4 1 P D 7
P B 7 /A N 7 9 4 0 R E S
P B 6 /A N 6 1 0 3 9 A V D D
P A 3 1 2 8 P A 4 P B 5 /A N 5 1 1 3 8 V D D
P A 2 2 2 7 P A 5 P B 4 /A N 4 1 2 3 7 A V S S
P A 1 3 2 6 P A 6 P C 7 1 3 3 6 V S S
P A 0 4 2 5 P A 7 P C 6 1 4 3 5 O S C 1
P D 1 /P W M 1 5 2 4 R E S P C 5 1 5 3 4 O S C 2
P D 0 /P W M 0 6 2 3 V D D /A V D D P C 4 1 6 3 3 P E 4
P B 5 /A N 5 7 2 2 V S S /A V S S P B 3 /A N 3 1 7 3 2 P E 5
P B 4 /A N 4 8 2 1 O S C 1 P B 2 /A N 2 1 8 3 1 V 3 3 O
P B 3 /A N 3 9 2 0 O S C 2 P B 1 /A N 1 1 9 3 0 U D P
P B 2 /A N 2 1 0 1 9 V 3 3 O P B 0 /A N 0 2 0 2 9 U D N
P B 1 /A N 1 1 1 1 8 U D P P E 3 /S D O 2 1 2 8 P C 0 /IN T
P B 0 /A N 0 1 2 1 7 U D N P E 2 /S D I 2 2 2 7 P C 1 /T M R 0
P E 3 /S D O 1 3 1 6 P C 0 /IN T P E 1 /C L K 2 3 2 6 P C 2 /T M R 1
P E 2 /S D I 1 4 1 5 P E 1 /C L K P E 0 /S C S 2 4 2 5 P C 3
H T 4 6 R B 7 0 H T 4 6 R B 7 0
2 8 S O P -A /S K D IP -A 4 8 S S O P -A
Pin Description
Pin Name I/O Options Description
Pull-high Bidirectional 8-bit input/output port. Each pin can be configured as a
(bit option) wake-up input by ROM code option. The input or output mode is controlled
PA0~PA7 I/O
Wake-up by PAC (PA control register, bit option). Pull-high resistor options:
(bit option) PA0~PA7, bit option, wake-up options: PA0~PA7.
Bidirectional 8-bit input/output port. Software instructions determine the
PB0/AN0~ Pull-high CMOS output or Schmitt trigger input with pull-high resistor (determined by
I/O
PB7/AN7 (bit option) pull-high options: bit option). The PB can be used as analog input of the ana-
log to digital converter.
PC0/INT Bidirectional I/O lines. Software instructions determine the CMOS output or
PC1/TMR0 Pull-high Schmitt trigger input with pull-high resistor (determined by pull-high options:
I/O
PC2/TMR1 (nibble option) nibble option). The PC0, PC1 PC2 are pin-shared with INT, TMR0, TMR1
PC3~PC7 respectively.
Bidirectional I/O lines. Software instructions determine the CMOS output or
PD0/PWM0~ Pull-high
Schmitt trigger input with pull-high resistor (determined by pull-high options:
PD3/PWM3 I/O (nibble option)
nibble option). The PD0/PD1/PD2/PD3 are pin-shared with PWM0/PWM1/
PD4~PD7 I/O or PWM
PWM2/PWM3 (dependent on PWM options).
Bidirectional I/O lines. Software instructions determine the CMOS output or
Pull-high Schmitt trigger input with pull-high resistor (determined by pull-high options:
PE0/SCS I/O
(nibble option) nibble option). The PE0 is pin-shared with SCS. SCS is a chip select pin of
the Serial interface, Master mode is output, Slave mode is input.
Bidirectional I/O lines. Software instructions determine the CMOS output or
Pull-high Schmitt trigger input with pull-high resistor (determined by pull-high options:
PE1/CLK I/O
(nibble option) nibble option). The PE1 is pin-shared with CLK. CLK is a Serial interface se-
rial clock input/output (Initial is input).
AVDD ¾ ¾ ADC positive power supply, AVDD should be externally connected to VDD.
OSC1 I OSC1 and OSC2 are connected to a 6MHz or 12MHz Crystal/resonator (de-
¾
OSC2 O termined by software instructions) for the internal system clock.
V33O O ¾ 3.3V regulator output.
UDP is USBD+ line
UDP I/O ¾
USB function is controlled by software control register.
UDN is USBD- line
UDN I/O ¾
USB function is controlled by software control register.
Note: These are stress ratings only. Stresses exceeding the range specified under ²Absolute Maximum Ratings² may
cause substantial damage to the device. Functional operation of this device at other conditions beyond those
listed in the specification is not implied and prolonged exposure to extreme conditions may affect device reliabil-
ity.
Test Conditions
Symbol Parameter Min. Typ. Max. Unit
VDD Conditions
fSYS=6MHz 2.2 ¾ 5.5 V
VDD Operating Voltage ¾
fSYS=12MHz 2.7 ¾ 5.5 V
IDD1 Operating Current (6MHz Crystal) 5V No load, fSYS=6MHz ¾ 6.5 12 mA
3V ¾ 3.6 10 mA
IDD2 Operating Current (12MHz Crystal) No load, fSYS=12MHz
5V ¾ 7.5 16 mA
Test Conditions
Symbol Parameter Min. Typ. Max. Unit
VDD Conditions
3V No load, system HALT, ¾ ¾ 1 mA
ISTB2 Standby Current (WDT Disabled)
5V USB suspended ¾ ¾ 2 mA
No load, system HALT,
ISTB3 Standby Current (WDT Disabled) 5V USB transceiver and ¾ 150 200 mA
3.3V regulator On
VIL1 Input Low Voltage for I/O Ports ¾ ¾ 0 ¾ 0.3VDD V
VIH1 Input High Voltage for I/O Ports ¾ ¾ 0.7VDD ¾ VDD V
VIL2 Input Low Voltage (RES) ¾ ¾ 0 ¾ 0.4VDD V
VIH2 Input High Voltage (RES) ¾ ¾ 0.9VDD ¾ VDD V
3V 4 8 ¾ mA
IOL I/O Port Sink Current VOL=0.1VDD
5V 10 20 ¾ mA
3V -2 -4 ¾ mA
IOH I/O Port Source Current VOH=0.9VDD
5V -5 -10 ¾ mA
3V 20 60 100 kW
RPH Pull-high Resistance ¾
5V 10 30 50 kW
VLVR Low Voltage Reset Voltage ¾ Option 3.0V 2.7 3 3.3 V
VV33O 3.3V Regulator Output 5V IV33O=-5mA 3 3.3 3.6 V
EAD A/D Conversion Error ¾ ¾ ¾ ±0.5 ±1 LSB
Test Conditions
Symbol Parameter Min. Typ. Max. Unit
VDD Conditions
3V ¾ 45 90 180 ms
tWDTOSC Watchdog Oscillator Period
5V ¾ 32 65 130 ms
tRES External Reset Low Pulse Width ¾ ¾ 1 ¾ ¾ ms
tSST System Start-up Timer Period ¾ Wake-up from HALT ¾ 1024 ¾ *tSYS
Note: *tSYS=1/fSYS
Functional Description
Execution Flow points to the memory word containing the next instruc-
tion code. When executing a jump instruction, condi-
The system clock is derived from a crystal. It is internally
tional skip execution, loading a PCL register, a
divided into four non-overlapping clocks. One instruc-
subroutine call, an initial reset, an internal interrupt, an
tion cycle consists of four system clock cycles. Instruc-
external interrupt, or returning from a subroutine, the PC
tion fetching and execution are pipelined in such a way
manages the program transfer by loading the address
that a fetch takes one instruction cycle while decoding
corresponding to each instruction.
and execution takes the next instruction cycle. The
pipelining scheme makes it possible for each instruction The conditional skip is activated by instructions. Once
to be effectively executed in a cycle. If an instruction the condition is met, the next instruction, fetched during
changes the value of the program counter, two cycles the current instruction execution, is discarded and a
are required to complete the instruction. dummy cycle replaces it to get a proper instruction, oth-
erwise proceed to the next instruction.
Program Counter - PC
The lower byte of the PC (PCL) is a readable and
The program counter (PC) is 13 bits wide and it controls writeable register (06H). Moving data into the PCL per-
the sequence in which the instructions stored in the pro- forms a short jump. The destination is within 256 loca-
gram ROM are executed. The contents of the PC can tions.
specify a maximum of 8192 addresses. After accessing
When a control transfer takes place, an additional
a program memory word to fetch an instruction code,
dummy cycle is required.
the value of the PC is incremented by 1. The PC then
T 1 T 2 T 3 T 4 T 1 T 2 T 3 T 4 T 1 T 2 T 3 T 4
S y s te m C lo c k
P C P C P C + 1 P C + 2
F e tc h IN S T (P C )
E x e c u te IN S T (P C -1 ) F e tc h IN S T (P C + 1 )
E x e c u te IN S T (P C ) F e tc h IN S T (P C + 2 )
E x e c u te IN S T (P C + 1 )
Execution Flow
Program Counter
Mode
*12 *11 *10 *9 *8 *7 *6 *5 *4 *3 *2 *1 *0
Initial Reset 0 0 0 0 0 0 0 0 0 0 0 0 0
External Interrupt 0 0 0 0 0 0 0 0 0 0 1 0 0
Timer/Event Counter 0 Overflow 0 0 0 0 0 0 0 0 0 1 0 0 0
Timer/Event Counter 1 Overflow 0 0 0 0 0 0 0 0 0 1 1 0 0
USB Interrupt 0 0 0 0 0 0 0 0 1 0 0 0 0
A/D Converter Interrupt 0 0 0 0 0 0 0 0 1 0 1 0 0
Serial Interface Interrupt 0 0 0 0 0 0 0 0 1 1 0 0 0
Skip Program Counter+2
Loading PCL *12 *11 *10 *9 *8 @7 @6 @5 @4 @3 @2 @1 @0
Jump, Call Branch #12 #11 #10 #9 #8 #7 #6 #5 #4 #3 #2 #1 #0
Return from Subroutine S12 S11 S10 S9 S8 S7 S6 S5 S4 S3 S2 S1 S0
Program Counter
Table Location
Instruction
*12 *11 *10 *9 *8 *7 *6 *5 *4 *3 *2 *1 *0
TABRDC [m] P12 P11 P10 P9 P8 @7 @6 @5 @4 @3 @2 @1 @0
TABRDL [m] 1 1 1 1 1 @7 @6 @5 @4 @3 @2 @1 @0
Table Location
Note: *12~*0: Table location bits P12~P8: Current program counter bits
@7~@0: Table pointer bits
0 0 H In d ir e c t A d d r e s s in g R e g is te r 0
At a subroutine call or an interrupt acknowledgment, the 0 1 H M P 0
contents of the program counter are pushed onto the 0 2 H In d ir e c t A d d r e s s in g R e g is te r 1
0 3 H M P 1
stack. At the end of the subroutine or an interrupt rou-
0 4 H B P
tine, signaled by a return instruction (RET or RETI), the 0 5 H A C C
program counter is restored to its previous value from 0 6 H P C L
0 7 H T B L P
the stack. After a chip reset, the SP will point to the top of 0 8 H T B L H
the stack. 0 9 H
0 A H S T A T U S
If the stack is full and a non-masked interrupt takes 0 B H IN T C 0
0 C H T M R 0 H
place, the interrupt request flag will be recorded but the
0 D H T M R 0 L
acknowledgment will be inhibited. When the stack 0 E H T M R 0 C
pointer is decremented (by RET or RETI), the interrupt is 0 F H T M R 1 H
1 0 H T M R 1 L
serviced. This feature prevents stack overflow, allowing 1 1 H T M R 1 C
the programmer to use the structure more easily. If the 1 2 H P A
1 3 H P A C
stack is full and a ²CALL² is subsequently executed, 1 4 H P B
stack overflow occurs and the first entry will be lost (only 1 5 H P B C
1 6 H P C
the most recent 16 return addresses are stored).
1 7 H P C C
1 8 H P D
Data Memory - RAM 1 9 H P D C
1 A H P E
The data memory (RAM) is designed with 438´8 bits, 1 B H P E C
1 C H
and is divided into two functional groups, namely; spe- 1 D H S p e c ia l P u r p o s e
cial function registers (51´8 bits) and general purpose 1 E H IN T C 1 D a ta M e m o ry
1 F H
data memory (Bank 0: 192´8 bits and Bank 1: 192´8
2 0 H U S C
bits) most of which are readable/writeable, although 2 1 H U S R
some are read only. 2 2 H U C C
2 3 H A W R
The unused space before 40H is reserved for future ex- 2 4 H S T A L L
2 5 H S IE S
pansion usage and reading these locations will retrieve 2 6 H M IS C
a ²00H². The space before 40H overlaps in each bank. 2 7 H S E T IO
2 8 H F IF O 0
The general purpose data memory, addressed from 40H 2 9 H F IF O 1
to FFH (Bank0; BP=0 or Bank1; BP=1), is used for data 2 A H F IF O 2
2 B H F IF O 3
and control information under instruction commands.
2 C H F IF O 4
All of the data memory areas can handle arithmetic, 2 D H F IF O 5
2 E H
logic, increment, decrement and rotate operations di- 2 F H
rectly. Except for some dedicated bits, each bit in the 3 0 H A D R L
3 1 H A D R H
data memory can be set and reset by ²SET [m].i² and 3 2 H A D C R
²CLR [m].i². They are also indirectly accessible through 3 3 H A C S R
3 4 H P W M 0
memory pointer registers (MP0;01H/MP1;03H). 3 5 H P W M 1
3 6 H P W M 2
After first setting up BP to a value of ²01H² to access 3 7 H P W M 3
bank 1, data in this bank can then be accessed indirectly 3 8 H S B C R
3 9 H S B D R
using the Memory Pointer, MP1. With BP set to a value 3 A H
of ²01H², using MP1 to indirectly read or write to ad- 3 F H
4 0 H
dresses between 40H~FFH in the data memory areas, G e n e ra l P u rp o s e : U n u s e d
D a ta M e m o ry
will result in operations to Bank 1. Directly addressing (1 9 2 B y te s ´ 2 B a n k : B a n k 0 ,B a n k 1 ) R e a d a s "0 0 "
F F H
the Data Memory will always result in Bank 0 being ac-
cessed irrespective of the value of BP. RAM Mapping
PDF is cleared by a system power-up or executing the ²CLR WDT² instruction. PDF is set by
4 PDF
executing the ²HALT² instruction.
The internal Timer/Event Counter 0 interrupt is initialized When the interrupt is enabled, the stack is not full and
by setting the Timer/Event Counter 0 interrupt request the external interrupt is active, a subroutine call to loca-
flag (bit 5 of the INTC0), caused by a Timer 0 overflow. tion 10H will occur. The interrupt request flag (USBF)
When the interrupt is enabled, the stack is not full and the and EMI bits will be cleared to disable other interrupts.
T0F bit is set, a subroutine call to location 08H will occur.
When PC Host access the FIFO of the HT46RB70, the
The related interrupt request flag (T0F) will be reset and
corresponding request bit of USR is set, and a USB
the EMI bit cleared to disable further interrupts.
interrupt is triggered. So user can easily determine
The internal Timer/Event Counter 1 interrupt is initialized which FIFO is accessed. When the interrupt has been
by setting the Timer/Event Counter 1 interrupt request served, the corresponding bit should be cleared by
flag (bit 6 of the INTC0), caused by a Timer 1 overflow. firmware. When the HT46RB70 receives a USB
When the interrupt is enabled, the stack is not full and the Suspend signal from the Host PC, the suspend line (bit0
T1F is set, a subroutine call to location 0CH will occur. of the USC) of the HT46RB70 is set and a USB interrupt
The related interrupt request flag (T1F) will be reset and is also triggered.
the EMI bit cleared to disable further interrupts.
USB interrupts are triggered by the following USB
events and the related interrupt request flag (USBF; bit
4 of the INTC1) will be set.
· The access of the corresponding USB FIFO from PC
· The USB suspend signal from the PC
· The USB resume signal from the PC
· USB Reset signal
It is recommended that a program does not use the If the WDT oscillator is disabled, the WDT clock may still
²CALL subroutine² within the interrupt subroutine. Inter- come from the instruction clock and operates in the
rupts often occur in an unpredictable manner or need to same manner except that in the HALT state the WDT
be serviced immediately in some applications. If only one may stop counting and lose its protecting purpose. In
stack is left and enabling the interrupt is not well con- this situation the logic can only be restarted by external
trolled, the original control sequence will be damaged logic. If the device operates in a noisy environment, us-
ing the on-chip RC oscillator (WDT OSC) is strongly rec-
once the ²CALL² operates in the interrupt subroutine.
ommended, since the HALT will stop the system clock.
S y s te m C lo c k /4
R O M fW D T fW D T /2 8
C o d e D iv id e r W D T P r e s c a le r
o p tio n
W D T
O S C C K T C K T T im e - o u t R e s e t
M a s k O p tio n
(1 2 k H z ) R R fs /2 1 5 ~ fs /2 1 6
fs /2 1 4 ~ fs /2 1 5
W D T C le a r fs /2 1 3 ~ fs /2 1 4
fs /2 1 2 ~ fs /2 1 3
Watchdog Timer
V D D
TO PDF RESET Conditions
0 .0 1 m F *
0 0 RES reset during power-up
1 0 0 k W u u RES reset during normal operation
R E S 0 1 RES wake-up at HALT
1 0 k W
1 u WDT time-out during normal operation
0 .1 m F * 1 1 WDT wake-up at HALT
P o w e r - o n D e te c tio n
Reset Configuration
WDT
RES Reset WDT
Reset Time-out RES Reset USB Reset USB Reset
Register (Normal Time-out
(Power On) (Normal (HALT) (Normal) (HALT)
Operation) (HALT)*
Operation)
TBLH xxxx xxxx uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu
STATUS --00 xxxx --1u uuuu --uu uuuu --01 uuuu --11 uuuu --uu uuuu --01 uuuu
INTC0 -000 0000 -000 0000 -000 0000 -000 0000 -uuu uuuu -000 0000 -000 0000
INTC1 -000 -000 -000 -000 -000 -000 -000 -000 -uuu -uuu -000 -000 -000 -000
PA 1111 1111 1111 1111 1111 1111 1111 1111 uuuu uuuu 1111 1111 1111 1111
PAC 1111 1111 1111 1111 1111 1111 1111 1111 uuuu uuuu 1111 1111 1111 1111
PB 1111 1111 1111 1111 1111 1111 1111 1111 uuuu uuuu 1111 1111 1111 1111
PBC 1111 1111 1111 1111 1111 1111 1111 1111 uuuu uuuu 1111 1111 1111 1111
PC 1111 1111 1111 1111 1111 1111 1111 1111 uuuu uuuu 1111 1111 1111 1111
PCC 1111 1111 1111 1111 1111 1111 1111 1111 uuuu uuuu 1111 1111 1111 1111
PD 1111 1111 1111 1111 1111 1111 1111 1111 uuuu uuuu 1111 1111 1111 1111
PDC 1111 1111 1111 1111 1111 1111 1111 1111 uuuu uuuu 1111 1111 1111 1111
PE 1111 1111 1111 1111 1111 1111 1111 1111 uuuu uuuu 1111 1111 1111 1111
PEC 1111 1111 1111 1111 1111 1111 1111 1111 uuuu uuuu 1111 1111 1111 1111
AWR 0000 0000 uuuu uuuu 0000 0000 0000 0000 uuuu uuuu 0000 0000 0000 0000
STALL --11 1110 --uu uuuu --11 1110 --11 1110 --uu uuuu --11 1110 --11 1110
MISC 0xx- -000 uxx- -uuu 0xx- -000 0xx- -000 uxx- -uuu 000- -000 000- -000
SETIO --11 1110 --uu uuuu --11 1110 --11 1110 --uu uuuu --11 1110 --11 1110
FIFO0 xxxx xxxx uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu 0000 0000 0000 0000
FIFO1 xxxx xxxx uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu 0000 0000 0000 0000
FIFO2 xxxx xxxx uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu 0000 0000 0000 0000
FIFO3 xxxx xxxx uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu 0000 0000 0000 0000
FIFO4 xxxx xxxx uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu 0000 0000 0000 0000
FIFO5 xxxx xxxx uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu 0000 0000 0000 0000
USC 1-00 0000 u-uu uuuu 1-00 0000 1-00 0000 u-uu uuuu u-00 0100 u-00 0100
USR --00 0000 --uu uuuu --00 0000 --00 0000 --uu uuuu --00 0000 --00 0000
UCC -000 0000 -uuu uuuu -000 0000 -000 0000 -uuu uuuu -uu0 u000 -uu0 u000
SIES 0100 0000 uuuu uuuu 0100 0000 0100 0000 uuuu uuuu 0100 0000 0100 0000
ADRL xx-- ---- xx-- ---- xx-- ---- xx-- ---- uu-- ---- xx-- ---- xx-- ----
ADRH xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx uuuu uuuu xxxx xxxx xxxx xxxx
ADCR 0100 0000 0100 0000 0100 0000 0100 0000 uuuu uuuu 0100 0000 0100 0000
ACSR 1--- --00 1--- --00 1--- --00 1--- --00 u--- --uu 1--- --00 1--- --00
PWM0 xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx uuuu uuuu uuuu uuuu uuuu uuuu
PWM1 xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx uuuu uuuu uuuu uuuu uuuu uuuu
PWM2 xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx uuuu uuuu uuuu uuuu uuuu uuuu
PWM3 xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx uuuu uuuu uuuu uuuu uuuu uuuu
SBCR 0110 0000 0110 0000 0110 0000 0110 0000 uuuu uuuu uuuu uuuu uuuu uuuu
SBDR xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx uuuu uuuu uuuu uuuu uuuu uuuu
P W M
(6 + 2 ) o r (7 + 1 )
C o m p a re T o P D 0 /P D 1 /P D 2 /P D 3 C ir c u it
D a ta B u s
fS Y S 8 - s ta g e P r e s c a le r
L o w B y te
f IN T
B u ffe r
8 -1 M U X
T 0 M 1
T 0 M 0
T 0 P S C 2 ~ T 0 P S C 0 T M R 0 1 6 - B it R e lo a d
P r e lo a d R e g is te r
T 0 E
P u ls e W id th H ig h B y te L o w B y te O v e r flo w to In te rru p t
T 0 M 1 M e a s u re m e n t
T 0 M 0 M o d e C o n tro l
T 0 O N 1 6 - B it T im e r /E v e n t C o u n te r
Timer/Event Counter 0
D a ta B u s
L o w B y te
f IN T B u ffe r
fS Y S /4
T 1 M 1
T 1 M 0
T M R 1 1 6 - B it R e lo a d
P r e lo a d R e g is te r
T 1 E
T 1 M 1 P u ls e W id th H ig h B y te L o w B y te O v e r flo w to In te r r u p t
M e a s u re m e n t
T 1 M 0 M o d e C o n tro l
T 1 O N 1 6 - B it T im e r /E v e n t C o u n te r
Timer/Event Counter 1
In the event count or timer mode, the timer/event coun- two modes, the T0ON/T1ON can only be reset by in-
ter starts counting at the current contents in the structions. The overflow of the Timer/Event Counter 0/1
timer/event counter and ends at FFFFH. Once an over- is one of the wake-up sources. No matter what the oper-
flow occurs, the counter is reloaded from the timer/event ation mode is, writing a 0 to ET0I or ET1I disables the re-
counter preload register, and generates an interrupt re- lated interrupt service.
quest flag (T0F; bit 5 of the INTC0, T1F; bit 6 of the In the case of timer/event counter OFF condition, writing
INTC0). data to the timer/event counter preload register also re-
In the pulse width measurement mode with the values of loads that data to the timer/event counter. But if the
the T0ON/T1ON and T0E/T1E bits equal to 1, after the timer/event counter is turned on, data written to the
TMR0 (TMR1) has received a transient from low to high timer/event counter is kept only in the timer/event coun-
ter preload register. The timer/event counter still contin-
(or high to low if the T0E/T1E bit is ²0²), it will start count-
ues its operation until an overflow occurs.
ing until the TMR0 (TMR1) returns to the original level
and resets the T0ON/T1ON. The measured result re- When the timer/event counter (reading TMR0/TMR1) is
read, the clock is blocked to avoid errors, as this may re-
mains in the timer/event counter even if the activated
sults in a counting error. Blocking of the clock should be
transient occurs again. In other words, only 1-cycle
taken into account by the programmer. It is strongly rec-
measurement can be made until the T0ON/T1ON is set.
ommended to load a desired value into the TMR0/TMR1
The cycle measurement will re-function as long as it re-
register first, before turning on the related timer/event
ceives further transient pulse. In this operation mode, counter, for proper operation since the initial value of
the timer/event counter begins counting not according TMR0/TMR1 is unknown. Due to the timer/event
to the logic level but to the transient edges. In the case of scheme, the programmer should pay special attention
counter overflows, the counter is reloaded from the on the instruction to enable then disable the timer for the
timer/event counter register and issues an interrupt re- first time, whenever there is a need to use the
quest, as in the other two modes, i.e., event and timer timer/event function, to avoid unpredictable result. After
modes. this procedure, the timer/event function can be operated
normally.
To enable the counting operation, the Timer ON bit
(T0ON: bit 4 of the TMR0C; T10N: bit 4 of the TMR1C) The bit0~bit2 of the TMR0C can be used to define the
should be set to 1. In the pulse width measurement pre-scaling stages of the internal clock sources of
mode, the T0ON/T1ON is automatically cleared after timer/event counter. The definitions are as shown. The
the measurement cycle is completed. But in the other timer prescaler is also used as the PWM counter.
Input/Output Ports depends on the control register. If the control register bit
There are 38 bidirectional input/output lines in the is ²1² the input will read the pad state. If the control reg-
microcontroller, labeled from PA to PE, which are ister bit is ²0² the contents of the latches will move to the
mapped to the data memory of [12H], [14H], [16H], i n t e r n a l b u s. T h e l a t t e r i s p o ssi b l e i n t h e
[18H] and [1A] respectively. All of these I/O ports can be ²Read-modify-write² instruction. For output function,
used for input and output operations. For input opera- CMOS is the only configuration. These control registers
tion, these ports are non-latching, that is, the inputs are mapped to locations 13H, 15H, 17H, 19H and 1BH.
must be ready at the T2 rising edge of instruction ²MOV After a chip reset, these input/output lines remain at high
A,[m]² (m=12H, 14H, 16H, 18H or 1A). For output oper- levels or floating state (depending on the pull-high op-
ation, all the data is latched and remains unchanged un- tions). Each bit of these input/output latches can be set
til the output latch is rewritten. or cleared by ²SET [m].i² and ²CLR [m].i² (m=12H, 14H,
Each I/O line has its own control register (PAC, PBC, 16H, 18H or 1AH ) instructions.
PCC, PDC, PEC) to control the input/output configura- Some instructions first input data and then follow the
tion. With this control register, CMOS output or Schmitt output operations. For example, ²SET [m].i², ²CLR
trigger input with or without pull-high resistor structures [m].i², ²CPL [m]², ²CPLA [m]² read the entire port states
can be reconfigured dynamically under software control. into the CPU, execute the defined operations
To function as an input, the corresponding latch of the (bit-operation), and then write the results back to the
control register must write a ²1². The input source also latches or the accumulator.
V D D
C o n tr o l B it P U
D a ta B u s D Q P A 0 ~ P A 7
P B 0 /A N 0 ~ P B 7 /A N 7
P C 0 /IN T
W r ite C o n tr o l R e g is te r C K Q
S P C 1 /T M R 0
P C 2 /T M R 1
C h ip R e s e t P C 3 ~ P C 7
P D 0 /P W M 0 ~ P D 3 /P W M 3
R e a d C o n tr o l R e g is te r P D 4 ~ P D 7
D a ta B it P E 0 /S C S
D Q P E 1 /C L K
P E 2 /S D I
W r ite D a ta R e g is te r C K Q P E 3 /S D O
S P E 4 ~ P E 5
M
P D 0 ~ P D 3 U
P W M 0 ~ P W M 3 X
M M a s k O p tio n
U
X
R e a d D a ta R e g is te r
S y s te m W a k e -u p
( P A o n ly ) M a s k O p tio n
IN T fo r P C 0
T M R 0 fo r P C 1
T M R 1 fo r P C 2
Input/Output Ports
Each line of Port A has the capability of waking-up the writing a ²0² will force the PD0/PD1/PD2/PD3 to remain
device. at ²0².
It is recommended that unused or not bonded out I/O A (6+2) bits mode PWM cycle is divided into four modu-
lines should be set as output pins by software instruction lation cycles (modulation cycle 0~modulation cycle 3).
to avoid consuming power under input floating state. Each modulation cycle has 64 PWM input clock period.
In a (6+2) bit PWM function, the contents of the PWM
Pulse Width Modulator - PWM register is divided into two groups. Group 1 of the PWM
The microcontroller provides 4 channels (6+2)/(7+1) register is denoted by DC which is the value of
(depending on options) bits PWM output shared with PWM.7~PWM.2.
PD0/PD1/PD2/PD3. The data register of the PWM Group 2 is denoted by AC which is the value of
channels are denoted as PWM0 (34H), PWM1 (35H), PWM.1~PWM.0.
PWM2 (36H) and PWM3 (37H). The frequency source
In a (6+2) bits mode PWM cycle, the duty cycle of each
of the PWM counter comes from fSYS. There are four
modulation cycle is shown in the table.
8-bit PWM registers. The waveforms of the PWM out-
puts are as shown. Once the PD0/PD1/PD2/PD3 are Parameter AC (0~3) Duty Cycle
selected as the PWM outputs and the output function of DC+1
PD0/PD1/PD2/PD3 are enabled (PDC.0/PDC.1/ i<AC
Modulation cycle i 64
PDC.2/PDC.3 =²0²), writing a ²1² to PD0/PD1/PD2/PD3 (i=0~3) DC
data register will enable the PWM output function and i³AC
64
fS Y S /2
[P W M ] = 1 0 0
P W M
2 5 /6 4 2 5 /6 4 2 5 /6 4 2 5 /6 4 2 5 /6 4
[P W M ] = 1 0 1
P W M
2 6 /6 4 2 5 /6 4 2 5 /6 4 2 5 /6 4 2 6 /6 4
[P W M ] = 1 0 2
P W M
2 6 /6 4 2 6 /6 4 2 5 /6 4 2 5 /6 4 2 6 /6 4
[P W M ] = 1 0 3
P W M
2 6 /6 4 2 6 /6 4 2 6 /6 4 2 5 /6 4 2 6 /6 4
P W M m o d u la tio n p e r io d : 6 4 /fS Y S
M o d u la tio n c y c le 0 M o d u la tio n c y c le 1 M o d u la tio n c y c le 2 M o d u la tio n c y c le 3 M o d u la tio n c y c le 0
P W M c y c le : 2 5 6 /fS Y S
fS Y S /2
[P W M ] = 1 0 0
P W M
5 0 /1 2 8 5 0 /1 2 8 5 0 /1 2 8
[P W M ] = 1 0 1
P W M
5 1 /1 2 8 5 0 /1 2 8 5 1 /1 2 8
[P W M ] = 1 0 2
P W M
5 1 /1 2 8 5 1 /1 2 8 5 1 /1 2 8
[P W M ] = 1 0 3
P W M
5 1 /1 2 8 5 2 /1 2 8
5 2 /1 2 8
P W M m o d u la tio n p e r io d : 1 2 8 /fS Y S
P W M c y c le : 2 5 6 /fS Y S
A (7+1) bits mode PWM cycle is divided into two modu- bit of the ADCR is used to begin the conversion of the
lation cycles (modulation cycle 0~modulation cycle 1). A/D converter. Giving START bit a rising edge and fall-
Each modulation cycle has 128 PWM input clock period. ing edge means that the A/D conversion has started. In
order to ensure that A/D conversion is completed, the
In a (7+1) bits PWM function, the contents of the PWM
register is divided into two groups. Group 1 of the PWM START bit should remain at ²0² until the EOCB is
register is denoted by DC which is the value of cleared to ²0² (end of A/D conversion).
PWM.7~PWM.1. Bit 7 of the ACSR register is used for test purposes only
Group 2 is denoted by AC which is the value of PWM.0. and must not be used for other purposes by the applica-
tion program. Bit1 and bit0 of the ACSR register are
In a (7+1) bits mode PWM cycle, the duty cycle of each
used to select the A/D clock source.
modulation cycle is shown in the table.
When the A/D conversion has completed, the A/D inter-
Parameter AC (0~1) Duty Cycle
rupt request flag will be set. The EOCB bit is set to ²1²
DC+1
i<AC when the START bit is set from ²0² to ²1².
Modulation cycle i 128
(i=0~1) DC Important Note for A/D initialisation:
i³AC Special care must be taken to initialise the A/D con-
128
verter each time the Port B A/D channel selection bits
The modulation frequency, cycle frequency and cycle are modified, otherwise the EOCB flag may be in an un-
duty of the PWM output signal are summarized in the defined condition. An A/D initialisation is implemented
following table. by setting the START bit high and then clearing it to zero
PWM PWM Cycle PWM Cycle within 10 instruction cycles of the Port B channel selec-
Modulation Frequency Frequency Duty tion bits being modified. Note that if the Port B channel
selection bits are all cleared to zero then an A/D initialis-
fSYS/64 for (6+2) bits mode
fSYS/256 [PWM]/256 ation is not required.
fSYS/128 for (7+1) bits mode
Bit No. Label Function
A/D Converter Selects the A/D converter clock source
This microcontroller has 8 channels and 10-bit resolu- 00= system clock/2
0 ADCS0
01= system clock/8
tion A/D (9-bit accuracy) converter. The reference volt- 1 ADCS1
10= system clock/32
age is VDD. The A/D converter contains 4 special
11= undefined
registers which are; ADRL (30H), ADRH (31H), ADCR
(32H) and ACSR (33H). The ADRH and ADRL are A/D
2~6 ¾ Unused bit, read as ²0²
result register higher-order byte and lower-order byte 7 TEST For test mode used only
and are read-only. After the A/D conversion is com- ACSR (33H) Register
pleted, the ADRH and ADRL should be read to get the
conversion result data. The ADCR is an A/D converter
control register, which defines the A/D channel number, Bit No. Label Function
analog channel select, start A/D conversion control bit 0 ACS0
and end of A/D conversion flag. If users want to start an 1 ACS1 Defines the analog channel select
A/D conversion, first, define PB configuration, select the 2 ACS2
converted analog channel, and give START bit a raising Defines the Port B configuration se-
3 PCR0
edge and falling edge (0®1®0). At the end of A/D con- lect. If PCR0, PCR1 and PCR2 are all
4 PCR1
zero, the ADC circuit is powered off to
version, the EOCB bit is cleared and an A/D converter 5 PCR2
reduce power consumption
interrupt occurs (if the A/D converter interrupt is en-
abled). The ACSR is A/D clock setting register, which is Indicates end of A/D conversion.
(0= end of A/D conversion)
used to select the A/D clock source.
Each time bits 3~5 change state the
The A/D converter control register is used to control the A/D should be initialised by issuing a
6 EOCB
A/D converter. The bit2~bit0 of the ADCR are used to START signal, otherwise the EOCB
select an analog input channel. There¢s a total of eight flag may have an undefined condi-
channels to select. The bit5~bit3 of the ADCR are used tion. See ²Important note for A/D in-
to set PB configurations. PB can be an analog input or itialisation².
as digital I/O line determined by these 3 bits. Once a PB Starts the A/D conversion.
line is selected as an analog input, the I/O functions and 0®1®0= Start
7 START
pull-high resistor of this I/O line are disabled and the A/D 0®1= Reset A/D converter and set
converter circuit is powered on. The EOCB bit (bit6 of EOCB to ²1².
the ADCR) is end of A/D conversion flag. Check this bit ADCR (32H) Register
to know when A/D conversion is completed. The START
ACS2 ACS1 ACS0 Analog Channel When the A/D conversion is completed, the A/D inter-
rupt request flag is set. The EOCB bit is set to ²1² when
0 0 0 AN0
the START bit is set from ²0² to ²1².
0 0 1 AN1
Register Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
0 1 0 AN2
ADRL D1 D0 ¾ ¾ ¾ ¾ ¾ ¾
0 1 1 AN3
ADRH D9 D8 D7 D6 D5 D4 D3 D2
1 0 0 AN4
1 0 1 AN5 Note: D0~D9 is A/D conversion result data bit
LSB~MSB.
1 1 0 AN6
1 1 1 AN7
Port B Configuration
S T A R T
P C R 2 ~ 0 0 0 B 1 0 0 B 1 0 0 B 1 0 1 B 0 0 0 B
P C R 0
1 . P B p o rt s e tu p a s I/O s
2 . A /D c o n v e r te r is p o w e r e d o ff
to r e d u c e p o w e r c o n s u m p tio n
A C S 2 ~
A C S 0 0 0 0 B 0 1 0 B 0 0 0 B 0 0 1 B d o n 't c a r e
P o w e r-o n S ta rt o f A /D S ta rt o f A /D S ta rt o f A /D
R e s e t c o n v e r s io n c o n v e r s io n c o n v e r s io n
R e s e t A /D R e s e t A /D R e s e t A /D
c o n v e rte r c o n v e rte r c o n v e rte r
E n d o f A /D E n d o f A /D E n d o f A /D
1 : D e fin e P B c o n fig u r a tio n c o n v e r s io n c o n v e r s io n c o n v e r s io n
2 : S e le c t a n a lo g c h a n n e l
tA D C tA D C tA D C
A /D c o n v e r s io n tim e A /D c o n v e r s io n tim e A /D c o n v e r s io n tim e
N o te : A /D c lo c k m u s t b e fS Y S /2 , fS Y S /8 o r fS Y S /3 2
tA D C S = 3 2 tA D
tA D C = 7 6 tA D
The following two programming examples illustrate how to setup and implement an A/D conversion. In the first exam-
ple, the method of polling the EOCB bit in the ADCR register is used to detect when the conversion cycle is complete,
whereas in the second example, the A/D interrupt is used to determine when the conversion is complete.
Example: using EOCB Polling Method to detect end of conversion
clr EADI ; disable ADC interrupt
mov a,00000001B
mov ACSR,a ; setup the ACSR register to select fSYS/8 as the A/D clock
mov a,00100000B ; setup ADCR register to configure Port PB0~PB3 as A/D inputs
mov ADCR,a ; and select AN0 to be connected to the A/D converter
:
: ; As the Port B channel bits have changed the following START
; signal (0-1-0) must be issued within 10 instruction cycles
:
Start_conversion:
clr START
set START ; reset A/D
clr START ; start A/D
Polling_EOC:
sz EOCB ; poll the ADCR register EOCB bit to detect end of A/D conversion
jmp polling_EOC ; continue polling
mov a,ADRH ; read conversion result high byte value from the ADRH register
mov adrh_buffer,a ; save result to user defined memory
mov a,ADRL ; read conversion result low byte value from the ADRL register
mov adrl_buffer,a ; save result to user defined memory
:
:
jmp Start_conversion ; start next A/D conversion
Example: using Interrupt Method to detect end of conversion
clr EADI ; disable ADC interrupt
mov a,00000001B
mov ACSR,a ; setup the ACSR register to select fSYS/8 as the A/D clock
mov a,00100000B ; setup ADCR register to configure Port PB0~PB3 as A/D inputs
mov ADCR,a ; and select AN0 to be connected to the A/D converter
:
; As the Port B channel bits have changed the following START
; signal (0-1-0) must be issued within 10 instruction cycles
:
Start_conversion:
clr START
set START ; reset A/D
clr START ; start A/D
clr ADF ; clear ADC interrupt request flag
set EADI ; enable ADC interrupt
set EMI ; enable global interrupt
:
:
:
; ADC interrupt service routine
ADC_ISR:
mov acc_stack,a ; save ACC to user defined memory
mov a,STATUS
mov status_stack,a ; save STATUS to user defined memory
:
:
mov a,ADRH ; read conversion result high byte value from the ADRH register
mov adrh_buffer,a ; save result to user defined register
mov a,ADRL ; read conversion result low byte value from the ADRL register
mov adrl_buffer,a ; save result to user defined register
clr START
set START ; reset A/D
clr START ; start A/D
:
:
EXIT_INT_ISR:
mov a,status_stack
mov STATUS,a ; restore STATUS from user defined memory
mov a,acc_stack ; restore ACC from user defined memory
reti
Low Voltage Reset - LVR The relationship between VDD and VLVR is shown below.
The microcontroller provides low voltage reset circuit in
V D D V O P R
order to monitor the supply voltage of the device. If the 5 .5 V 5 .5 V
supply voltage of the device is within the range
0.9V~VLVR, such as changing a battery, the LVR will au-
tomatically reset the device internally.
The LVR includes the following specifications: V L V R
3 .0 V
· The low voltage range (0.9V~VLVR) has to be main-
2 .2 V
tained for over 1ms, otherwise, the LVR will ignore it
and do not perform a reset function.
· The LVR uses the ²OR² function with the external RES
0 .9 V
signal to perform a chip reset.
Note: VOPR is the voltage range for proper chip
operation at 4MHz system clock.
V D D
5 .5 V
V L V R L V R D e te c t V o lta g e
0 .9 V
0 V
R e s e t S ig n a l
R e s e t N o r m a l O p e r a tio n R e s e t
*1 *2
Note: *1: To make sure that the system oscillator has stabilized, the SST provides an extra delay of 1024 system
clock pulses before resuming normal operation.
*2: Low voltage state has to be maintained in its original state for over 1ms, then after 1ms delay,
the device enters the reset mode.
Serial Interface
Serial interface function has four basic signals included. They are SDI (serial data input), SDO (serial data output), SCK
(serial clock) and SCS (slave select pin).
Note: SCS can be named SCS in the design note.
S C S
C L K
S D I D 7 /D 0 D 6 /D 1 D 5 /D 2 D 4 /D 3 D 3 /D 4 D 2 /D 5 D 1 /D 6 D 0 /D 7
S D O D 7 /D 0 D 6 /D 1 D 5 /D 2 D 4 /D 3 D 3 /D 4 D 2 /D 5 D 1 /D 6 D 0 /D 7
D 7 D 6 D 5 D 4 D 3 D 2 D 1 D 0
S B C R C K S M 1 M 0 S B E N M L S C S E N W C O L T R F S B C R : S E R IA L B U S
D E F A U L T 0 1 1 0 0 0 0 0 C O N T R O L R E G IS T E R
S B D R D 7 D 6 D 5 D 4 D 3 D 2 D 1 D 0 S B D R : S E R IA L B U S
D E F A U L T U U U U U U U U D A T A R E G IS T E R
N o te : "U " m e a n s u n c h a n g e d .
Two registers (SBCR and SBDR) unique to serial inter- ¨ Disable: SCK (SCK), SDI, SDO, SCS floating
face provide control, status, and data storage. Bit3 (MLS) ® MSB or LSB (1/0) shift first control bit
· SBCR: Serial bus control register Bit2 (CSEN) ® serial bus selection signal en-
Bit7 (CKS) clock source selection: fSIO=fSYS/4, select able/disable (SCS), when CSEN=0, SCSB is float-
as 0 ing.
Bit6 (M1), Bit5 (M0) master/slave mode and baud rate Bit1 (WCOL) ® this bit is set to 1 if data is written to
selection SBDR (TXRX buffer) when data is transferred,
M1, M0: 00 ® MASTER MODE, BAUD RATE= fSIO writing will be ignored if data is written to SBDR
01 ® MASTER MODE, BAUD RATE= fSIO/4 (TXRX buffer) when data is transferred.
10 ® MASTER MODE, BAUD RATE= fSIO/16 Bit0 (TRF) ® data transferred or data received
11 ® SLAVE MODE used to generate an interrupt.
· Bit4 (SBEN) ® serial bus enable/disable (1/0) Note: data receiving is still working when the MCU
enters HALT mode.
¨ Enable: (SCS dependent on CSEN bit)
· SBDR: Serial bus data register
Disable ® enable: SCK, SDI, SDO, SCS= 0
Data written to SBDR ® write data to TXRX buffer
(SCKB= ²0²) and waiting for writing data to SBDR
only
(TXRX buffer)
Data read from SBDR ® read from SBDR only
Master mode: write data to SBDR (TXRX buffer)
Operating Mode description:
start transmission/reception automatically
Master transmitter: clock sending and data I/O started
Master mode: when data has been transferred, set by writing SBDR
TRF Master clock sending started by writing SBDR
Slave mode: when an SCK (and SCS dependent on Slave transmitter: data I/O started by clock received
CSEN) is received, data in TXRX buffer is Slave receiver: data I/O started by clock received
shifted-out and data on SDI is shifted-in.
Modes Operations
1. Select CKS and select M1, M0 = 00,01,10
2. Select CSEN, MLS (the same as the slave)
3. Set SBEN
4. Writing data to SBDR ® data is stored in TXRX buffer ® output CLK (and SCS) signals ® go to
step 5 ® (SIO internal operation ® data stored in TXRX buffer, and SDI data is shifted into TXRX
Master buffer ® data transferred, data in TXRX buffer is latched into SBDR)
5. Check WCOL; WCOL= 1 ® clear WCOL and go to step 4; WCOL= 0 ® go to step 6
6. Check TRF or waiting for SBI (serial bus interrupt)
7. Read data from SBDR
8. Clear TRF
9. Go to step 4
WCOL: master/slave mode, set while writing to SBDR SCS pin (master and slave) should be floating. CSEN
when data is transferring (transmitting or receiving) and has 2 options: CSEN mask option is used to enable/dis-
this writing will then be ignored. WCOL function can be able software CSEN function. If CSEN mask option is
enabled/disabled by mask option. WCOL is set by SIO disabled, the software CSEN is always disabled. If
and cleared by users. CSEN mask option is enabled, software CSEN function
can be used.
Data transmission and reception are still working when
the MCU enters the HALT mode. SBEN= 1 ® serial bus standby; SCS (CSEN= 1) = 1;
CPOL is used to select the clock polarity of CLK. It is a SCS= floating (CSEN= 0); SDI= floating; SDO= 1; mas-
mask option. ter CLK= output 1/0 (dependent on CPOL mask option),
slave CLK= floating
MLS: MSB or LSB first selection
SBEN= 0 ® serial bus disabled; SCS= SDI= SDO=
CSEN: chip select function enable/disable, CSEN=1 ® CLK= floating
SCS signal function is active. Master should output SCS
signal before CLK signal is set and slave data transfer- TRF is set by SIO and cleared by users. When data
ring should be disabled (or enabled) before (after) SCS transfer (transmission and reception) is completed, TRF
signal is received. CSEN= 0, SCS signal is not needed, is set to generate SBI (serial bus interrupt).
S B E N = 1 , C S E N = 0 a n d w r ite d a ta to S B D R ( if p u ll- h ig h e d )
S C S S B E N = C S E N = 1 a n d w r ite d a ta to S B D R
C L K
S D I D 7 /D 0 D 6 /D 1 D 5 /D 2 D 4 /D 3 D 3 /D 4 D 2 /D 5 D 1 /D 6 D 0 /D 7
S D O D 7 /D 0 D 6 /D 1 D 5 /D 2 D 4 /D 3 D 3 /D 4 D 2 /D 5 D 1 /D 6 D 0 /D 7
C L K B
D 7 D 6 D 5 D 4 D 3 D 2 D 1 D 0
S B C R C K S M 1 M 0 S B E N M L S C S E N W C O L T R F
D e fa u lt 0 1 1 0 0 0 0 0
S B D R D 7 D 6 D 5 D 4 D 3 D 2 D 1 D 0
D e fa u lt u u u u u u u u
N o te : "u " m e a n s u n c h a n g e d .
D a ta B u s
S B D R ( R e c e iv e d D a ta R e g is te r )
D 7 D 6 D 5 D 4 D 3 D 2 D 1 D 0 M
U S D O B u ffe r S D O
X
M L S S B E N
M
U S D I
In te r n a l B a u d R a te C lo c k X
a n d , s ta rt M
E N U
C L K X
a n d , s ta rt C 0 C 1 C 2 T R F
C lo c k P o la r ity M a s te r o r S la v e A N D W C O L F la g
S B E N In te r n a l B u s y F la g
W r ite S B D R
S B E N W r ite S B D R E n a b le /D is a b le
a n d , s ta rt
W r ite S B D R
E N S C S
M a s te r o r S la v e
S B E N
C S E N
W C O L : s e t b y S IO c le a r e d b y u s e r s
C S E N : e n a b le /d is a b le c h ip s e le c tio n fu n c tio n p in
1 . m a s te r m o d e 1 /0 : w ith /w ith o u t S C S B o u tp u t fu n c tio n
2 . s la v e m o d e 1 /0 : w ith /w ith o u t S C S B in p u t c o n tro l fu n c tio n
S B E N : e n a b le /d is a b le s e r ia l b u s ( 0 : in itia liz e a ll s ta tu s fla g s )
1 . W h e n S B E N = 0 , a ll s ta tu s fla g s s h o u ld b e in itia liz e d
2 . W h e n S B E N = 0 , a ll S IO r e la te d fu n c tio n p in s s h o u ld s ta y a t flo a tin g s ta te
T R F 1 : d a ta tr a n s m itte d o r r e c e iv e d , 0 : d a ta is tr a n s m ittin g o r s till n o t r e c e iv e d
C P O L 1 /0 : c lo c k p o la r ity r is in g /fa llin g e d g e : m a s k o p tio n
Suspend Wake-Up or Remote Wake-Up the USB Host by sending a wake-up pulse through
RMWK (bit 1 of the USC). Once the USB Host receive
If there is no signal on the signal bus for over 3ms, the
the wake-up signal from the HT46RB70, it will send a
HT46RB70 will go into suspend mode . The suspend
Resume signal to the device. The timing is as follow:
line (bit 0 of the USC) will be set to 1 and a USB interrupt
is triggered to indicate that the HT46RB70 should jump
USB Interface
to suspend state to meet the 500mA USB suspend cur-
rent spec.
S U S P E N D
In order to meet the 500mA suspend current, the firm-
M in . 1 U S B C L K
ware should disable the USB clock by clearing the
R M W K
USBCKEN (bit3 of the UCC) to ²0². The suspend cur-
rent is about 400mA.
M in .2 .5 m s
The user can also further decrease the suspend current U S B R e s u m e S ig n a l
S U S P E N D
U S B R e s u m e S ig n a l
U S B _ IN T
The USR (USB endpoint interrupt status register) register is used to indicate which endpoint is accessed and then se-
lects A/D converter operation modes. The endpoint request flags (EP0IF, EP1IF, EP2IF, EP3IF, EP4IF and EP5IF) are
used to indicate which endpoints are accessed. If an endpoint is accessed, the related endpoint request flag will be set
to ²1² and the USB interrupt will occur (if the USB interrupt is enabled and the stack is not full). When the active end-
point request flag is served, the endpoint request flag has to be cleared to ²0².
Bit No. Label R/W Function
When this bit is set to ²1² (set by SIE), it indicates that the endpoint 0 is accessed
0 EP0IF R/W and a USB interrupt will occur. When the interrupt has been served, this bit should
be cleared by firmware.
When this bit is set to ²1² (set by SIE), it indicates that the endpoint 1 is accessed
1 EP1IF R/W and a USB interrupt will occur. When the interrupt has been served, this bit should
be cleared by firmware.
When this bit is set to ²1² (set by SIE), it indicates that the endpoint 2 is accessed
2 EP2IF R/W and a USB interrupt will occur. When the interrupt has been served, this bit should
be cleared by firmware.
When this bit is set to ²1² (set by SIE), it indicates that the endpoint 3 is accessed
3 EP3IF R/W and a USB interrupt will occur. When the interrupt has been served, this bit should
be cleared by firmware.
When this bit is set to ²1² (set by SIE), it indicates that the endpoint 4 is accessed
4 EP4IF R/W and a USB interrupt will occur. When the interrupt has been served, this bit should
be cleared by firmware.
When this bit is set to ²1² (set by SIE), it indicates that the endpoint 5 is accessed
5 EP5IF R/W and a USB interrupt will occur. When the interrupt has been served, this bit should
be cleared by firmware.
6~7 ¾ ¾ Undefined bit, read as ²0²
USR (21H) Definitions
There is a system clock control register implemented to select the clock used in the MCU. This register consists of USB
clock control bit (USBCKEN), second suspend mode control bit (SUSP2) and system clock selection (SYSCLK)
The following table defines which endpoint FIFO is selected, EPS2, EPS1 and EPS0.
Bit No. Label R/W Function
Accessing endpoint FIFO selection.
EPS2, EPS1, EPS0:
000: Select endpoint 0 FIFO
001: Select endpoint 1 FIFO
010: Select endpoint 2 FIFO
0~2 EPS0~EPS2 R/W 011: Select endpoint 3 FIFO
100: Select endpoint 4 FIFO
101: Select endpoint 5 FIFO
110: Reserved for future expansion, cannot be used
111: Reserved for future expansion, cannot be used
If the selected endpoints do not exist, the related functions are not available.
USB clock control bit. When this bit is set to ²1², it indicates that the USB clock
3 USBCKEN R/W is enabled.
Otherwise, the USB clock is turned-off.
This bit is used to reduce power consumption in suspend mode.
4 SUSP2 R/W In normal mode, clear this bit to 0 (default)
In HALT mode, set this bit to 1 to reduce power consumption.
This bit is used to define the MCU system clock to come from either the exter-
fSYS nal OSC or from PLL output 24MHz clock.
5 R/W
(24MHz) 0: system clock comes from OSC
1: system clock comes from PLL output 24MHz
This bit is used to specify the system clock oscillator frequency used by the
MCU. If a 6MHz crystal oscillator or resonator is used, this bit should be set to
6 SYSCLK R/W
²1². If a 12MHz crystal oscillator or resonator is used. this bit should be cleared
to ²0² (default).
7 ¾ ¾ Undefined, read as ²0²
The AWR register contains the current address and the remote wake-up function control bit. The initial value of the
AWR is ²00H². The address value extracted from the USB command is not to be loaded into this register until the
SETUP stage is finished.
The STALL register shows whether the corresponding endpoint works properly or not. As soon as the endpoint works
improperly, the related bit in the STALL has to be set to ²1². The STALL will be cleared by the USB reset signal.
MISC register combines a command and status to control the desired endpoint FIFO action and to show the status of
the desired endpoint FIFO. The MISC will be cleared by USB reset signal.
There are some timing constrains and usages illustrated here. By setting the MISC register, MCU can perform reading,
writing and clearing actions. There are some examples shown in the following table for endpoint FIFO reading, writing
and clearing.
Note: *: There are 2ms existing between 2 reading action or between 2 writing action
R e q . R e q .
T x T x
R e a d y R e a d y
R e a d F IF O T im in g W r ite F IF O T im in g
SETIO Register (27H), USB Endpoint 1~Endpoint5 Set IN/OUT Pipe Register
Note: *USB definition: when the host sends a ²set Configuration², the Data pipe should send the DATA0 (Data tog-
gle) first. So, when the device receives a ²set configuration² setup command, user needs to toggle this bit so
the next data will send a Data0 first.
**Needs to set the data pipe as an input pile or output pile. The purpose of this function is to avoid the host from
abnormally sending only an IN or OUT token and disables the endpoint.
Options
The following table shows all kinds of options in the microcontroller. All of the OTP options must be defined to ensure a
proper functioning system.
No. Option
1 PA0~PA7 pull-high resistor enable or disable (by bit)
2 PB0~PB7 pull down resistor enable or disable (by bit)
3 PC0~PC7 pull-high resistor enable or disable (by nibble)
4 PD0~PD7 pull-high resistor enable or disable (by nibble)
No. Option
5 PE0~PE5 pull-high resistor enable or disable (by nibble)
6 LVR enable or disable
PWM selection: (7+1) or (6+2) mode
PD0: level output or PWM0 output
7 PD1: level output or PWM1 output
PD2: level output or PWM2 output
PD3: level output or PWM3 output
8 SIO (Serial Interface) enable/disable (if SIO is enabled then PE0~PE3 I/O port will be disabled)
9 SIO_ CPOL: Clock polarity 1/0: clock polarity rising or falling edge
10 SIO_WCOL: Enable/disable
11 SIO_CSEN: Enable/disable, CSEN mask option is used to enable/disable (1/0) software CSEN function
12 WDT enable/disable
13 WDT clock source: fSYS/4 or WDTOSC
14 WDT timeout period: 212/fS~213/fS, 213/fS~214/fS, 214/fS~215/fS, 215/fS~216/fS
15 ²CLRWDT² instruction (s): 1 or 2
16 PA0~PA7 wake-up enable/disable (by bit)
17* EP1~EP5 Data pipe enable: EP1, EP2, EP3, EP4, EP5 enable/disable. (Default is enable)
Note: *: The purpose of this option is to enable the endpoint that will be used, and disable the endpoint that will not be
used.
Application Circuits
P A 0 ~ P A 7
5 W * 3 3 W *
V D D V D D P B 0 ~ P B 7
U S B - 0 .1 m F * 1 0 0 k W 0 .1 m F P C 0 ~ P C 7
U S B + P D 0 ~ P D 7
1 0 k W
V S S R E S P E 0 ~ P E 5
0 .1 m F * 0 .1 m F *
5 W * 0 .1 m F
V 3 3 O
4 7 p F *
3 3 W *
2 2 p F U S B D -
O S C 1
4 7 p F * 1 .5 k W 4 7 p F
3 3 W *
2 2 p F U S B D +
O S C 2
V S S 4 7 p F
H T 4 6 R B 7 0
Note: The resistance and capacitance for reset circuit should be designed in such a way as to ensure that the VDD is
stable and remains within a valid operating voltage range before bringing RES to high.
X1 can use 6MHz or 12MHz, X1 as close to OSC1 and OSC2 as possible
Components with ²*² are used for EMC issue
22pF capacitance are used for resonator only
Instruction Flag
Mnemonic Description
Cycle Affected
Branch
JMP addr Jump unconditionally 2 None
SZ [m] Skip if data memory is zero 1(2) None
SZA [m] Skip if data memory is zero with data movement to ACC 1(2) None
SZ [m].i Skip if bit i of data memory is zero 1(2) None
SNZ [m].i Skip if bit i of data memory is not zero 1(2) None
SIZ [m] Skip if increment data memory is zero 1(3) None
SDZ [m] Skip if decrement data memory is zero 1(3) None
SIZA [m] Skip if increment data memory is zero with result in ACC 1(2) None
SDZA [m] Skip if decrement data memory is zero with result in ACC 1(2) None
CALL addr Subroutine call 2 None
RET Return from subroutine 2 None
RET A,x Return from subroutine and load immediate data to ACC 2 None
RETI Return from interrupt 2 None
Table Read
TABRDC [m] Read ROM code (current page) to data memory and TBLH 2(1) None
TABRDL [m] Read ROM code (last page) to data memory and TBLH 2(1) None
Miscellaneous
NOP No operation 1 None
CLR [m] Clear data memory 1(1) None
SET [m] Set data memory 1(1) None
CLR WDT Clear Watchdog Timer 1 TO,PDF
CLR WDT1 Pre-clear Watchdog Timer 1 TO(4),PDF(4)
CLR WDT2 Pre-clear Watchdog Timer 1 TO(4),PDF(4)
SWAP [m] Swap nibbles of data memory 1(1) None
SWAPA [m] Swap nibbles of data memory with result in ACC 1 None
HALT Enter power down mode 1 TO,PDF
Instruction Definition
¾ ¾ Ö Ö Ö Ö
¾ ¾ Ö Ö Ö Ö
¾ ¾ Ö Ö Ö Ö
¾ ¾ Ö Ö Ö Ö
¾ ¾ Ö Ö Ö Ö
¾ ¾ ¾ Ö ¾ ¾
¾ ¾ ¾ Ö ¾ ¾
¾ ¾ ¾ Ö ¾ ¾
¾ ¾ ¾ ¾ ¾ ¾
¾ ¾ ¾ ¾ ¾ ¾
¾ ¾ ¾ ¾ ¾ ¾
¾ ¾ ¾ Ö ¾ ¾
CPLA [m] Complement data memory and place result in the accumulator
Description Each bit of the specified data memory is logically complemented (1¢s complement). Bits
which previously contained a 1 are changed to 0 and vice-versa. The complemented result
is stored in the accumulator and the contents of the data memory remain unchanged.
Operation ACC ¬ [m]
Affected flag(s)
TO PDF OV Z AC C
¾ ¾ ¾ Ö ¾ ¾
¾ ¾ ¾ ¾ ¾ Ö
¾ ¾ ¾ Ö ¾ ¾
DECA [m] Decrement data memory and place result in the accumulator
Description Data in the specified data memory is decremented by 1, leaving the result in the accumula-
tor. The contents of the data memory remain unchanged.
Operation ACC ¬ [m]-1
Affected flag(s)
TO PDF OV Z AC C
¾ ¾ ¾ Ö ¾ ¾
¾ ¾ ¾ Ö ¾ ¾
INCA [m] Increment data memory and place result in the accumulator
Description Data in the specified data memory is incremented by 1, leaving the result in the accumula-
tor. The contents of the data memory remain unchanged.
Operation ACC ¬ [m]+1
Affected flag(s)
TO PDF OV Z AC C
¾ ¾ ¾ Ö ¾ ¾
¾ ¾ ¾ ¾ ¾ ¾
¾ ¾ ¾ ¾ ¾ ¾
¾ ¾ ¾ ¾ ¾ ¾
¾ ¾ ¾ ¾ ¾ ¾
NOP No operation
Description No operation is performed. Execution continues with the next instruction.
Operation Program Counter ¬ Program Counter+1
Affected flag(s)
TO PDF OV Z AC C
¾ ¾ ¾ ¾ ¾ ¾
¾ ¾ ¾ Ö ¾ ¾
¾ ¾ ¾ Ö ¾ ¾
¾ ¾ ¾ Ö ¾ ¾
¾ ¾ ¾ ¾ ¾ ¾
¾ ¾ ¾ ¾ ¾ ¾
¾ ¾ ¾ ¾ ¾ ¾
¾ ¾ ¾ ¾ ¾ ¾
RLA [m] Rotate data memory left and place result in the accumulator
Description Data in the specified data memory is rotated 1 bit left with bit 7 rotated into bit 0, leaving the
rotated result in the accumulator. The contents of the data memory remain unchanged.
Operation ACC.(i+1) ¬ [m].i; [m].i:bit i of the data memory (i=0~6)
ACC.0 ¬ [m].7
Affected flag(s)
TO PDF OV Z AC C
¾ ¾ ¾ ¾ ¾ ¾
RLCA [m] Rotate left through carry and place result in the accumulator
Description Data in the specified data memory and the carry flag are rotated 1 bit left. Bit 7 replaces the
carry bit and the original carry flag is rotated into bit 0 position. The rotated result is stored
in the accumulator but the contents of the data memory remain unchanged.
Operation ACC.(i+1) ¬ [m].i; [m].i:bit i of the data memory (i=0~6)
ACC.0 ¬ C
C ¬ [m].7
Affected flag(s)
TO PDF OV Z AC C
¾ ¾ ¾ ¾ ¾ Ö
RRCA [m] Rotate right through carry and place result in the accumulator
Description Data of the specified data memory and the carry flag are rotated 1 bit right. Bit 0 replaces
the carry bit and the original carry flag is rotated into the bit 7 position. The rotated result is
stored in the accumulator. The contents of the data memory remain unchanged.
Operation ACC.i ¬ [m].(i+1); [m].i:bit i of the data memory (i=0~6)
ACC.7 ¬ C
C ¬ [m].0
Affected flag(s)
TO PDF OV Z AC C
¾ ¾ ¾ ¾ ¾ Ö
SBC A,[m] Subtract data memory and carry from the accumulator
Description The contents of the specified data memory and the complement of the carry flag are sub-
tracted from the accumulator, leaving the result in the accumulator.
Operation ACC ¬ ACC+[m]+C
Affected flag(s)
TO PDF OV Z AC C
¾ ¾ Ö Ö Ö Ö
SBCM A,[m] Subtract data memory and carry from the accumulator
Description The contents of the specified data memory and the complement of the carry flag are sub-
tracted from the accumulator, leaving the result in the data memory.
Operation [m] ¬ ACC+[m]+C
Affected flag(s)
TO PDF OV Z AC C
¾ ¾ Ö Ö Ö Ö
¾ ¾ ¾ ¾ ¾ ¾
SDZA [m] Decrement data memory and place result in ACC, skip if 0
Description The contents of the specified data memory are decremented by 1. If the result is 0, the next
instruction is skipped. The result is stored in the accumulator but the data memory remains
unchanged. If the result is 0, the following instruction, fetched during the current instruction
execution, is discarded and a dummy cycle is replaced to get the proper instruction (2 cy-
cles). Otherwise proceed with the next instruction (1 cycle).
Operation Skip if ([m]-1)=0, ACC ¬ ([m]-1)
Affected flag(s)
TO PDF OV Z AC C
¾ ¾ ¾ ¾ ¾ ¾
¾ ¾ ¾ ¾ ¾ ¾
¾ ¾ ¾ ¾ ¾ ¾
¾ ¾ ¾ ¾ ¾ ¾
SIZA [m] Increment data memory and place result in ACC, skip if 0
Description The contents of the specified data memory are incremented by 1. If the result is 0, the next
instruction is skipped and the result is stored in the accumulator. The data memory re-
mains unchanged. If the result is 0, the following instruction, fetched during the current in-
struction execution, is discarded and a dummy cycle is replaced to get the proper
instruction (2 cycles). Otherwise proceed with the next instruction (1 cycle).
Operation Skip if ([m]+1)=0, ACC ¬ ([m]+1)
Affected flag(s)
TO PDF OV Z AC C
¾ ¾ ¾ ¾ ¾ ¾
¾ ¾ ¾ ¾ ¾ ¾
¾ ¾ Ö Ö Ö Ö
¾ ¾ Ö Ö Ö Ö
¾ ¾ Ö Ö Ö Ö
¾ ¾ ¾ ¾ ¾ ¾
SWAPA [m] Swap data memory and place result in the accumulator
Description The low-order and high-order nibbles of the specified data memory are interchanged, writ-
ing the result to the accumulator. The contents of the data memory remain unchanged.
Operation ACC.3~ACC.0 ¬ [m].7~[m].4
ACC.7~ACC.4 ¬ [m].3~[m].0
Affected flag(s)
TO PDF OV Z AC C
¾ ¾ ¾ ¾ ¾ ¾
¾ ¾ ¾ ¾ ¾ ¾
¾ ¾ ¾ ¾ ¾ ¾
¾ ¾ ¾ ¾ ¾ ¾
TABRDC [m] Move the ROM code (current page) to TBLH and data memory
Description The low byte of ROM code (current page) addressed by the table pointer (TBLP) is moved
to the specified data memory and the high byte transferred to TBLH directly.
Operation [m] ¬ ROM code (low byte)
TBLH ¬ ROM code (high byte)
Affected flag(s)
TO PDF OV Z AC C
¾ ¾ ¾ ¾ ¾ ¾
TABRDL [m] Move the ROM code (last page) to TBLH and data memory
Description The low byte of ROM code (last page) addressed by the table pointer (TBLP) is moved to
the data memory and the high byte transferred to TBLH directly.
Operation [m] ¬ ROM code (low byte)
TBLH ¬ ROM code (high byte)
Affected flag(s)
TO PDF OV Z AC C
¾ ¾ ¾ ¾ ¾ ¾
¾ ¾ ¾ Ö ¾ ¾
¾ ¾ ¾ Ö ¾ ¾
¾ ¾ ¾ Ö ¾ ¾
Package Information
28-pin SOP (300mil) Outline Dimensions
2 8 1 5
A B
1 1 4
C '
G
D H
E F a
Dimensions in mil
Symbol
Min. Nom. Max.
A 394 ¾ 419
B 290 ¾ 300
C 14 ¾ 20
C¢ 697 ¾ 713
D 92 ¾ 104
E ¾ 50 ¾
F 4 ¾ ¾
G 32 ¾ 38
H 4 ¾ 12
a 0° ¾ 10°
2 8 1 5
B
1 1 4
D
a I
E F G
Dimensions in mil
Symbol
Min. Nom. Max.
A 1375 ¾ 1395
B 278 ¾ 298
C 125 ¾ 135
D 125 ¾ 145
E 16 ¾ 20
F 50 ¾ 70
G ¾ 100 ¾
H 295 ¾ 315
I 330 ¾ 375
a 0° ¾ 15°
4 8 2 5
A B
1 2 4
C '
G
D H
a
E F
Dimensions in mil
Symbol
Min. Nom. Max.
A 395 ¾ 420
B 291 ¾ 299
C 8 ¾ 12
C¢ 613 ¾ 637
D 85 ¾ 99
E ¾ 25 ¾
F 4 ¾ 10
G 25 ¾ 35
H 4 ¾ 12
a 0° ¾ 8°
D
T 2
A B C
T 1
SSOP 48W
P 0 P 1
D t
F
W
B 0
C
D 1 P
K 0
A 0
P 0 P 1 t
D
F
W C B 0
K 1
D 1 P
K 2
A 0
SSOP 48W