Touch Key Flash Type 8-Bit MCU with LCD/LED Driver
BS85B12-3/BS85C20-3/BS85C20-5
Revision: V1.20
Date: ½½½½st 10½ 2012
BS85B12-3/BS85C20-3/BS85C20-5
Touch Key Flash MCU with LCD/LED Driver
Table of Contents
Features ............................................................................................................ 7
CPU Feat½res ......................................................................................................................... 7
Peripheral Feat½res................................................................................................................. 7
Selection Table ................................................................................................. 8
Block Diagram.................................................................................................. 9
Pin Assignment ................................................................................................ 9
Pin Description ...............................................................................................11
BS85B12-3 .............................................................................................................................11
BS85C20-3............................................................................................................................ 13
BS85C20-5............................................................................................................................ 17
Absolute Maximum Ratings.......................................................................... 20
D.C. Characteristics....................................................................................... 21
A.C. Characteristics....................................................................................... 22
Power-on Reset Characteristics................................................................... 23
Oscillator Temperature/Frequency Characteristics ................................... 24
System Architecture ...................................................................................... 26
Clockin½ and Pipelinin½ ......................................................................................................... 26
Pro½ram Co½nter................................................................................................................... 27
Stack ..................................................................................................................................... 28
½rithmetic and Lo½ic Unit – ½LU ........................................................................................... 28
Flash Program Memory ................................................................................. 29
Str½ct½re................................................................................................................................ 29
Special Vectors ..................................................................................................................... 29
Look-½p Table ........................................................................................................................ 29
Table Pro½ram Example ........................................................................................................ 30
In Circ½it Pro½rammin½ ......................................................................................................... 31
RAM Data Memory ......................................................................................... 32
Str½ct½re................................................................................................................................ 32
Special Function Register Description ........................................................ 32
Indirect ½ddressin½ Re½isters – I½R0½ I½R1 ......................................................................... 32
Memory Pointers – MP0½ MP1 .............................................................................................. 33
Bank Pointer – BP ................................................................................................................. 35
½cc½m½lator – ½CC ............................................................................................................... 36
Pro½ram Co½nter Low Re½ister – PCL.................................................................................. 36
Look-½p Table Re½isters – TBLP½ TBHP½ TBLH ..................................................................... 36
Stat½s Re½ister – ST½TUS .................................................................................................... 36
Rev. 1.20
2
½½½½st 10½ 2012
BS85B12-3/BS85C20-3/BS85C20-5
Touch Key Flash MCU with LCD/LED Driver
EEPROM Data Memory.................................................................................. 38
EEPROM Data Memory Str½ct½re ........................................................................................ 38
Readin½ Data from the EEPROM ......................................................................................... 40
Writin½ Data to the EEPROM ................................................................................................ 40
Write Protection ..................................................................................................................... 40
EEPROM Interr½pt ................................................................................................................ 41
Pro½rammin½ Considerations................................................................................................ 41
Pro½rammin½ Examples ........................................................................................................ 41
Oscillator ........................................................................................................ 42
Oscillator Overview ............................................................................................................... 42
System Clock Configurations
................................................................................................ 42
Internal Hi½h Speed RC Oscillator – HIRC ........................................................................... 42
External 32.768kHz Crystal Oscillator – LXT (BS85C20-5 only) .......................................... 43
LXT Oscillator Low Power F½nction (BS85C20-5 only) ........................................................ 44
Internal Low Speed RC Oscillator – LIRC ............................................................................. 44
Operating Modes and System Clocks ......................................................... 44
System Clocks ...................................................................................................................... 44
Control Re½ister .................................................................................................................... 46
System Operation Modes...................................................................................................... 47
Operatin½ Mode Switchin½ .................................................................................................... 48
NORM½L Mode to SLOW Mode Switchin½ ........................................................................... 49
SLOW Mode to NORM½L Mode Switchin½ ........................................................................... 49
Enterin½ the SLEEP Mode .................................................................................................... 49
Enterin½ the IDLE0 Mode ...................................................................................................... 50
Enterin½ the IDLE1 Mode ...................................................................................................... 50
Standby C½rrent Considerations ........................................................................................... 50
Wake-½p ................................................................................................................................ 51
Pro½rammin½ Considerations................................................................................................ 51
Watchdog Timer ............................................................................................. 52
Watchdo½ Timer Clock So½rce .............................................................................................. 52
Watchdo½ Timer Control Re½ister ......................................................................................... 52
Watchdo½ Timer Operation ................................................................................................... 53
Reset and Initialisation.................................................................................. 54
Reset F½nctions .................................................................................................................... 54
Reset Initial Conditions ......................................................................................................... 55
Input/Output Ports ......................................................................................... 59
I/O Re½ister List .................................................................................................................... 59
P½ll-hi½h Resistors ................................................................................................................ 60
Port ½ Wake-½p ..................................................................................................................... 60
I/O Port Control Re½ister ....................................................................................................... 61
Pin Re-mappin½ F½nctions .................................................................................................... 61
I/O Pin Str½ct½res .................................................................................................................. 66
Pro½rammin½ Considerations................................................................................................ 66
Rev. 1.20
3
½½½½st 10½ 2012
BS85B12-3/BS85C20-3/BS85C20-5
Touch Key Flash MCU with LCD/LED Driver
Timer Modules – TM ...................................................................................... 67
Introd½ction ........................................................................................................................... 67
TM Operation ........................................................................................................................ 67
TM Clock So½rce................................................................................................................... 68
TM Interr½pts ......................................................................................................................... 68
TM External Pins ................................................................................................................... 68
TM Inp½t/O½tp½t Pin Control Re½isters ................................................................................. 69
Pro½rammin½ Considerations................................................................................................ 72
Compact Type TM – CTM .............................................................................. 73
Compact TM Operation ......................................................................................................... 73
Compact Type TM Re½ister Description................................................................................ 74
Compact Type TM Operatin½ Modes .................................................................................... 77
Compare Match O½tp½t Mode ............................................................................................... 77
Timer/Co½nter Mode ............................................................................................................. 79
PWM O½tp½t Mode................................................................................................................ 80
Standard Type TM – STM .............................................................................. 82
Standard TM Operation ......................................................................................................... 82
Standard Type TM Re½ister Description ............................................................................... 83
Standard Type TM Operatin½ Modes .................................................................................... 87
Compare Match O½tp½t Mode ............................................................................................... 87
Timer/Co½nter Mode ............................................................................................................. 88
PWM O½tp½t Mode................................................................................................................ 89
Sin½le P½lse Mode ................................................................................................................ 91
Capt½re Inp½t Mode .............................................................................................................. 93
Enhanced Type TM – ETM ............................................................................. 94
Enhanced TM Operation ....................................................................................................... 94
Enhanced Type TM Re½ister Description .............................................................................. 95
Enhanced Type TM Operatin½ Modes................................................................................. 100
Compare O½tp½t Mode........................................................................................................ 101
Timer/Co½nter Mode ........................................................................................................... 105
PWM O½tp½t Mode.............................................................................................................. 105
Sin½le P½lse O½tp½t Mode ...................................................................................................111
Capt½re Inp½t Mode .............................................................................................................113
Touch Key Function .....................................................................................115
To½ch Key Str½ct½re .............................................................................................................115
Touch Key Register Definition
..............................................................................................115
To½ch Key Operation............................................................................................................119
To½ch Key Interr½pt ............................................................................................................. 120
Pro½rammin½ Considerations.............................................................................................. 120
Serial Interface Module – SIM ..................................................................... 121
SPI Interface ....................................................................................................................... 121
SPI Re½isters ...................................................................................................................... 122
SPI Comm½nication ............................................................................................................ 125
Rev. 1.20
4
½½½½st 10½ 2012
BS85B12-3/BS85C20-3/BS85C20-5
Touch Key Flash MCU with LCD/LED Driver
I
2
C Interface ........................................................................................................................ 127
I
2
C Re½isters ....................................................................................................................... 128
I
2
C B½s Comm½nication ...................................................................................................... 132
I
2
C B½s Start Si½nal............................................................................................................. 132
Slave ½ddress ..................................................................................................................... 133
I
2
C B½s Read/Write Si½nal .................................................................................................. 133
I
2
C B½s Slave ½ddress ½cknowled½e Si½nal ....................................................................... 134
I
2
C B½s Data and ½cknowled½e Si½nal ............................................................................... 134
I
2
C Time-o½t Control ............................................................................................................ 135
Peripheral Clock Output.............................................................................. 136
Peripheral Clock Operation ................................................................................................. 136
Interrupts ...................................................................................................... 137
Interr½pt Re½isters............................................................................................................... 137
Interr½pt Re½ister Contents ................................................................................................. 138
Interr½pt Operation .............................................................................................................. 144
External Interr½pt................................................................................................................. 146
M½lti-f½nction Interr½pt ........................................................................................................ 146
Time Base Interr½pts ........................................................................................................... 146
External Peripheral Interr½pt ............................................................................................... 148
LVD Interr½pt ....................................................................................................................... 149
TM Interr½pts ....................................................................................................................... 149
EEPROM Interr½pt .............................................................................................................. 149
To½ch Key Interr½pts ........................................................................................................... 149
SIM Interr½pt ....................................................................................................................... 150
Interr½pt Wake-½p F½nction ................................................................................................. 150
Pro½rammin½ Considerations.............................................................................................. 150
Low Voltage Detector – LVD ....................................................................... 151
LVD Re½ister ....................................................................................................................... 151
LVD Operation ..................................................................................................................... 152
LCD Driver – SCOM and SSEG Function................................................... 152
LCD Operation .................................................................................................................... 152
LCD Bias Control ................................................................................................................ 154
LCD Driver Re½isters .......................................................................................................... 154
LED Driver .................................................................................................... 156
LED Driver Operation .......................................................................................................... 156
LED Driver Re½isters .......................................................................................................... 156
Application Circuits ..................................................................................... 157
Instruction Set.............................................................................................. 158
Introd½ction ......................................................................................................................... 158
Instr½ction Timin½ ................................................................................................................ 158
Movin½ and Transferrin½ Data ............................................................................................. 158
½rithmetic Operations.......................................................................................................... 158
Lo½ical and Rotate Operation ............................................................................................. 159
Rev. 1.20
5
½½½½st 10½ 2012