Zilog Datasheet
Zilog Datasheet
ii
As used herein
Life support devices or systems are devices which (a) are intended for surgical implant into the body, or (b)
support or sustain life and whose failure to perform when properly used in accordance with instructions for
use provided in the labeling can be reasonably expected to result in a significant injury to the user. A criti-
cal component is any component in a life support device or system whose failure to perform can be reason-
ably expected to cause the failure of the life support device or system or to affect its safety or effectiveness.
Document Disclaimer
©2011 Zilog, Inc. All rights reserved. Information in this publication concerning the devices, applications,
or technology described is intended to suggest possible uses and may be superseded. ZILOG, INC. DOES
NOT ASSUME LIABILITY FOR OR PROVIDE A REPRESENTATION OF ACCURACY OF THE
INFORMATION, DEVICES, OR TECHNOLOGY DESCRIBED IN THIS DOCUMENT. ZILOG ALSO
DOES NOT ASSUME LIABILITY FOR INTELLECTUAL PROPERTY INFRINGEMENT RELATED
IN ANY MANNER TO USE OF INFORMATION, DEVICES, OR TECHNOLOGY DESCRIBED
HEREIN OR OTHERWISE. The information contained within this document has been verified according
to the general principles of electrical and mechanical engineering.
Z8, Z8 Encore!, Z8 Encore! XP and Z8 Encore! MC are trademarks or registered trademarks of Zilog, Inc.
All other product or service names are the property of their respective owners.
iii
Revision History
Each instance in Revision History reflects a change to this document from its previous
revision. For more details, refer to the corresponding pages and appropriate links in the
table below.
Revision
Date Level Description Page
Oct 18 Added LDWX information to Load Instructions table, eZ8 CPU Instruction 206, 212,
2011 Summary table and to Second Op Code Map after 1FH figure; revised 220, 152,
Flash Sector Protect Register description; revised Packaging chapter. 221
May 17 Removed Flash Microcontrollers from the title throughout the document. All
2008
Feb 16 Updated the flag status for BCLR, BIT, and BSET in eZ8 CPU Instruction 208
2008 Summary table.
Dec 15 Updated Zilog logo/text, Foreword section. Updated Z8 Encore! 8K Series All
2007 to Z8 Encore! XP® F0822 Series Flash Microcontrollers throughout the
document.
iv
Table of Contents
Revision History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .iii
List of Figures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi
List of Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xiii
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Part Selection Guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
CPU and Peripheral Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
General Purpose Input/Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Flash Controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
10-Bit Analog-to-Digital Converter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
UART . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
I2C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Serial Peripheral Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Timers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Interrupt Controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Reset Controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
On-Chip Debugger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Signal and Pin Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Available Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Pin Configurations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Signal Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Pin Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Address Space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Register File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Program Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Data Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Information Area . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Register File Address Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Reset and Stop Mode Recovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Reset Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
System Reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Reset Sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Power-On Reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Voltage Brown-Out Reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Watchdog Timer Reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
vi
vii
viii
Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
Automatic Power-Down . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
Single-Shot Conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
Continuous Conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
ADC Control Register Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
ADC Control Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
ADC Data High Byte Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
ADC Data Low Bits Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
Flash Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
Information Area . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
Timing Using the Flash Frequency Registers . . . . . . . . . . . . . . . . . . . . . . . . . 145
Flash Read Protection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
Flash Write/Erase Protection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
Byte Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
Page Erase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
Mass Erase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
Flash Controller Bypass . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
Flash Controller Behavior in Debug Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
Flash Control Register Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
Flash Control Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
Flash Status Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
Page Select Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
Flash Sector Protect Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
Flash Frequency High and Low Byte Registers . . . . . . . . . . . . . . . . . . . . . . . . 153
Option Bits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
Option Bit Configuration By Reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
Option Bit Address Space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
Flash Memory Address 0000H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
Flash Memory Address 0001H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
On-Chip Debugger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
OCD Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
Debug Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
OCD Data Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
OCD Autobaud Detector/Generator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
OCD Serial Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
ix
Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
OCDCNTR Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
On-Chip Debugger Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
On-Chip Debugger Control Register Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . 169
OCD Control Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
OCD Status Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
On-Chip Oscillator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
Operating Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
Crystal Oscillator Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
Oscillator Operation with an External RC Network . . . . . . . . . . . . . . . . . . . . . . . . 174
Electrical Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176
Absolute Maximum Ratings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176
DC Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
AC Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
On-Chip Peripheral AC and DC Electrical Characteristics . . . . . . . . . . . . . . . . . . 186
General Purpose I/O Port Input Data Sample Timing . . . . . . . . . . . . . . . . . . . 191
General Purpose I/O Port Output Timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
On-Chip Debugger Timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
SPI MASTER Mode Timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
SPI SLAVE Mode Timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
I2C Timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
UART Timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
eZ8 CPU Instruction Set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
Assembly Language Programming Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . 199
Assembly Language Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
eZ8 CPU Instruction Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
Condition Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
eZ8 CPU Instruction Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204
eZ8 CPU Instruction Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208
Flags Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
Op Code Maps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
Packaging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221
Ordering Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222
Part Number Suffix Designations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224
General Purpose RAM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
Timer 0 Control Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
UART Control Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230
I2C Control Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
SPI Control Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
Analog-to-Digital Converter Control Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
xi
List of Figures
Figure 1. Z8 Encore! XP® F0822 Series Block Diagram . . . . . . . . . . . . . . . . . . . . . . . 3
Figure 2. The Z8F0821 and Z8F0421 MCUs in 20-Pin SSOP and PDIP Packages . . . 8
Figure 3. The Z8F0822 and Z8F0422 MCUs in 28-Pin SOIC and PDIP Packages . . . 8
Figure 4. The Z8F0811 and Z8F0411 MCUs in 20-Pin SSOP and PDIP Packages . . . 9
Figure 5. The Z8F0812 and Z8F0412 MCUs in 28-Pin SOIC and PDIP Packages . . . 9
Figure 6. Power-On Reset Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Figure 7. Voltage Brown-Out Reset Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Figure 8. GPIO Port Pin Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Figure 9. Interrupt Controller Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Figure 10. Timer Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Figure 11. UART Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
Figure 12. UART Asynchronous Data Format without Parity . . . . . . . . . . . . . . . . . . . 79
Figure 13. UART Asynchronous Data Format with Parity . . . . . . . . . . . . . . . . . . . . . . 79
Figure 14. UART Asynchronous Multiprocessor Mode Data Format . . . . . . . . . . . . . 83
Figure 15. UART Driver Enable Signal Timing (with 1 Stop Bit and Parity) . . . . . . . 85
Figure 16. UART Receiver Interrupt Service Routine Flow . . . . . . . . . . . . . . . . . . . . 87
Figure 17. Infrared Data Communication System Block Diagram . . . . . . . . . . . . . . . 97
Figure 18. Infrared Data Transmission . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
Figure 19. Infrared Data Reception . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
Figure 20. SPI Configured as a Master in a Single Master, Single Slave System . . . 101
Figure 21. SPI Configured as a Master in a Single Master, Multiple Slave System . . 102
Figure 22. SPI Configured as a Slave . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
Figure 23. SPI Timing When PHASE is 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
Figure 24. SPI Timing When PHASE is 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
Figure 25. I2C Controller Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
Figure 26. 7-Bit Address Only Transaction Format . . . . . . . . . . . . . . . . . . . . . . . . . . 120
Figure 27. 7-Bit Addressed Slave Data Transfer Format . . . . . . . . . . . . . . . . . . . . . . 121
Figure 28. 10-Bit Address Only Transaction Format . . . . . . . . . . . . . . . . . . . . . . . . . 122
Figure 29. 10-Bit Addressed Slave Data Transfer Format . . . . . . . . . . . . . . . . . . . . . 123
Figure 30. Receive Data Transfer Format for a 7-Bit Addressed Slave . . . . . . . . . . . 125
Figure 31. Receive Data Format for a 10-Bit Addressed Slave . . . . . . . . . . . . . . . . . 126
Figure 32. Analog-to-Digital Converter Block Diagram . . . . . . . . . . . . . . . . . . . . . . 137
Figure 33. Flash Memory Arrangement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
xii
xiii
List of Tables
Table 1. Z8 Encore! XP® F0822 Series Part Selection Guide . . . . . . . . . . . . . . . . . . . 2
Table 2. Z8 Encore! XP® F0822 Series Package Options . . . . . . . . . . . . . . . . . . . . . . 7
Table 3. Signal Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Table 4. Pin Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Table 5. Z8 Encore! XP® F0822 Series Program Memory Maps . . . . . . . . . . . . . . . 15
Table 6. Information Area Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Table 7. Register File Address Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Table 8. Reset and Stop Mode Recovery Characteristics and Latency . . . . . . . . . . . 21
Table 9. Reset Sources and Resulting Reset Type . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Table 10. Stop Mode Recovery Sources and Resulting Action . . . . . . . . . . . . . . . . . . 25
Table 11. Port Availability by Device and Package Type . . . . . . . . . . . . . . . . . . . . . . 29
Table 12. Port Alternate Function Mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Table 13. GPIO Port Registers and Subregisters . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Table 14. Port A–C GPIO Address Registers (PxADDR) . . . . . . . . . . . . . . . . . . . . . . 32
Table 15. Port A–C Control Registers (PxCTL) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Table 16. Port A–C Data Direction Subregisters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Table 17. Port A–CA–C Alternate Function Subregisters . . . . . . . . . . . . . . . . . . . . . . 34
Table 18. Port A–C Output Control Subregisters . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Table 19. Port A–C High Drive Enable Subregisters . . . . . . . . . . . . . . . . . . . . . . . . . 36
Table 20. Port A–C Stop Mode Recovery Source Enable Subregisters . . . . . . . . . . . 37
Table 21. Port A–C Pull-Up Enable Subregisters . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Table 22. Port A–C Input Data Registers (PxIN) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Table 23. Port A–C Output Data Register (PxOUT) . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Table 24. Interrupt Vectors in Order of Priority . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Table 25. Interrupt Request 0 Register (IRQ0) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Table 26. Interrupt Request 1 Register (IRQ1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Table 27. Interrupt Request 2 Register (IRQ2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Table 28. IRQ0 Enable and Priority Encoding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Table 29. IRQ0 Enable High Bit Register (IRQ0ENH) . . . . . . . . . . . . . . . . . . . . . . . 48
Table 30. IRQ0 Enable Low Bit Register (IRQ0ENL) . . . . . . . . . . . . . . . . . . . . . . . . 49
Table 31. IRQ1 Enable and Priority Encoding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Table 32. IRQ1 Enable High Bit Register (IRQ1ENH) . . . . . . . . . . . . . . . . . . . . . . . 50
Table 33. IRQ1 Enable Low Bit Register (IRQ1ENL) . . . . . . . . . . . . . . . . . . . . . . . . 50
xiv
xv
Table 70. SPI Baud Rate Low Byte Register (SPIBRL) . . . . . . . . . . . . . . . . . . . . . . 114
Table 71. I2C Data Register (I2CDATA) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
Table 72. I2C Status Register (I2CSTAT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
Table 73. I2C Control Register (I2CCTL) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
Table 74. I2C Baud Rate High Byte Register (I2CBRH) . . . . . . . . . . . . . . . . . . . . . 132
Table 75. I2C Baud Rate Low Byte Register (I2CBRL) . . . . . . . . . . . . . . . . . . . . . . 133
Table 76. I2C Diagnostic State Register (I2CDST) . . . . . . . . . . . . . . . . . . . . . . . . . . 133
Table 77. I2C Diagnostic Control Register (I2CDIAG) . . . . . . . . . . . . . . . . . . . . . . 135
Table 78. ADC Control Register (ADCCTL) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
Table 79. ADC Data High Byte Register (ADCD_H) . . . . . . . . . . . . . . . . . . . . . . . . 141
Table 80. ADC Data Low Bits Register (ADCD_L) . . . . . . . . . . . . . . . . . . . . . . . . . 142
Table 81. Flash Memory Configurations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
Table 82. Flash Memory Sector Addresses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
Table 83. Z8 Encore! XP® F0822 Series Information Area Map . . . . . . . . . . . . . . . 145
Table 84. Flash Control Register (FCTL) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
Table 85. Flash Status Register (FSTAT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
Table 86. Page Select Register (FPS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
Table 87. Flash Sector Protect Register (FPROT) . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
Table 88. Flash Frequency High Byte Register (FFREQH) . . . . . . . . . . . . . . . . . . . 154
Table 89. Flash Frequency Low Byte Register (FFREQL) . . . . . . . . . . . . . . . . . . . . 154
Table 90. Option Bits at Flash Memory Address 0000H for 8K Series Flash
Devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
Table 91. Options Bits at Flash Memory Address 0001H . . . . . . . . . . . . . . . . . . . . . 157
Table 92. OCD Baud-Rate Limits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
Table 93. On-Chip Debugger Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
Table 94. OCD Control Register (OCDCTL) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
Table 95. OCD Status Register (OCDSTAT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
Table 96. Recommended Crystal Oscillator Specifications (20 MHz Operation) . . . 173
Table 97. Absolute Maximum Ratings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176
Table 98. DC Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
Table 99. AC Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
Table 100. Power-On Reset and Voltage Brown-Out Electrical Characteristics
and Timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
Table 101. External RC Oscillator Electrical Characteristics and Timing . . . . . . . . . 187
Table 102. Flash Memory Electrical Characteristics and Timing . . . . . . . . . . . . . . . . 187
Table 103. Reset and Stop Mode Recovery Pin Timing . . . . . . . . . . . . . . . . . . . . . . . 188
xvi
xvii
Table 140. Timer 0–1 Reload High Byte Register (TxRH) . . . . . . . . . . . . . . . . . . . . . 228
Table 141. Timer 0–1 Reload Low Byte Register (TxRL) . . . . . . . . . . . . . . . . . . . . . 229
Table 142. Timer 0–1 PWM High Byte Register (TxPWMH) . . . . . . . . . . . . . . . . . . 229
Table 143. Timer 0–1 PWM Low Byte Register (TxPWML) . . . . . . . . . . . . . . . . . . . 229
Table 144. Timer 0–3 Control 0 Registers (TxCTL0) . . . . . . . . . . . . . . . . . . . . . . . . . 229
Table 145. Timer 0–1 Control Registers (TxCTL) . . . . . . . . . . . . . . . . . . . . . . . . . . . 230
Table 146. UART Transmit Data Register (U0TXD) . . . . . . . . . . . . . . . . . . . . . . . . . 230
Table 147. UART Receive Data Register (U0RXD) . . . . . . . . . . . . . . . . . . . . . . . . . . 230
Table 148. UART Status 0 Register (U0STAT0) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
Table 149. UART Control 0 Register (U0CTL0) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
Table 150. UART Control 1 Register (U0CTL1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
Table 151. UART Status 1 Register (U0STAT1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
Table 152. UART Address Compare Register (U0ADDR) . . . . . . . . . . . . . . . . . . . . . 232
Table 153. UART Baud Rate High Byte Register (U0BRH) . . . . . . . . . . . . . . . . . . . 232
Table 154. UART Baud Rate Low Byte Register (U0BRL) . . . . . . . . . . . . . . . . . . . . 232
Table 155. I2C Data Register (I2CDATA) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
Table 156. I2C Status Register (I2CSTAT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
Table 157. I2C Control Register (I2CCTL) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
Table 158. I2C Baud Rate High Byte Register (I2CBRH) . . . . . . . . . . . . . . . . . . . . . 234
Table 159. I2C Baud Rate Low Byte Register (I2CBRL) . . . . . . . . . . . . . . . . . . . . . . 234
Table 160. I2C Diagnostic State Register (I2CDST) . . . . . . . . . . . . . . . . . . . . . . . . . . 234
Table 161. I2C Diagnostic Control Register (I2CDIAG) . . . . . . . . . . . . . . . . . . . . . . 234
Table 162. SPI Data Register (SPIDATA) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
Table 163. SPI Control Register (SPICTL) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
Table 164. SPI Status Register (SPISTAT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
Table 165. SPI Mode Register (SPIMODE) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236
Table 166. SPI Diagnostic State Register (SPIDST) . . . . . . . . . . . . . . . . . . . . . . . . . . 236
Table 167. SPI Baud Rate High Byte Register (SPIBRH) . . . . . . . . . . . . . . . . . . . . . 236
Table 168. SPI Baud Rate Low Byte Register (SPIBRL) . . . . . . . . . . . . . . . . . . . . . . 237
Table 169. ADC Control Register (ADCCTL) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
Table 170. ADC Data High Byte Register (ADCD_H) . . . . . . . . . . . . . . . . . . . . . . . . 238
Table 171. ADC Data Low Bits Register (ADCD_L) . . . . . . . . . . . . . . . . . . . . . . . . . 238
Table 172. Interrupt Request 0 Register (IRQ0) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238
Table 173. IRQ0 Enable High Bit Register (IRQ0ENH) . . . . . . . . . . . . . . . . . . . . . . 239
Table 174. IRQ0 Enable Low Bit Register (IRQ0ENL) . . . . . . . . . . . . . . . . . . . . . . . 239
Table 175. Interrupt Request 1 Register (IRQ1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
xviii
Introduction
Zilog’s Z8 Encore! XP® MCU product family is a line of Zilog microcontrollers based on
the 8-bit eZ8 CPU. Z8 Encore! XP® F0822 Series of MCUs adds Flash memory to Zilog’s
extensive line of 8-bit microcontrollers. The Flash in-circuit programming allows faster
development time and program changes in the field. The new eZ8 CPU is upward-compat-
ible with the existing Z8® CPU instructions. The rich peripheral set of the Z8 Encore!
XP® F0822 Series makes it suitable for a variety of applications including motor control,
security systems, home appliances, personal electronic devices and sensors.
Features
The Z8 Encore! XP® F0822 Series features:
• 20 MHz eZ8 CPU core
• Up to 8 KB Flash with in-circuit programming capability
• 1 KB Register RAM
• Optional 2- to 5-channel, 10-bit Analog-to-Digital Converter (ADC)
• Full-duplex 9-bit Universal Asynchronous Receiver/Transmitter (UART) with bus
transceiver Driver Enable Control
• Inter-Integrated Circuit (I2C)
• Serial Peripheral Interface (SPI)
• Infrared Data Association (IrDA)-compliant infrared encoder/decoders
• Two 16-bit timers with Capture, Compare, and PWM capability
• Watchdog Timer (WDT) with internal RC oscillator
• 11 to 19 Input/Output pins depending upon package
• Up to 19 interrupts with configurable priority
• On-Chip Debugger (OCD)
• Voltage Brown-Out (VBO) protection
• Power-On Reset (POR)
• Crystal oscillator with three power settings and RC oscillator option
• 2.7 V to 3.6 V operating voltage with 5 V-tolerant inputs
• 20-pin and 28-pin packages
• 0°C to +70°C standard temperature and –40°C to +105°C extended temperature oper-
ating ranges
Block Diagram
Figure 1 displays the block diagram of the architecture of Z8 Encore! XP® F0822 Series
devices.
Crystal On-Chip
Oscillator Debugger
POR/VBO
eZ8
Interrupt & Reset WDT with
CPU
Controller Controller RC Oscillator
System
Clock
Memory Buses
Register Bus
IrDA
Flash
Memory RAM
GPIO
For more information about the eZ8 CPU, refer to the eZ8 CPU Core User Manual
(UM0128), which is available for download at www.zilog.com.
Flash Controller
The Flash Controller programs and erases the contents of Flash memory.
UART
The Universal Asynchronous Receiver/Transmitter (UART) is full-duplex and capable of
handling asynchronous data transfers. The UART supports 8-bit and 9-bit data modes and
selectable parity.
I2C
The Inter-Integrated Circuit (I2C) controller makes the Z8 Encore! XP compatible with the
I2C protocol. The I2C Controller consists of two bidirectional bus lines, a serial data
(SDA) line, and a serial clock (SCL) line.
Timers
Two 16-bit reloadable timers are used for timing/counting events or for motor control
operations. These timers provide a 16-bit programmable reload counter and operate in
One-Shot, Continuous, Gated, Capture, Compare, Capture and Compare, and PWM
modes.
Interrupt Controller
Z8 Encore! XP® F0822 Series products support up to 18 interrupts. These interrupts con-
sist of 7 internal peripheral interrupts and 11 GPIO pin interrupt sources. The interrupts
have 3 levels of programmable interrupt priority.
Reset Controller
Z8 Encore! XP® F0822 Series products are reset using the RESET pin, POR, WDT, STOP
Mode exit, or VBO warning signal.
On-Chip Debugger
Z8 Encore! XP® F0822 Series products feature an integrated On-Chip Debugger (OCD).
The OCD provides a rich-set of debugging capabilities, such as, reading and writing regis-
ters, programming Flash memory, setting breakpoints, and executing code. A single-pin
interface provides communication to the OCD.
Available Packages
Table 2 identifies the package styles available for each device within the Z8 Encore! XP®
F0822 Series.
Pin Configurations
Figures 2 through 5 display the pin configurations for all of the packages available in the
Z8 Encore! XP® F0822 Series. See Table 4 on page 13 for a description of the signals.
Note: The analog input alternate functions (ANAx) are not available on Z8 Encore! XP® F0822
Series devices.
PA6/SCL 1 20 PC0/T1IN
PA7/SDA 2 19 PB0/ANA0
RESET 3 18 PB1/ANA1
VSS 4 17 VREF
XIN 5 16 AVSS
XOUT 6 15 AVDD
VDD 7 14 DBG
PA0/T0IN 8 13 PA5/TXD0
PA1/T0OUT 9 12 PA4/RXD0
PA2/DE0 10 11 PA3/CTS0
Figure 2. The Z8F0821 and Z8F0421 MCUs in 20-Pin SSOP and PDIP Packages
PC0/T1IN 1 28 PB0/ANA0
PA6/SCL 2 27 PB1/ANA1
PA7/SDA 3 26 PB2/ANA2
RESET 4 25 PB3/ANA3
VSS 5 24 PB4/ANA4
XIN 6 23 VREF
XOUT 7 22 AVSS
VDD 8 21 AVDD
PC5/MISO 9 20 DBG
PC4/MOSI 10 19 PC1/T1OUT
PC3/SCK 11 18 PA5/TXD0
PC2/SS 12 17 PA4/RXD0
PA0/T0IN 13 16 PA3/CTS0
PA1/T0OUT 14 15 PA2/DE0
Figure 3. The Z8F0822 and Z8F0422 MCUs in 28-Pin SOIC and PDIP Packages
PA6/SCL 1 20 PC0/T1IN
PA7/SDA 2 19 PB0
RESET 3 18 PB1
VSS 4 17 No Connect
XIN 5 16 AVSS
XOUT 6 15 AVDD
VDD 7 14 DBG
PA0/T0IN 8 13 PA5/TXD0
PA1/T0OUT 9 12 PA4/RXD0
PA2/DE0 10 11 PA3/CTS0
Figure 4. The Z8F0811 and Z8F0411 MCUs in 20-Pin SSOP and PDIP Packages
PC0/T1IN 1 28 PB0
PA6/SCL 2 27 PB1
PA7/SDA 3 26 PB2
RESET 4 25 PB3
VSS 5 24 PB4
XIN 6 23 No Connect
XOUT 7 22 AVSS
VDD 8 21 AVDD
PC5/MISO 9 20 DBG
PC4/MOSI 10 19 PC1/T1OUT
PC3/SCK 11 18 PA5/TXD0
PC2/SS 12 17 PA4/RXD0
PA0/T0IN 13 16 PA3/CTS0
PA1/T0OUT 14 15 PA2/DE0
Figure 5. The Z8F0812 and Z8F0412 MCUs in 28-Pin SOIC and PDIP Packages
10
Signal Descriptions
Table 3 describes Z8 Encore! XP® F0822 Series signals. See the Pin Configurations sec-
tion on page 7 to determine the signals available for the specific package styles
Signal
Mnemonic I/O Description
General-Purpose I/O Ports A–H
PA[7:0] I/O Port C
These pins are used for general-purpose I/O and supports 5 V-tolerant inputs.
PB[4:0] I/O Port B
These pins are used for general-purpose I/O.
PC[5:0] I/O Port C
These pins are used for general-purpose I/O and support 5 V-tolerant inputs.
I2C Controller
SCL I/O Serial Clock
This open-drain pin clocks data transfers in accordance with the I2C standard
protocol. This pin is multiplexed with a GPIO pin. When the GPIO pin is config-
ured for alternate function to enable the SCL function, this pin is open-drain.
SDA I/O Serial Data
This open-drain pin transfers data between the I2C and a slave. This pin is multi-
plexed with a GPIO pin. When the GPIO pin is configured for alternate function to
enable the SDA function, this pin is open-drain.
SPI Controller
SS I/O Slave Select
This signal can be an output or an input. If the Z8 Encore! XP® F0822 Series
MCU is the SPI Master, this pin can be configured as the Slave Select output. If
the MCU is the SPI Slave, this pin is the input slave select. It is multiplexed with a
GPIO pin.
SCK I/O SPI Serial Clock
The SPI Master supplies this pin. If the Z8 Encore! XP® F0822 Series MCU is the
SPI Master, this pin is the output. If the MCU is the SPI Slave, this pin is the
input. It is multiplexed with a GPIO pin.
MOSI I/O Master-Out/Slave-In
This signal is the data output from the SPI Master device and the data input to
the SPI Slave device. It is multiplexed with a GPIO pin.
MISO I/O Master-In/Slave-Out
This pin is the data input to the SPI Master device and the data output from the
SPI Slave device. It is multiplexed with a GPIO pin.
11
Signal
Mnemonic I/O Description
UART Controllers
TXD0 O Transmit Data
This signal is the transmit output from the UART and IrDA. The TXD signals are
multiplexed with GPIO pins.
RXD0 I Receive Data
This signal is the receiver input for the UART and IrDA. The RXD signals are
multiplexed with GPIO pins.
CTS0 I Clear To Send
This signal is control inputs for the UART. The CTS signals are multiplexed with
GPIO pins.
DE0 O Driver Enable
This signal allows automatic control of external RS-485 drivers. This signal is
approximately the inverse of the TXE (Transmit Empty) bit in the UART Status 0
Register. The DE signal can be used to ensure the external RS-485 driver is
enabled when data is transmitted by the UART.
Timers
T0OUT/ O Timer Output 0–1
T1OUT These signals are output pins from the timers. The Timer Output signals are mul-
tiplexed with GPIO pins.
T0IN/T1IN I Timer Input 0–1
These signals are used as the Capture, Gating and Counter inputs. The Timer
Input signals are multiplexed with GPIO pins.
Analog
ANA[4:0] I Analog Input
These signals are inputs to the Analog-to-Digital Converter (ADC). The ADC
analog inputs are multiplexed with GPIO pins.
VREF I Analog-to-Digital Converter Reference Voltage Input
As an output, Zilog does not recommend the VREF signal for use as a reference
voltage for external devices. If the ADC is configured to use the internal refer-
ence voltage generator, this pin should remain unconnected or capacitively cou-
pled to analog ground (AVSS).
Oscillators
XIN I External Crystal Input
This pin is the input to the crystal oscillator. A crystal is connected between the
external crystal input and the XOUT pin to form the oscillator. In addition, this pin
is used with external RC networks or external clock drivers to provide the system
clock to the system.
12
Signal
Mnemonic I/O Description
XOUT O External Crystal Output
This pin is the output of the crystal oscillator. A crystal is connected between
external crystal output and the XIN pin to form the oscillator. When the system
clock is referred in this manual, it refers to the frequency of the signal at this pin.
This pin must remain unconnected when not using a crystal.
On-Chip Debugger
DBG I/O Debug
This pin is the control and data input and output to and from the OCD. The DBG
pin is open-drain and must have an external pull-up resistor to ensure proper
operation.
Caution: For operation of the OCD, all power pins (VDD and AVDD) must be sup-
plied with power and all ground pins (VSS and AVSS) must be properly grounded.
Reset
RESET I RESET
Generates a Reset when asserted (driven Low).
Power Supply
VDD I Digital Power Supply.
AVDD I Analog Power Supply
Must be powered up and grounded to VDD, even if not using analog features.
VSS I Digital Ground.
AVSS I Analog Ground
Must be grounded and connected to VSS, even if not using analog features.
13
Pin Characteristics
Table 4 provides detailed information about the characteristics for each pin available on
Z8 Encore! XP® F0822 Series products. The data in Table 4 is sorted alphabetically by pin
symbol mnemonic.
Active
Low or Internal
Symbol Reset Active Tri-State Pull-Up or Schmitt-Trigger Open Drain
Mnemonic Direction Direction High Output Pull-Down Input Output
AVDD N/A N/A N/A N/A No No N/A
AVSS N/A N/A N/A N/A No No N/A
DBG I/O I N/A Yes No Yes Yes
PA[7:0] I/O I N/A Yes Programma- Yes Yes, pro-
ble pull-up grammable
PB[4:0] I/O I N/A Yes Programma- Yes Yes, pro-
ble pull-up grammable
PC[5:0] I/O I N/A Yes Programma- Yes Yes, pro-
ble pull-up grammable
RESET I I Low N/A Pull-up Yes N/A
VDD N/A N/A N/A N/A No No N/A
VREF Analog N/A N/A N/A No No N/A
VSS N/A N/A N/A N/A No No N/A
XIN I I N/A N/A No No N/A
XOUT O O N/A No No No No
14
Address Space
The eZ8 CPU accesses three distinct address spaces:
• The Register File contains addresses for the general-purpose registers and the eZ8
CPU, Peripheral, and GPIO Port Control registers
• The Program Memory contains addresses for all memory locations having executable
code and/or data
• The Data Memory contains addresses for all memory locations that hold data only
These three address spaces are covered briefly in the following sections. For more infor-
mation about the eZ8 CPU and its address space, refer to the eZ8 CPU Core User Manual
(UM0128), which is available for download at www.zilog.com.
Register File
The Register File address space in the Z8 Encore! XP® F0822 Series is 4 KB (4096 bytes).
It is composed of two sections: Control registers and General-Purpose registers. When
instructions are executed, registers are read from when defined as sources and written to
when defined as destinations. The architecture of the eZ8 CPU allows all general-purpose
registers to function as accumulators, address pointers, index registers, stack areas, or
scratch pad memory.
The upper 256 bytes of the 1 KB Register File address space is reserved for control of the
eZ8 CPU, the on-chip peripherals, and the I/O ports. These registers are located at
addresses from F00H to FFFH. Some of the addresses within the 256-byte Control Register
section is reserved (unavailable). Reading from the reserved Register File addresses
returns an undefined value. Writing to reserved Register File addresses is not recom-
mended by Zilog because it can produce unpredictable results.
The on-chip RAM always begins at address 000H in the Register File address space. Z8
Encore! XP® F0822 Series contains 1 KB of on-chip RAM. Reading from Register File
addresses outside the available RAM addresses (and not within the control register address
space) returns an undefined value. Writing to these Register File addresses produces no
effect.
15
Program Memory
The eZ8 CPU supports 64 KB of Program memory address space. Z8 Encore! XP® F0822
Series contain 4 KB to 8 KB on-chip Flash in the Program memory address space, depend-
ing on the device. Reading from Program memory addresses outside the available Flash
addresses returns FFH. Writing to unimplemented Program memory addresses produces no
effect. Table 5 describes the Program memory Maps for Z8 Encore! XP® F0822 Series
devices.
Data Memory
Z8 Encore! XP® F0822 Series does not use the eZ8 CPU’s 64 KB Data Memory address
space.
Information Area
Table 6 describes the Z8 Encore! XP® F0822 Series Information Area. This 512-byte
Information Area is accessed by setting bit 7 of the Page Select Register to 1. When access
is enabled, the Information Area is mapped into the Program memory and overlays the
512 bytes at addresses FE00H to FFFFH. When the Information Area access is enabled, all
16
reads from these Program memory addresses return the Information Area data rather than
the Program memory data. Access to the Information Area is read-only.
Program Memory
Address (Hex) Function
FE00H–FE3FH Reserved
FE40H–FE53H Part Number: 20-character ASCII alphanumeric
code, left-justified and filled with zeros
FE54H–FFFFH Reserved
17
18
19
20
21
When the Z8 Encore! XP® F0822 Series device is in STOP Mode, a Stop Mode Recovery
is initiated by any of the following events:
• WDT time-out
• GPIO Port input pin transition on an enabled Stop Mode Recovery source
• DBG pin driven Low
Reset Types
Z8 Encore! XP® F0822 Series provides two types of reset operation (System Reset and
Stop Mode Recovery). The type of reset is a function of both the current operating mode
of the Z8 Encore! XP® F0822 Series device and the source of the Reset. Table 8 lists the
types of Resets and their operating characteristics.
System Reset
During a System Reset, a Z8 Encore! XP® F0822 Series device is held in Reset for 66
cycles of the WDT oscillator followed by 16 cycles of the system clock. At the beginning
22
of Reset, all GPIO pins are configured as inputs. All GPIO programmable pull-ups are dis-
abled.
During Reset, the eZ8 CPU and the on-chip peripherals are idle; however, the on-chip
crystal oscillator and WDT oscillator continue to run. The system clock begins operating
following the WDT oscillator cycle count. The eZ8 CPU and on-chip peripherals remain
idle through all of the 16 cycles of the system clock.
Upon Reset, control registers within the Register File which have a defined Reset value
are loaded with their reset values. Other control registers (including the Stack Pointer,
Register Pointer, and Flags) and general-purpose RAM are undefined following the Reset.
The eZ8 CPU fetches the Reset vector at Program memory addresses 0002H and 0003H
and loads that value into the Program Counter. Program execution begins at the Reset vec-
tor address.
Reset Sources
Table 9 lists the reset sources as a function of the operating mode. The remainder of this
section provides more detail about the individual reset sources.
Note: A POR/VBO event always has priority over all other possible reset sources to ensure a full
system reset occurs.
Power-On Reset
Each device in the Z8 Encore! XP® F0822 Series contains an internal POR circuit. The
POR circuit monitors the supply voltage and holds the device in the Reset state until the
supply voltage reaches a safe operating level. After the supply voltage exceeds the POR
23
voltage threshold (VPOR), the POR Counter is enabled and counts 66 cycles of the WDT
oscillator. After the POR counter times out, the XTAL Counter is enabled to count a total
of 16 system clock pulses. The device is held in the Reset state until both the POR Counter
and XTAL counter have timed out. After the Z8 Encore! XP® F0822 Series device exits
the POR state, the eZ8 CPU fetches the Reset vector. Following POR, the POR status bit
in the Watchdog Timer Control Register (WDTCTL) is set to 1.
Figure 6 displays POR operation. See the Electrical Characteristics chapter on page 176
for the POR threshold voltage (VPOR).
VCC = 3.3V
VPOR
VVBO
WDT Clock
Primary
Oscillator
Oscillator
Start-up
Internal RESET
Signal
POR XTAL
Not to Scale Counter Delay Counter Delay
24
the POR status bit in the Watchdog Timer Control Register (WDTCTL) is set to 1.
Figure 7 displays the VBO operation. See the Electrical Characteristics chapter on
page 176 for the VBO and POR threshold voltages (VVBO and VPOR).
The VBO circuit can be either enabled or disabled during STOP Mode. Operation during
STOP Mode is set by the VBO_AO option bit. For information about configuring
VBO_AO, see the Option Bits chapter on page 155.
WDT Clock
Primary
Oscillator
Internal RESET
signal
POR XTAL
Counter Delay Counter Delay
25
clock cycles, the device progresses through the System Reset sequence. While the RESET
input pin is asserted Low, Z8 Encore! XP® F0822 Series device continues to be held in the
Reset state. If the RESET pin is held Low beyond the System Reset time-out, the device
exits the Reset state immediately following RESET pin deassertion. Following a System
Reset initiated by the external RESET pin, the EXT status bit in the Watchdog Timer Con-
trol Register (WDTCTL) is set to 1.
26
Caution: In STOP Mode, the GPIO Port Input Data registers (PxIN) are disabled. The Port Input
Data registers record the Port transition only if the signal stays on the port pin through
the end of the Stop Mode Recovery delay. Therefore, short pulses on the port pin initiates
Stop Mode Recovery without being written to the Port Input Data Register or without ini-
tiating an interrupt (if enabled for that pin).
27
Low-Power Modes
Z8 Encore! XP® F0822 Series products contain power-saving features. The highest level
of power reduction is provided by STOP Mode. The next level of power reduction is pro-
vided by the HALT Mode.
STOP Mode
Execution of the eZ8 CPU’s stop instruction places the device into STOP Mode. In STOP
Mode, the operating characteristics are:
• Primary crystal oscillator is stopped; the XIN pin is driven High and the XOUT pin is
driven Low
• System clock is stopped
• eZ8 CPU is stopped
• Program counter (PC) stops incrementing
• If enabled for operation in STOP Mode, the WDT and its internal RC oscillator contin-
ue to operate
• If enabled for operation in STOP Mode through the associated option bit, the VBO pro-
tection circuit continues to operate
• All other on-chip peripherals are idle
To minimize current in STOP Mode, WDT must be disabled and all GPIO pins configured
as digital inputs must be driven to one of the supply rails (VCC or GND). The device can be
brought out of STOP Mode using Stop Mode Recovery. For more information about Stop
Mode Recovery, see the Reset and Stop Mode Recovery chapter on page 21.
Caution: STOP Mode must not be used when driving the Z8F082x family devices with an external
clock driver source.
HALT Mode
Execution of the eZ8 CPU’s HALT instruction places the device into HALT Mode. In
HALT Mode, the operating characteristics are:
• Primary crystal oscillator is enabled and continues to operate
28
The eZ8 CPU can be brought out of HALT Mode by any of the following operations:
• Interrupt
• WDT time-out (interrupt or reset)
• Power-On Reset
• Voltage Brown-Out reset
• External RESET pin assertion
To minimize current in HALT Mode, all GPIO pins which are configured as inputs must
be driven to one of the supply rails (VCC or GND).
29
General-Purpose Input/Output
Z8 Encore! XP® F0822 Series products support a maximum of 19 Port A–C pins for Gen-
eral-Purpose Input/Output (GPIO) operations. Each port consists Control and Data regis-
ters. The GPIO Control registers are used to determine data direction, open-drain, output
drive current, programmable pull-ups, Stop Mode Recovery functionality, and alternate
pin functions. Each port pin is individually programmable. Ports A and C support 5 V-tol-
erant inputs.
Architecture
Figure 8 displays a simplified block diagram of a GPIO port pin. It does not display the
ability to accommodate alternate functions, variable port current drive strength, and pro-
grammable pull-up.
30
Q D Q D
System
Clock
VDD
Port Output Control
Port Output
Data Register
DATA
Bus D Q Port
Pin
System
Clock
31
GPIO Interrupts
Many of GPIO port pins are used as interrupt sources. Some port pins are configured to
generate an interrupt request on either the rising edge or falling edge of the pin input sig-
nal. Other port pin interrupts generate an interrupt when any edge occurs (both rising and
falling). For more details about interrupts using the GPIO pins, see Figure 8.
32
Bit 7 6 5 4 3 2 1 0
Field PADDR[7:0]
RESET 00H
R/W R/W
Address FD0H, FD4H, FD8H
Bit Description
[7:0] Port Address
PADDR The Port Address selects one of the subregisters accessible through the Port Control Register.
00H = No function. Provides some protection against accidental port reconfiguration.
01H = Data Direction.
02H = Alternate Function.
03H = Output Control (Open-Drain).
04H = High Drive Enable.
05H = Stop Mode Recovery Source Enable.
06H = Pull-up Enable.
07H–FFH = no function.
33
Bit 7 6 5 4 3 2 1 0
Field PCTL
RESET 00H
R/W R/W
Address FD1H, FD5H, FD9H
Bit Description
[7:0] Port Control
PCTL The Port Control Register provides access to all subregisters that configure the GPIO port
operation.
Bit 7 6 5 4 3 2 1 0
Field DD7 DD6 DD5 DD4 DD3 DD2 DD1 DD0
RESET 1
R/W R/W
Address See footnote.
Note: If 01H is written to the Port A–C Address Register, then it is accessible via the Port A–C Control Register.
Bit Description
[7:0] Data Direction
DDx These bits control the direction of the associated port pin. Port Alternate Function operation
overrides the Data Direction Register setting.
0 = Output. Data in the Port A–C Output Data Register is driven onto the port pin.
1 = Input. The port pin is sampled and the value written into the Port A–C Input Data Register.
The output driver is tri-stated.
Note: x indicates register bits in the range [7:0].
34
Caution: Do not enable alternate functions for GPIO port pins which do not have an associated al-
ternate function. Failure to follow this guideline can result in unpredictable operation.
Bit 7 6 5 4 3 2 1 0
Field AF7 AF6 AF5 AF4 AF3 AF2 AF1 AF0
RESET 0
R/W R/W
Address See footnote.
Note: If 02H is written to the Port A–C Address Register, then it is accessible via the Port A–C Control Register.
Bit Description
[7:0] Port Alternate Function enabled
AFx 0 = The port pin is in NORMAL Mode and the DDx bit in the Port A–C Data Direction Subregis-
ter determines the direction of the pin.
1 = The alternate function is selected. Port pin operation is controlled by the alternate function.
Note: x indicates register bits in the range [7:0].
35
Bit 7 6 5 4 3 2 1 0
Field POC7 POC6 POC5 POC4 POC3 POC2 POC1 POC0
RESET 0
R/W R/W
Address See footnote.
Note: If 03H is written to the Port A–C Address Register, then it is accessible via the Port A–C Control Register.
Bit Description
[7:0] Port Output Control
POCx These bits function independently of the alternate function bit and always disable the drains if
set to 1.
0 = The drains are enabled for any output mode (unless overridden by the alternate function).
1 = The drain of the associated pin is disabled (open-drain mode).
Note: x indicates register bits in the range [7:0].
36
Bit 7 6 5 4 3 2 1 0
Field PHDE7 PHDE6 PHDE5 PHDE4 PHDE3 PHDE2 PHDE1 PHDE0
RESET 0
R/W R/W
Address See footnote.
Note: If 04H is written to the Port A–C Address Register, then it is accessible via the Port A–C Control Register.
Bit Description
[7:0] Port High Drive Enabled
PHDEx 0 = The port pin is configured for standard-output current drive.
1 = The port pin is configured for high-output current drive.
Note: x indicates register bits in the range [7:0].
37
Table 20. Port A–C Stop Mode Recovery Source Enable Subregisters
Bit 7 6 5 4 3 2 1 0
Field PSMRE7 PSMRE6 PSMRE5 PSMRE4 PSMRE3 PSMRE2 PSMRE1 PSMRE0
RESET 0
R/W R/W
Address See footnote.
Note: If 05H is written to the Port A–C Address Register, then it is accessible through the Port A–C Control Register.
Bit Description
[7:0] Port Stop Mode Recovery Source Enabled
PSMREx 0 = The port pin is not configured as a Stop Mode Recovery source. Transitions on this pin dur-
ing STOP Mode does not initiate Stop Mode Recovery.
1 = The port pin is configured as a Stop Mode Recovery source. Any logic transition on this pin
during STOP Mode initiates Stop Mode Recovery.
Note: x indicates register bits in the range [7:0].
38
Bit 7 6 5 4 3 2 1 0
Field PPUE7 PPUE6 PPUE5 PPUE4 PPUE3 PPUE2 PPUE1 PPUE0
RESET 0
R/W R/W
Address See footnote.
Note: If 06H is written to the Port A–C Address Register, then it is accessible through the Port A–C Control Register.
Bit Description
[7:0] Port Pull-up Enabled
PPUEx 0 = The weak pull-up on the port pin is disabled.
1 = The weak pull-up on the port pin is enabled.
Note: x indicates register bits in the range [7:0].
Bit 7 6 5 4 3 2 1 0
Field PIN7 PIN6 PIN5 PIN4 PIN3 PIN2 PIN1 PIN0
RESET X
R/W R
Address FD2H, FD6H, FDAH
Bit Description
[7:0] Port Input Data
PxIN Sampled data from the corresponding port pin input.
0 = Input data is logical 0 (Low).
1 = Input data is logical 1 (High).
Note: x indicates register bits in the range [7:0].
39
Bit 7 6 5 4 3 2 1 0
Field POUT7 POUT6 POUT5 POUT4 POUT3 POUT2 POUT1 POUT0
RESET 0
R/W R/W
Address FD3H, FD7H, FDBH
Bit Description
[7:0] Port Output Data
PxOUT These bits contain the data to be driven to the port pins. The values are only driven if the corre-
sponding pin is configured as an output and the pin is not configured for alternate function
operation.
0 = Drive a logical 0 (Low).
1 = Drive a logical 1 (High). This High value is not driven if the drain has been disabled by set-
ting the corresponding Port Output Control Register bit to 1.
Note: x indicates register bits in the range [7:0].
40
Interrupt Controller
The interrupt controller on Z8 Encore! XP® F0822 Series products prioritizes the interrupt
requests from the on-chip peripherals and the GPIO port pins. The features of the interrupt
controller include the following:
• 19 unique interrupt vectors:
– 12 GPIO port pin interrupt sources
– 7 On-chip peripheral interrupt sources
41
Program Memory
Priority Vector Address Interrupt Source
Highest 0002H Reset (not an interrupt)
0004H WDT (see the Watchdog Timer chapter on page 70)
0006H Illegal Instruction Trap (not an interrupt)
0008H Reserved
000AH Timer 1
000CH Timer 0
000EH UART 0 receiver
0010H UART 0 transmitter
0012H I2C
0014H SPI
0016H ADC
0018H Port A7, rising or falling input edge
001AH Port A6, rising or falling input edge
001CH Port A5, rising or falling input edge
001EH Port A4, rising or falling input edge
0020H Port A3, rising or falling input edge
0022H Port A2, rising or falling input edge
0024H Port A1, rising or falling input edge
0026H Port A0, rising or falling input edge
0028H Reserved
002AH Reserved
002CH Reserved
002EH Reserved
0030H Port C3, both input edges
0032H Port C2, both input edges
0034H Port C1, both input edges
Lowest 0036H Port C0, both input edges
42
Architecture
Figure 9 displays a block diagram of the interrupt controller.
Vector
Medium Priority
Priority Mux IRQ Request
Operation
This section describes the operational aspects of the following functions.
Master Interrupt Enable: see page 42
Interrupt Vectors and Priority: see page 43
Interrupt Assertion: see page 43
Software Interrupt Assertion: see page 44
43
Interrupt Assertion
Interrupt sources assert their interrupt requests for only a single system clock period (sin-
gle pulse). When the interrupt request is acknowledged by the eZ8 CPU, the correspond-
ing bit in the Interrupt Request Register is cleared until the next interrupt occurs. Writing a
0 to the corresponding bit in the Interrupt Request Register likewise clears the interrupt
request.
Caution: Zilog recommends not using a coding style that clears bits in the Interrupt Request reg-
isters. All incoming interrupts received between execution of the first LDX command
and the final LDX command are lost. See Example 1, which follows.
Example 1. A poor coding style that can result in lost interrupt requests:
LDX r0, IRQ0
AND r0, MASK
LDX IRQ0, r0
44
To avoid missing interrupts, use the coding style in Example 2 to clear bits in the Interrupt
Request 0 Register:
Example 2. A good coding style that avoids lost interrupt requests:
ANDX IRQ0, MASK
Caution: Zilog recommends not using a coding style to generate software interrupts by setting bits
in the Interrupt Request registers. All incoming interrupts received between execution of
the first LDX command and the final LDX command are lost. See Example 3, which fol-
lows.
Example 3. A poor coding style that can result in lost interrupt requests:
LDX r0, IRQ0
OR r0, MASK
LDX IRQ0, r0
To avoid missing interrupts, use the coding style in Example 4 to set bits in the Interrupt
Request registers:
Example 4. A good coding style that avoids lost interrupt requests:
ORX IRQ0, MASK
45
Bit 7 6 5 4 3 2 1 0
Field Reserved T1I T0I U0RXI U0TXI I2CI SPII ADCI
RESET 0
R/W R/W
Address FC0H
Bit Description
[7] Reserved
This bit is reserved and must be programmed to 0.
[6] Timer 1 Interrupt Request
T1I 0 = No interrupt request is pending for Timer 1.
1 = An interrupt request from Timer 1 is awaiting service.
[5] Timer 0 Interrupt Request
T0I 0 = No interrupt request is pending for Timer 0.
1 = An interrupt request from Timer 0 is awaiting service.
[4] UART 0 Receiver Interrupt Request
U0RXI 0 = No interrupt request is pending for the UART 0 receiver.
1 = An interrupt request from the UART 0 receiver is awaiting service.
[3] UART 0 Transmitter Interrupt Request
U0TXI 0 = No interrupt request is pending for the UART 0 transmitter.
1 = An interrupt request from the UART 0 transmitter is awaiting service.
[2] I2C Interrupt Request
I2CI 0 = No interrupt request is pending for the I2C.
1 = An interrupt request from the I2C is awaiting service.
46
Bit 7 6 5 4 3 2 1 0
Field PA7I PA6I PA5I PA4I PA3I PA2I PA1I PA0I
RESET 0
R/W R/W
Address FC3H
Bit Description
[7:0] Port A Pin x Interrupt Request
PAxI 0 = No interrupt request is pending for GPIO Port A pin x.
1 = An interrupt request from GPIO Port A pin x is awaiting service.
Note: x indicates register bits in the range [7:0].
47
Bit 7 6 5 4 3 2 1 0
Field Reserved PC3I PC2I PC1I PC0I
RESET 0
R/W R/W
Address FC6H
Bit Description
[7:4] Reserved
These bits are reserved and must be programmed to 0000.
[3:0] Port C Pin x Interrupt Request
PCxI 0 = No interrupt request is pending for GPIO Port C pin x.
1 = An interrupt request from GPIO Port C pin x is awaiting service.
Note: x indicates register bits in the range [3:0].
48
Bit 7 6 5 4 3 2 1 0
Field Reserved T1ENH T0ENH U0RENH U0TENH I2CENH SPIENH ADCENH
RESET 0
R/W R/W
Address FC1H
Bit Description
[7] Reserved
This bit is reserved and must be programmed to 0.
[6] Timer 1 Interrupt Request Enable High Bit
T1ENH
[5] Timer 0 Interrupt Request Enable High Bit
T0ENH
[4] UART 0 Receive Interrupt Request Enable High Bit
U0RENH
[3] UART 0 Transmit Interrupt Request Enable High Bit
U0TENH
[2] I2C Interrupt Request Enable High Bit
I2CENH
[1] SPI Interrupt Request Enable High Bit
SPIENH
[0] ADC Interrupt Request Enable High Bit
ADCENH
49
Bit 7 6 5 4 3 2 1 0
Field Reserved T1ENL T0ENL U0RENL U0TENL I2CENL SPIENL ADCENL
RESET 0
R/W R/W
Address FC2H
Bit Description
[7] Reserved
This bit is reserved and must be programmed to 0.
[6] Timer 1 Interrupt Request Enable Low Bit
T1ENL
[5] Timer 0 Interrupt Request Enable Low Bit
T0ENL
[4] UART 0 Receive Interrupt Request Enable Low Bit
U0RENL
[3] UART 0 Transmit Interrupt Request Enable Low Bit
U0TENL
[2] I2C Interrupt Request Enable Low Bit
I2CENL
[1] SPI Interrupt Request Enable Low Bit
SPIENL
[0] ADC Interrupt Request Enable Low Bit
ADCENL
50
Bit 7 6 5 4 3 2 1 0
Field PA7ENH PA6ENH PA5ENH PA4ENH PA3ENH PA2ENH PA1ENH PA0ENH
RESET 0
R/W R/W
Address FC4H
Bit Description
[7:0] Port A Bit[x] Interrupt Request Enable High Bit
PAxENH
Note: x indicates register bits in the range [7:0].
Bit 7 6 5 4 3 2 1 0
Field PA7ENL PA6ENL PA5ENL PA4ENL PA3ENL PA2ENL PA1ENL PA0ENL
RESET 0
R/W R/W
Address FC5H
Bit Description
[7:0] Port A Bit[x] Interrupt Request Enable Low Bit
PAxENL
Note: x indicates register bits in the range [7:0].
51
Bit 7 6 5 4 3 2 1 0
Field Reserved C3ENH C2ENH C1ENH C0ENH
RESET 0
R/W R/W
Address FC7H
Bit Description
[7:4] Reserved
These bits are reserved and must be programmed to 0000.
[3] Port C3 Interrupt Request Enable High Bit
C3ENH
[2] Port C2 Interrupt Request Enable High Bit
C2ENH
[1] Port C1 Interrupt Request Enable High Bit
C1ENH
[0] Port C0 Interrupt Request Enable High Bit
C0ENH
52
Bit 7 6 5 4 3 2 1 0
Field Reserved C3ENL C2ENL C1ENL C0ENL
RESET 0
R/W R/W
Address FC8H
Bit Description
[7:4] Reserved
These bits are reserved and must be programmed to 0000.
[3] Port C3 Interrupt Request Enable Low Bit
C3ENL
[2] Port C2 Interrupt Request Enable Low Bit
C2ENL
[1] Port C1 Interrupt Request Enable Low Bit
C1ENL
[0] Port C0 Interrupt Request Enable Low Bit
C0ENL
Bit 7 6 5 4 3 2 1 0
Field IES7 IES6 IES5 IES4 IES3 IES2 IES1 IES0
RESET 0
R/W R/W
Address FCDH
Bit Description
[7:0] Interrupt Edge Select x
IESx 0 = An interrupt request is generated on the falling edge of the PAx input.
1 = An interrupt request is generated on the rising edge of the PAx input.
Note: x indicates register bits in the range [7:0].
53
Bit 7 6 5 4 3 2 1 0
Field IRQE Reserved
RESET 0
R/W R/W R
Address FCFH
Bit Description
[7] Interrupt Request Enable
IRQE This bit is set to 1 by execution of an Enable Interrupts (EI) or Interrupt Return (IRET) instruc-
tion, or by a direct register write of a 1 to this bit. It is reset to 0 by executing a DI instruction,
eZ8 CPU acknowledgement of an interrupt request, Reset or by a direct register write of a 0 to
this bit.
0 = Interrupts are disabled.
1 = Interrupts are enabled.
[6:0] Reserved
These bits are reserved and must be programmed to 000000.
54
Timers
Z8 Encore! XP® F0822 Series products contain up to two 16-bit reloadable timers that can
be used for timing, event counting, or generation of pulse-width modulated signals. The
timer features include:
• 16-bit reload counter
• Programmable prescaler with prescale values from 1 to 128
• PWM output generation
• Capture and compare capability
• External input pin for timer input, clock gating, or capture signal; external input pin sig-
nal frequency is limited to a maximum of one-fourth the system clock frequency
• Timer output pin
• Timer interrupt
In addition to the timers described in this chapter, the Baud Rate Generators for any
unused UART, SPI, or I2C peripherals can also be used to provide basic timing functional-
ity. See the respective serial communication peripheral chapters for information about
using the Baud Rate Generators as timers.
55
Architecture
Figure 10 displays the architecture of the timers.
Timer Block
Data Timer
Bus Control
Block
Control
16-Bit Interrupt, Timer
Compare
Reload Register PWM, Interrupt
and
Timer Output
System Timer
Control Output
Clock 16-Bit Counter
Timer with Prescaler
Input
Compare
Gate
16-Bit
Input
PWM/Compare
Capture
Input
Operation
The timers are 16-bit up-counters. Minimum time-out delay is set by loading the value
0001H into the Timer Reload High and Low Byte registers and setting the prescale value
to 1. Maximum time-out delay is set by loading the value 0000H into the Timer Reload
High and Low Byte registers and setting the prescale value to 128. If the Timer reaches
FFFFH, the timer rolls over to 0000H and continues counting.
ONE-SHOT Mode
In ONE-SHOT Mode, the timer counts up to the 16-bit reload value stored in the Timer
Reload High and Low Byte registers. The timer input is the system clock. Upon reaching
the reload value, the timer generates an interrupt and the count value in the Timer High
56
and Low Byte registers is reset to 0001H. Then, the timer is automatically disabled and
stops counting.
Also, if the Timer Output alternate function is enabled, the Timer Output pin changes
state for one system clock cycle (from Low to High or vice-versa) on timer reload. If it is
required for the Timer Output to make a permanent state change on One-Shot time-out,
first set the TPOL bit in the Timer Control Register to the start value before beginning
ONE-SHOT Mode. Then, after starting the timer, set TPOL to the opposite bit value.
Observe the following procedure for configuring a timer for ONE-SHOT Mode and initi-
ating the count:
1. Write to the Timer Control Register to:
– Disable the timer
– Configure the timer for ONE-SHOT Mode
– Set the prescale value
– If using the Timer Output alternate function, set the initial output level (High or
Low)
2. Write to the Timer High and Low Byte registers to set the starting count value.
3. Write to the Timer Reload High and Low Byte registers to set the reload value.
4. If appropriate, enable the timer interrupt and set the timer interrupt priority by writing
to the relevant interrupt registers.
5. If using the Timer Output function, configure the associated GPIO port pin for the
Timer Output alternate function.
6. Write to the Timer Control Register to enable the timer and initiate counting.
In ONE-SHOT Mode, the system clock always provides the timer input. The timer period
is calculated using the following equation:
CONTINUOUS Mode
In CONTINUOUS Mode, the timer counts up to the 16-bit reload value stored in the
Timer Reload High and Low Byte registers. The timer input is the system clock. Upon
reaching the reload value, the timer generates an interrupt, the count value in the Timer
High and Low Byte registers is reset to 0001H and counting resumes. Also, if the Timer
Output alternate function is enabled, the Timer Output pin changes state (from Low to
High or from High to Low) upon timer reload.
57
Observe the following procedure for configuring a timer for CONTINUOUS Mode and
initiating the count:
1. Write to the Timer Control Register to:
– Disable the timer
– Configure the timer for CONTINUOUS Mode
– Set the prescale value.
– If using the Timer Output alternate function, set the initial output level (High or
Low)
2. Write to the Timer High and Low Byte registers to set the starting count value (usually
0001H). This starting count value only affects the first pass in CONTINUOUS Mode.
After the first timer reload in CONTINUOUS Mode, counting always begins at the
reset value of 0001H.
3. Write to the Timer Reload High and Low Byte registers to set the reload value.
4. If appropriate, enable the timer interrupt and set the timer interrupt priority by writing
to the relevant interrupt registers.
5. If using the Timer Output function, configure the associated GPIO port pin for the
Timer Output alternate function.
6. Write to the Timer Control Register to enable the timer and initiate counting.
In CONTINUOUS Mode, the system clock always provides the timer input. The timer
period is calculated using the following equation:
If an initial starting value other than 0001H is loaded into the Timer High and Low Byte
registers, the ONE-SHOT Mode equation must be used to determine the first time-out
period.
COUNTER Mode
In COUNTER Mode, the timer counts input transitions from a GPIO port pin. The timer
input is taken from the GPIO Port pin Timer Input alternate function. The TPOL bit in the
Timer Control Register selects whether the count occurs on the rising edge or the falling
edge of the Timer Input signal. In COUNTER Mode, the prescaler is disabled.
Caution: The input frequency of the Timer Input signal must not exceed one-fourth system clock
frequency.
58
Upon reaching the reload value stored in the Timer Reload High and Low Byte registers,
the timer generates an interrupt, the count value in the Timer High and Low Byte registers
is reset to 0001H and counting resumes. Also, if the Timer Output alternate function is
enabled, the Timer Output pin changes state (from Low to High or from High to Low) at
timer reload.
Observe the following procedure for configuring a timer for COUNTER Mode and initiat-
ing the count:
1. Write to the Timer Control Register to:
– Disable the timer
– Configure the timer for COUNTER Mode
– Select either the rising edge or falling edge of the Timer Input signal for the count.
This selection also sets the initial logic level (High or Low) for the Timer Output
alternate function; however, the Timer Output function does not have to be
enabled.
2. Write to the Timer High and Low Byte registers to set the starting count value. This
only affects the first pass in COUNTER Mode. After the first timer reload in COUN-
TER Mode, counting always begins at the reset value of 0001H. Generally, in COUN-
TER Mode the Timer High and Low Byte registers must be written with the value
0001H.
3. Write to the Timer Reload High and Low Byte registers to set the reload value.
4. If required, enable the timer interrupt and set the timer interrupt priority by writing to
the relevant interrupt registers.
5. Configure the associated GPIO port pin for the Timer Input alternate function.
6. If using the Timer Output function, configure the associated GPIO port pin for the
Timer Output alternate function.
7. Write to the Timer Control Register to enable the timer.
In COUNTER Mode, the number of timer input transitions since the timer start is calcu-
lated using the following equation:
COUNTER Mode Timer Input Transitions = Current Count Value – Start Value
PWM Mode
In PWM Mode, the timer outputs a Pulse-Width Modulator output signal through a GPIO
port pin. The timer input is the system clock. The timer first counts up to the 16-bit PWM
match value stored in the Timer PWM High and Low Byte registers. When the timer count
59
value matches the PWM value, the Timer Output toggles. The timer continues counting
until it reaches the reload value stored in the Timer Reload High and Low Byte registers.
Upon reaching the reload value, the timer generates an interrupt, the count value in the
Timer High and Low Byte registers is reset to 0001H and counting resumes.
If the TPOL bit in the Timer Control Register is set to 1, the Timer Output signal begins as
a High (1) and then transitions to a Low (0) when the timer value matches the PWM value.
The Timer Output signal returns to a High (1) after the timer reaches the reload value and
is reset to 0001H.
If the TPOL bit in the Timer Control Register is set to 0, the Timer Output signal begins as
a Low (0) and then transitions to a High (1) when the timer value matches the PWM value.
The Timer Output signal returns to a Low (0) after the timer reaches the reload value and
is reset to 0001H.
Observe the following procedure for configuring a timer for PWM Mode and initiating the
PWM operation:
1. Write to the Timer Control Register to:
– Disable the timer
– Configure the timer for PWM Mode
– Set the prescale value
– Set the initial logic level (High or Low) and PWM High/Low transition for the
Timer Output alternate function
2. Write to the Timer High and Low Byte registers to set the starting count value (typi-
cally 0001H). This only affects the first pass in PWM Mode. After the first timer reset
in PWM Mode, counting always begins at the reset value of 0001H.
3. Write to the PWM High and Low Byte registers to set the PWM value.
4. Write to the Timer Reload High and Low Byte registers to set the reload value (PWM
period). The reload value must be greater than the PWM value.
5. If required, enable the timer interrupt and set the timer interrupt priority by writing to
the relevant interrupt registers.
6. Configure the associated GPIO port pin for the Timer Output alternate function.
7. Write to the Timer Control Register to enable the timer and initiate counting.
60
If an initial starting value other than 0001H is loaded into the Timer High and Low Byte
registers, the ONE-SHOT Mode equation is used to determine the first PWM time-out
period.
If TPOL is set to 0, the ratio of the PWM output High time to the total period is calculated
using the following equation:
If TPOL is set to 1, the ratio of the PWM output High time to the total period is calculated
using the following equation:
PWM Value
PWM Output High Time Ratio (%) = ------------------------------------ x100
Reload Value
CAPTURE Mode
In CAPTURE Mode, the current timer count value is recorded when the appropriate exter-
nal Timer Input transition occurs. The capture count value is written to the Timer PWM
High and Low Byte registers. The timer input is the system clock. The TPOL bit in the
Timer Control Register determines if the Capture occurs on a rising edge or a falling edge
of the Timer Input signal. When the capture event occurs, an interrupt is generated and the
timer continues counting.
The timer continues counting up to the 16-bit reload value stored in the Timer Reload
High and Low Byte registers. Upon reaching the reload value, the timer generates an inter-
rupt and continues counting.
Observe the following procedure for configuring a timer for CAPTURE Mode and initiat-
ing the count:
1. Write to the Timer Control Register to:
– Disable the timer
– Configure the timer for CAPTURE Mode
– Set the prescale value
– Set the Capture edge (rising or falling) for the Timer Input
2. Write to the Timer High and Low Byte registers to set the starting count value (typi-
cally 0001H).
3. Write to the Timer Reload High and Low Byte registers to set the reload value.
4. Clear the Timer PWM High and Low Byte registers to 0000H. This allows user soft-
ware to determine if interrupts were generated by either a capture event or a reload. If
61
the PWM High and Low Byte registers still contains 0000H after the interrupt, then
the interrupt was generated by a reload.
5. If required, enable the timer interrupt and set the timer interrupt priority by writing to
the relevant interrupt registers.
6. Configure the associated GPIO port pin for the Timer Input alternate function.
7. Write to the Timer Control Register to enable the timer and initiate counting.
In CAPTURE Mode, the elapsed time from timer start to capture event is calculated using
the following equation:
COMPARE Mode
In COMPARE Mode, the timer counts up to the 16-bit maximum Compare value stored in
the Timer Reload High and Low Byte registers. The timer input is the system clock. Upon
reaching the Compare value, the timer generates an interrupt and counting continues (the
timer value is not reset to 0001H). Also, if the Timer Output alternate function is enabled,
the Timer Output pin changes state (from Low to High or from High to Low) upon Com-
pare.
If the Timer reaches FFFFH, the timer rolls over to 0000H and continue counting.
Observe the following procedure for configuring a timer for COMPARE Mode and initiat-
ing the count:
1. Write to the Timer Control Register to:
– Disable the timer
– Configure the timer for COMPARE Mode
– Set the prescale value
– Set the initial logic level (High or Low) for the Timer Output alternate function, if
required
2. Write to the Timer High and Low Byte registers to set the starting count value.
3. Write to the Timer Reload High and Low Byte registers to set the Compare value.
4. If required, enable the timer interrupt and set the timer interrupt priority by writing to
the relevant interrupt registers.
5. If using the Timer Output function, configure the associated GPIO port pin for the
Timer Output alternate function.
6. Write to the Timer Control Register to enable the timer and initiate counting.
62
In COMPARE Mode, the system clock always provides the timer input. The Compare
time is calculated by the following equation:
GATED Mode
In GATED Mode, the timer counts only when the Timer Input signal is in its active state
(asserted), as determined by the TPOL bit in the Timer Control Register. When the Timer
Input signal is asserted, counting begins. A timer interrupt is generated when the Timer
Input signal is deasserted or a timer reload occurs. To determine if a Timer Input signal
deassertion generated the interrupt, read the associated GPIO input value and compare to
the value stored in the TPOL bit.
The timer counts up to the 16-bit reload value stored in the Timer Reload High and Low
Byte registers. The timer input is the system clock. When reaching the reload value, the
timer generates an interrupt, the count value in the Timer High and Low Byte registers is
reset to 0001H and counting resumes (assuming the Timer Input signal is still asserted).
Also, if the Timer Output alternate function is enabled, the Timer Output pin changes state
(from Low to High or from High to Low) at timer reset.
Observe the following procedure for configuring a timer for GATED Mode and initiating
the count:
1. Write to the Timer Control Register to:
– Disable the timer
– Configure the timer for GATED Mode
– Set the prescale value
2. Write to the Timer High and Low Byte registers to set the starting count value. This
only affects the first pass in GATED Mode. After the first timer reset in GATED
Mode, counting always begins at the reset value of 0001H.
3. Write to the Timer Reload High and Low Byte registers to set the reload value.
4. If appropriate, enable the timer interrupt and set the timer interrupt priority by writing
to the relevant interrupt registers.
5. Configure the associated GPIO port pin for the Timer Input alternate function.
6. Write to the Timer Control Register to enable the timer.
7. Assert the Timer Input signal to initiate the counting.
63
CAPTURE/COMPARE Mode
In CAPTURE/COMPARE Mode, the timer begins counting on the first external Timer
Input transition. The required transition (rising edge or falling edge) is set by the TPOL bit
in the Timer Control Register. The timer input is the system clock.
Every subsequent transition of the Timer Input signal (after the first, and if appropriate)
captures the current count value. The Capture value is written to the Timer PWM High and
Low Byte registers. When the capture event occurs, an interrupt is generated, the count
value in the Timer High and Low Byte registers is reset to 0001H and counting resumes.
If no capture event occurs, the timer counts up to the 16-bit Compare value stored in the
Timer Reload High and Low Byte registers. Upon reaching the Compare value, the timer
generates an interrupt, the count value in the Timer High and Low Byte registers is reset to
0001H and counting resumes.
Observe the following procedure for configuring a timer for CAPTURE/COMPARE
Mode and initiating the count:
1. Write to the Timer Control Register to:
– Disable the timer
– Configure the timer for CAPTURE/COMPARE Mode
– Set the prescale value
– Set the Capture edge (rising or falling) for the Timer Input
2. Write to the Timer High and Low Byte registers to set the starting count value (typi-
cally 0001H).
3. Write to the Timer Reload High and Low Byte registers to set the Compare value.
4. If appropriate, enable the timer interrupt and set the timer interrupt priority by writing
to the relevant interrupt registers.
5. Configure the associated GPIO port pin for the Timer Input alternate function.
6. Write to the Timer Control Register to enable the timer.
7. Counting begins on the first appropriate transition of the Timer Input signal. No inter-
rupt is generated by this first edge.
In CAPTURE/COMPARE Mode, the elapsed time from timer start to capture event is cal-
culated using the following equation:
64
65
Bit 7 6 5 4 3 2 1 0
Field TH
RESET 0
R/W R/W
Address F00H, F08H
Bit 7 6 5 4 3 2 1 0
Field TL
RESET 0 1
R/W R/W
Address F01H, F09H
Bit Description
[7:0] Timer High and Low Bytes
TH, TL These 2 bytes, {TMRH[7:0], TMRL[7:0]}, contain the current 16-bit timer count value.
Bit 7 6 5 4 3 2 1 0
Field TRH
RESET 1
R/W R/W
Address F02H, F0AH
66
Bit 7 6 5 4 3 2 1 0
Field TRL
RESET 1
R/W R/W
Address F03H, F0BH
Bit Description
[7] Timer Reload Register High and Low
TRH, These two bytes form the 16-bit reload value, {TRH[7:0], TRL[7:0]}. This value sets the maxi-
TRL mum count value which initiates a timer reload to 0001H. In COMPARE Mode, these two bytes
form the 16-bit Compare value.
Bit 7 6 5 4 3 2 1 0
Field PWMH
RESET 0
R/W R/W
Address F04H, F0CH
Bit 7 6 5 4 3 2 1 0
Field PWML
RESET 0
R/W R/W
Address F05H, F0DH
67
Bit Description
[7:0] Pulse-Width Modulator High and Low Bytes
PWMH, These two bytes, {PWMH[7:0], PWML[7:0]}, form a 16-bit value that is compared to the current
PWML 16-bit timer count. When a match occurs, the PWM output changes state. The PWM output
value is set by the TPOL bit in the Timer Control (TxCTL) Register.
The TxPWMH and TxPWML registers also store the 16-bit captured timer value when operat-
ing in CAPTURE or CAPTURE/COMPARE modes.
Bit 7 6 5 4 3 2 1 0
Field Reserved CSC Reserved
RESET 0
R/W R/W
Address F06H, F0EH, F16H, F1EH
Bit Description
[7:5] Reserved
These bits are reserved and must be programmed to 000.
[4] Cascade Timers
CSC 0 = Timer Input signal comes from the pin.
1 = For Timer 0, input signal is connected to Timer 1 output. For Timer 1, the input signal is
connected to the Timer 0 output.
[3:0] Reserved
These bits are reserved and must be programmed to 0000.
68
Bit 7 6 5 4 3 2 1 0
Field TEN TPOL PRES TMODE
RESET 0
R/W R/W
Address F07H, F0FH
Bit Description
[7] Timer Enable
TEN 0 = Timer is disabled.
1 = Timer enabled to count.
[6] Timer Input/Output Polarity
TPOL Operation of this bit is a function of the current operating mode of the timer.
ONE-SHOT Mode
When the timer is disabled, the Timer Output signal is set to the value of this bit.
When the timer is enabled, the Timer Output signal is complemented upon timer reload.
CONTINUOUS Mode
When the timer is disabled, the Timer Output signal is set to the value of this bit. When the
timer is enabled, the Timer Output signal is complemented upon timer reload.
COUNTER Mode
If the timer is enabled the Timer Output signal is complemented after timer reload.
0 = Count occurs on the rising edge of the Timer Input signal.
1 = Count occurs on the falling edge of the Timer Input signal.
PWM Mode
0 = Timer Output is forced Low (0) when the timer is disabled. When enabled, the Timer Output
is forced High (1) upon PWM count match and forced Low (0) upon reload.
1 = Timer Output is forced High (1) when the timer is disabled. When enabled, the Timer Out-
put is forced Low (0) upon PWM count match and forced High (1) upon reload.
CAPTURE Mode
0 = Count is captured on the rising edge of the Timer Input signal.
1 = Count is captured on the falling edge of the Timer Input signal.
COMPARE Mode
When the timer is disabled, the Timer Output signal is set to the value of this bit. When the
timer is enabled, the Timer Output signal is complemented upon timer reload.
69
70
Watchdog Timer
Watchdog Timer (WDT) protects against corrupt or unreliable software, power faults, and
other system-level problems which can place the Z8 Encore! XP® F0822 Series device
into unsuitable operating states. It includes the following features:
• On-chip RC oscillator
• A selectable time-out response; either Reset or Interrupt
• 24-bit programmable time-out value
Operation
WDT is a retriggerable one-shot timer that resets or interrupts the Z8 Encore! XP® F0822
Series device when the WDT reaches its terminal count. It uses its own dedicated on-chip
RC oscillator as its clock source. The WDT has only two modes of operation: ON and
OFF. When enabled, it always counts and must be refreshed to prevent a time-out. An
enable is performed by executing the WDT instruction or by setting the WDT_AO option
bit. The WDT_AO bit enables the WDT to operate all of the time, even if a WDT instruc-
tion has not been executed.
The WDT is a 24-bit reloadable downcounter that uses three 8-bit registers in the eZ8
CPU register space to set the reload value. The nominal WDT time-out period is calcu-
lated using the following equation:
In this equation, the WDT reload value is the decimal value of the 24-bit value furnished
by {WDTU[7:0], WDTH[7:0], WDTL[7:0]}; the typical Watchdog Timer RC oscillator
frequency is 10 kHz. WDT cannot be refreshed after it reaches 000002H. The WDT reload
value must not be set to values below 000004H.
Table 47 lists the approximate time-out delays based on minimum and maximum WDT
reload values.
71
72
To minimize power consumption in STOP Mode, the WDT and its RC oscillator is dis-
abled in STOP Mode. The following sequence configures the WDT to be disabled when
the Z8F082x family device enters STOP Mode following execution of a stop instruction:
1. Write 55H to the Watchdog Timer Control Register (WDTCTL).
2. Write AAH to the Watchdog Timer Control Register (WDTCTL).
3. Write 81H to the Watchdog Timer Control Register (WDTCTL) to configure the WDT
and its oscillator to be disabled during STOP Mode. Alternatively, write 00H to the
WDTCTL as the third step in this sequence to reconfigure the WDT and its oscillator
to be enabled during STOP Mode. This sequence only affects WDT operation in
STOP Mode.
73
All three Watchdog Timer Reload registers must be written in this order. There must be no
other register writes between each of these operations. If a register write occurs, the lock
state machine resets and no further writes occur unless the sequence is restarted. The value
in the Watchdog Timer Reload registers is loaded into the counter when the WDT is first
enabled and every time a WDT instruction is executed.
74
Bit 7 6 5 4 3 2 1 0
Field POR STOP WDT EXT Reserved
RESET See Table 49. 0
R/W R
Address FF0H
Bit Description
[7] Power-On Reset Indicator
POR If this bit is set to 1, a POR event occurred. This bit is reset to 0, if a WDT time-out or Stop
Mode Recovery occurs. This bit is also reset to 0, when the register is read.
[6] Stop Mode Recovery Indicator
STOP If this bit is set to 1, a Stop Mode Recovery occurred. If the STOP and WDT bits are both set to
1, the Stop Mode Recovery occurred due to a WDT time-out. If the stop bit is 1 and the WDT bit
is 0, the Stop Mode Recovery was not caused by a WDT time-out. This bit is reset by a POR or
a WDT time-out that occurred while not in STOP Mode. Reading this register also resets this bit.
[5] Watchdog Timer Time-Out Indicator
WDT If this bit is set to 1, a WDT time-out occurred. A POR resets this pin. A Stop Mode Recovery
due a change in an input pin also resets this bit. Reading this register resets this bit.
[4] External Reset Indicator
EXT If this bit is set to 1, a Reset initiated by the external RESET pin occurred. A POR or a Stop
Mode Recovery from a change in an input pin resets this bit. Reading this register resets this bit.
[3:0] Reserved
These bits are reserved and must be programmed to 0000.
75
Caution: The 24-bit WDT reload value must not be set to a value less than 000004H.
Bit 7 6 5 4 3 2 1 0
Field WDTU
RESET 1
R/W R/W*
Address FF1H
Note: *R/W = a read returns the current WDT count value; a write sets the appropriate reload value.
Bit Description
[7:0] WDT Reload Upper Byte
WDTU Most significant byte (MSB), bits [23:16] of the 24-bit WDT reload value.
Bit 7 6 5 4 3 2 1 0
Field WDTH
RESET 1
R/W R/W*
Address FF2H
Note: *R/W = a read returns the current WDT count value; a write sets the appropriate reload value.
Bit Description
[7:0] WDT Reload High Byte
WDTH Middle byte, bits [15:8] of the 24-bit WDT reload value.
76
Bit 7 6 5 4 3 2 1 0
Field WDTL
RESET 1
R/W R/W*
Address FF3H
Note: *R/W = a read returns the current WDT count value; a write sets the appropriate reload value.
Bit Description
[7:0] WDT Reload Low
WDTL Least significant byte (LSB), bits [7:0] of the 24-bit WDT reload value.
77
Architecture
The UART consists of three primary functional blocks: Transmitter, Receiver, and Baud
Rate Generator. The UART’s transmitter and receiver functions independently, but use the
same baud rate and data format. Figure 11 displays the UART architecture.
78
Parity Checker
Receiver Control
with address compare
RXD
Receive Shifter
Receive Data
Register Control Registers
System Bus
Transmit Data
Register Status Register Baud Rate
Generator
Transmit Shift
TXD Register
Transmitter Control
Parity Generator
CTS
DE
Operation
The UART always transmits and receives data in an 8-bit data format, least-significant bit
first. An even or odd parity bit is optionally added to the data stream. Each character
begins with an active Low start bit and ends with either 1 or 2 active High stop bits.
Figures 12 and 13 display the asynchronous data format used by the UART without parity
and with parity, respectively.
79
80
– Set or clear the CTSE bit to enable or disable control from the remote receiver
using the CTS pin.
5. Check the TDRE bit in the UART Status 0 Register to determine if the Transmit Data
Register is empty (indicated by a 1). If empty, continue to Step 6. If the Transmit Data
Register is full (indicated by a 0), continue to monitor the TDRE bit until the Transmit
Data Register becomes available to receive new data.
6. Write the UART Control 1 Register to select the outgoing address bit:
– Set the Multiprocessor Bit Transmitter (MPBT) if sending an address byte, clear it
if sending a data byte.
7. Write data byte to the UART Transmit Data Register. The transmitter automatically
transfers data to the Transmit Shift Register and then transmits the data.
8. If required, and multiprocessor mode is enabled, make any changes to the Multipro-
cessor Bit Transmitter (MPBT) value.
9. To transmit additional bytes, return to Step 5.
81
– Set or clear the CTSE bit to enable or disable control from the remote receiver
through the CTS pin.
7. Execute an EI instruction to enable interrupts.
The UART is now configured for interrupt-driven data transmission. Because the UART
Transmit Data Register is empty, an interrupt is generated immediately. When the UART
transmit interrupt is detected, the associated ISR performs the following:
1. Write the UART Control 1 Register to select the outgoing address bit:
– Set the Multiprocessor Bit Transmitter (MPBT) if sending an address byte; clear it
if sending a data byte.
2. Write the data byte to the UART Transmit Data Register. The transmitter automati-
cally transfers data to the Transmit Shift Register and then transmits the data.
3. Clear the UART transmit interrupt bit in the applicable Interrupt Request Register.
4. Execute the IRET instruction to return from the ISR and waits for the Transmit Data
Register to again become empty.
5. Check the RDA bit in the UART Status 0 Register to determine if the Receive Data
Register contains a valid data byte (indicated by 1). If RDA is set to 1 to indicate
available data, continue to Step 6. If the Receive Data Register is empty (indicated by
a 0), continue to monitor the RDA bit awaiting reception of the valid data.
82
6. Read data from the UART Receive Data Register. If operating in MULTIPROCES-
SOR (9-Bit) Mode, further actions may be required depending on the Multiprocessor
Mode bits MPMD[1:0].
7. Return to Step 5 to receive additional data.
7. Write the device address to the Address Compare Register (automatic multiprocessor
modes only).
8. Write to the UART Control 0 Register to:
– Set the receive enable bit (REN) to enable the UART for data reception
– Enable parity, if required, and if MULTIPROCESSOR Mode is not enabled, and
select either even or odd parity.
83
The UART is now configured for interrupt-driven data reception. When the UART
Receiver Interrupt is detected, the associated ISR performs the following operations:
1. Check the UART Status 0 Register to determine the source of the interrupt, whether
error, break or received data.
2. If the interrupt was due to data available, read the data from the UART Receive Data
Register. If operating in MULTIPROCESSOR (9-Bit) Mode, further actions may be
required depending on the Multiprocessor Mode bits MPMD[1:0].
3. Clear the UART Receiver Interrupt in the applicable Interrupt Request Register.
4. Execute the IRET instruction to return from the ISR and await more data.
84
In MULTIPROCESSOR (9-Bit) Mode, the Parity bit location (9th bit) becomes the Multi-
processor control bit. The UART Control 1 and Status 1 registers provide MULTIPRO-
CESSOR (9-Bit) Mode control and status information. If an automatic address matching
scheme is enabled, the UART Address Compare Register holds the network address of the
device.
These modes are selected with MPMD[1:0] in the UART Control 1 Register. For all
MULTIPROCESSOR modes, bit MPEN of the UART Control 1 Register must be set to 1.
The first scheme is enabled by writing 01b to MPMD[1:0]. In this mode, all incoming
address bytes cause an interrupt, while data bytes never cause an interrupt. The ISR must
manually check the address byte that caused triggered the interrupt. If it matches the
UART address, the software should clear MPMD[0]. At this point, each new incoming
byte interrupts the CPU. The software is then responsible for determining the end-of-
frame. It checks for the end-of-frame by reading the MPRX bit of the UART Status 1 Reg-
ister for each incoming byte. If MPRX=1, then a new frame begins. If the address of this
new frame is different from the UART’s address, then MPMD[0] must be set to 1 causing
the UART interrupts to go inactive until the next address byte. If the new frame’s address
matches the UART’s address, then the data in the new frame should be processed as well.
The second scheme is enabled by setting MPMD[1:0] to 10b and writing the UART’s
address into the UART Address Compare Register. This mode introduces more hardware
control, interrupting only on frames that match the UART’s address. When an incoming
address byte does not match the UART’s address, it is ignored. All successive data bytes in
this frame are also ignored. When a matching address byte occurs, an interrupt is issued
and further interrupts occur on each successive data byte. The first data byte in the frame
contains the NEWFRM = 1 in the UART Status 1 Register. When the next address byte
occurs, the hardware compares it to the UART’s address. If there is a match, the interrupts
continue and the NEWFRM bit is set for the first byte of the new frame. If there is no
match, then the UART ignores all incoming bytes until the next address match.
85
The third scheme is enabled by setting MPMD[1:0] to 11b and by writing the UART’s
address into the UART Address Compare Register. This mode is identical to the second
scheme, except that there are no interrupts on address bytes. The first data byte of each
frame is still accompanied by a NEWFRM assertion.
DE
0
Figure 15. UART Driver Enable Signal Timing (with 1 Stop Bit and Parity)
----------------------------------------
1
- ----------------------------------------
2
-
Baud Rate (Hz) DE to Start Bit Setup Time (s) Baud Rate (Hz)
86
UART Interrupts
The UART features separate interrupts for the transmitter and the receiver. In addition,
when the UART primary functionality is disabled, the BRG also functions as a basic timer
with interrupt capability.
Transmitter Interrupts
The transmitter generates a single interrupt when the Transmit Data Register Empty bit
(TDRE) is set to 1. This indicates that the transmitter is ready to accept new data for trans-
mission. The TDRE interrupt occurs after the Transmit Shift Register has shifted the first
bit of data out. At this point, the Transmit Data Register can be written with the next char-
acter to send. This provides 7 bit periods of latency to load the Transmit Data Register
before the Transmit Shift Register completes shifting the current character. Writing to the
UART Transmit Data Register clears the TDRE bit to 0.
Receiver Interrupts
The receiver generates an interrupt when any of the following occurs:
• A data byte is received and is available in the UART Receive Data Register. This inter-
rupt can be disabled independent of the other receiver interrupt sources. The received
data interrupt occurs after the receive character is received and placed in the Receive
Data Register. Software must respond to this received data available condition before
the next character is completely received to avoid an overrun error. In MULTIPRO-
CESSOR Mode (MPEN = 1), the receive data interrupts are dependent on the multipro-
cessor configuration and the most recent address byte.
• A break is received.
• An overrun is detected.
• A data framing error is detected.
87
Receiver
Ready
Receiver
Interrupt
Read Status
No
Errors?
Yes
88
When the UART is disabled, the BRG functions as a basic 16-bit timer with interrupt upon
time-out. Observe the following procedure to configure the BRG as a timer with interrupt
upon time-out:
1. Disable the UART by clearing the REN and TEN bits in the UART Control 0 Register
to 0.
2. Load the appropriate 16-bit count value into the UART Baud Rate High and Low Byte
registers.
3. Enable the BRG timer function and associated interrupt by setting the BKGCTL bit in
the UART Control 1 Register to 1.
When configured as a general-purpose timer, the interrupt interval is calculated using the
following equation:
Interrupt Interval (s) = System Clock Period (s) ×BRG[15:0] ]
89
Bit 7 6 5 4 3 2 1 0
Field TXD
RESET X X X X X X X X
R/W W W W W W W W W
Address F40H
Bit Description
[7:0] Transmit Data
TXD UART transmitter data byte to be shifted out through the TXDx pin.
Bit 7 6 5 4 3 2 1 0
Field RXD
RESET X
R/W R
Address F40H
Bit Description
[7:0] Receive Data
RXD UART receiver data byte from the RXDx pin.
90
Bit 7 6 5 4 3 2 1 0
Field RDA PE OE FE BRKD TDRE TXE CTS
RESET 0 1 X
R/W R
Address F41H
Bit Description
[7] Receive Data Available
RDA This bit indicates that the UART Receive Data Register has received data. Reading the UART
Receive Data Register clears this bit.
0 = The UART Receive Data Register is empty.
1 = There is a byte in the UART Receive Data Register.
[6] Parity Error
PE This bit indicates that a parity error has occurred. Reading the UART Receive Data Register
clears this bit.
0 = No parity error has occurred.
1 = A parity error has occurred.
[5] Overrun Error
OE This bit indicates that an overrun error has occurred. An overrun occurs when new data is
received and the UART Receive Data Register has not been read. If the RDA bit is reset to 0,
then reading the UART Receive Data Register clears this bit.
0 = No overrun error occurred.
1 = An overrun error occurred.
[4] Framing Error
FE This bit indicates that a framing error (no stop bit following data reception) was detected. Read-
ing the UART Receive Data Register clears this bit.
0 = No framing error occurred.
1 = A framing error occurred.
[3] Break Detect
BRKD This bit indicates that a break occurred. If the data bits, parity/multiprocessor bit, and stop bit(s)
are all zeros then this bit is set to 1. Reading the UART Receive Data Register clears this bit.
0 = No break occurred.
1 = A break occurred.
[2]
TDRE
91
Bit 7 6 5 4 3 2 1 0
Field Reserved NEWFRM MPRX
RESET 0
R/W R R/W R
Address F44H
Bit Description
[7:2] Reserved
These bits are reserved and must be programmed to 000000.
[1] New Frame
NEWFRM Status bit denoting the start of a new frame. Reading the UART Receive Data Register
resets this bit to 0.
0 = The current byte is not the first data byte of a new frame.
1 = The current byte is the first data byte of a new frame.
[0] Multiprocessor Receive
MPRX Returns the value of the last multiprocessor bit received. Reading from the UART Receive
Data Register resets this bit to 0.
92
Bit 7 6 5 4 3 2 1 0
Field TEN REN CTSE PEN PSEL SBRK STOP LBEN
RESET 0
R/W R/W
Address F42H
Bit Description
[7] Transmit Enable
TEN This bit enables or disables the transmitter. The enable is also controlled by the CTS signal
and the CTSE bit. If the CTS signal is Low and the CTSE bit is 1, the transmitter is enabled.
0 = Transmitter disabled.
1 = Transmitter enabled.
[6] Receive Enable
REN This bit enables or disables the receiver.
0 = Receiver disabled.
1 = Receiver enabled.
[5] CTS Enable
CTSE 0 = The CTS signal has no effect on the transmitter.
1 = The UART recognizes the CTS signal as an enable control from the transmitter.
[4] Parity Enable
PEN This bit enables or disables parity. Even or odd is determined by the PSEL bit. This bit is over-
ridden by the MPEN bit.
0 = Parity is disabled.
1 = The transmitter sends data with an additional parity bit and the receiver receives an addi-
tional parity bit.
[3] Parity Select
PSEL 0 = Even parity is transmitted and expected on all received data.
1 = Odd parity is transmitted and expected on all received data.
[2] Send Break
SBRK This bit pauses or breaks data transmission by forcing the Transmit data output to 0. Sending a
break interrupts any transmission in progress, so ensure that the transmitter has finished send-
ing data before setting this bit. The UART does not automatically generate a stop bit when
SBRK is deasserted. Software must time the duration of the break and the duration of any
appropriate stop bit time following the break.
0 = No break is sent.
1 = The output of the transmitter is zero.
93
Bit 7 6 5 4 3 2 1 0
Field MPMD[1] MPEN MPMD[0] MPBT DEPOL BRGCTL RDAIRQ IREN
RESET 0
R/W R/W
Address F43H
Bit Description
[7,5] Multiprocessor Mode
MPMD[1,0] If MULTIPROCESSOR (9-Bit) Mode is enabled,
00 = The UART generates an interrupt request on all received bytes (data and address).
01 = The UART generates an interrupt request only on received address bytes.
10 = The UART generates an interrupt request when a received address byte matches the
value stored in the Address Compare Register and on all successive data bytes until
an address mismatch occurs.
11 = The UART generates an interrupt request on all received data bytes for which the most
recent address byte matched the value in the Address Compare Register.
[6] Multiprocessor (9-Bit) Enable
MPEN This bit is used to enable MULTIPROCESSOR (9-Bit) Mode.
0 = Disable MULTIPROCESSOR (9-Bit) Mode.
1 = Enable MULTIPROCESSOR (9-Bit) Mode.
[4] Multiprocessor Bit Transmit
MPBT This bit is applicable only when MULTIPROCESSOR (9-Bit) Mode is enabled.
0 = Send a 0 in the multiprocessor bit location of the data stream (9th bit).
1 = Send a 1 in the multiprocessor bit location of the data stream (9th bit).
[3] Driver Enable Polarity
DEPOL 0 = DE signal is Active High.
1 = DE signal is Active Low.
94
Bit 7 6 5 4 3 2 1 0
Field COMP_ADDR
RESET 0
R/W R/W
Address F45H
Bit Description
[7:0] Compare Address
COMP_ADDR This 8-bit value is compared to the incoming address bytes.
95
Bit 7 6 5 4 3 2 1 0
Field BRH
RESET 1
R/W R/W
Address F46H
Bit 7 6 5 4 3 2 1 0
Field BRL
RESET 1
R/W R/W
Address F47H
For a given UART data rate, the integer baud rate divisor value is calculated using the fol-
lowing equation:
The baud rate error relative to the desired baud rate is calculated using the following equa-
tion:
96
For reliable communication, the UART baud rate error must never exceed 5 percent.
Table 62 provides information about data rate errors for popular baud rates and commonly
used crystal oscillator frequencies.
97
Infrared Encoder/Decoder
Z8 Encore! XP® F0822 Series products contain a fully-functional, high-performance
UART to Infrared Encoder/Decoder (endec). The infrared endec is integrated with an on-
chip UART to allow easy communication between the Z8 Encore! XP and IrDA Physical
Layer Specification, v1.3-compliant infrared transceivers. Infrared communication pro-
vides secure, reliable, low-cost, point-to-point communication between PCs, PDAs, cell
phones, printers, and other infrared enabled devices.
Architecture
Figure 17 displays the architecture of the infrared endec.
System
Clock Zilog
ZHX1810
RxD RXD
RXD
TxD Infrared TXD
UART Encoder/Decoder TXD
Baud Rate (endec)
Clock Infrared
Transceiver
Operation
When the infrared endec is enabled, the transmit data from the associated on-chip UART
is encoded as digital signals in accordance with the IrDA standard and output to the infra-
red transceiver through the TXD pin. Similarly, data received from the infrared transceiver
is passed to the infrared endec through the RXD pin, decoded by the infrared endec, and
98
then passed to the UART. Communication is half-duplex, which means simultaneous data
transmission and reception is not allowed.
The baud rate is set by the UART’s Baud Rate Generator and supports IrDA standard baud
rates from 9600 baud to 115.2 Kbaud. Higher baud rates are possible, but do not meet
IrDA specifications. The UART must be enabled to use the infrared endec. The infrared
endec data rate is calculated using the following equation.
16-clock
period
Baud Rate
Clock
UART’s Start Bit = 0 Data Bit 0 = 1 Data Bit 1 = 0 Data Bit 2 = 1 Data Bit 3 = 1
TXD
3-clock
pulse
IR_TXD
7-clock
delay
99
16-clock
period
Baud Rate
Clock
Start Bit = 0 Data Bit 0 = 1 Data Bit 1 = 0 Data Bit 2 = 1 Data Bit 3 = 1
IR_RXD
min. 1.6s
pulse
UART’s
RXD Start Bit = 0 Data Bit 0 = 1 Data Bit 1 = 0 Data Bit 2 = 1 Data Bit 3 = 1
8-clock
delay 16-clock 16-clock 16-clock 16-clock
period period period period
Caution: The system clock frequency must be at least 1.0 MHz to ensure proper reception of the
1.6 µs minimum width pulses allowed by the IrDA standard.
100
clock periods since the previous pulse was detected). This period allows the endec a sam-
pling window of –4 to +8 baud rate clocks around the expected time of an incoming pulse.
If an incoming pulse is detected inside this window, this process is repeated. If the incom-
ing data is a logical 1 (no pulse), the endec returns to its initial state and waits for the next
falling edge. As each falling edge is detected, the endec clock counter is reset to resyn-
chronize the endec to the incoming signal. This routine allows the endec to tolerate jitter
and baud rate errors in the incoming data stream. Resynchronizing the endec does not alter
the operation of the UART, which ultimately receives the data. The UART is only syn-
chronized to the incoming data stream when a start bit is received.
Caution: To prevent spurious signals during IrDA data transmission, set the IREN bit in the UART
Control 1 Register to 1 to enable the infrared endec before enabling the GPIO port alter-
nate function for the corresponding pin.
101
Architecture
The SPI is be configured as either a Master (in single- or multiple-master systems) or a
Slave, as shown in Figures 20 through 22.
SPI Master
To Slave’s SS Pin SS
To Slave MOSI
Figure 20. SPI Configured as a Master in a Single Master, Single Slave System
102
VCC
SPI Master
SS
To Slave #2’s SS Pin GPIO
To Slave #1’s SS Pin GPIO
8-bit Shift Register
From Slave
MISO Bit 0 Bit 7
To Slave MOSI
Figure 21. SPI Configured as a Master in a Single Master, Multiple Slave System
SPI Slave
From Master SS
SCK
From Master
103
Operation
The SPI is a full-duplex, synchronous, and character-oriented channel that supports a four-
wire interface (serial clock, transmit, receive and Slave select). The SPI block consists of a
transmit/receive shift register, a Baud Rate (clock) Generator and a control unit.
During an SPI transfer, data is sent and received simultaneously by both the Master and
the Slave SPI devices. Separate signals are required for data and the serial clock. When an
SPI transfer occurs, a multibit (typically 8-bit) character is shifted out one data pin and an
multibit character is simultaneously shifted in on a second data pin. An 8-bit shift register
in the Master and another 8-bit shift register in the Slave are connected as a circular buffer.
The SPI Shift Register is single-buffered in the transmit and receive directions. New data
to be transmitted cannot be written into the shift register until the previous transmission is
complete and receive data (if valid) has been read.
SPI Signals
The four basic SPI signals are:
• MISO (Master-In, Slave-Out)
• MOSI (Master-Out, Slave-In)
• SCK (Serial Clock)
• SS (Slave Select)
The following sections discuss these SPI signals. Each signal is described in both Master
and Slave modes.
Master-In/Slave-Out
The Master-In/Slave-Out (MISO) pin is configured as an input in a Master device and as
an output in a Slave device. It is one of the two lines that transfer serial data, with the most
significant bit sent first. The MISO pin of a Slave device is placed in a high-impedance
state if the Slave is not selected. When the SPI is not enabled, this signal is in a high-
impedance state.
Master-Out/Slave-In
The Master-Out/Slave-In (MOSI) pin is configured as an output in a Master device and as
an input in a Slave device. It is one of the two lines that transfer serial data, with the most
significant bit sent first. When the SPI is not enabled, this signal is in a high-impedance
state.
104
Serial Clock
The Serial Clock (SCK) synchronizes data movement both in and out of the device
through its MOSI and MISO pins. In MASTER Mode, the SPI’s Baud Rate Generator cre-
ates the serial clock. The Master drives the serial clock out its own SCK pin to the Slave’s
SCK pin. When the SPI is configured as a Slave, the SCK pin is an input and the clock sig-
nal from the Master synchronizes the data transfer between the Master and Slave devices.
Slave devices ignore the SCK signal, unless the SS pin is asserted. When configured as a
slave, the SPI block requires a minimum SCK period of greater than or equal to 8 times
the system (XIN) clock period.
The Master and Slave are each capable of exchanging a character of data during a
sequence of NUMBITS clock cycles (see the NUMBITS field in the SPI Mode Register).
In both Master and Slave SPI devices, data is shifted on one edge of the SCK and is sam-
pled on the opposite edge where data is stable. Edge polarity is determined by the SPI
phase and polarity control.
Slave Select
The active Low Slave Select (SS) input signal selects a Slave SPI device. SS must be Low
prior to all data communication to and from the Slave device. SS must stay Low for the
full duration of each character transferred. The SS signal can stay Low during the transfer
of multiple characters or can deassert between each character.
When the SPI is configured as the only Master in an SPI system, the SS pin is set as either
an input or an output. For communication between the Z8 Encore! XP® F0822 Series
device’s SPI Master and external Slave devices, the SS signal, as an output, asserts the SS
input pin on one of the Slave devices. Other GPIO output pins can also be employed to
select external SPI Slave devices.
When the SPI is configured as one Master in a multimaster SPI system, the SS pin should
be set as an input. The SS input signal on the Master must be High. If the SS signal goes
Low (indicating another Master is driving the SPI bus), a Collision error flag is set in the
SPI Status Register.
105
Table 63. SPI Clock Phase (PHASE) and Clock Polarity (CLKPOL) Operation
SCK
(CLKPOL = 0)
SCK
(CLKPOL = 1)
SS
106
SCK
(CLKPOL = 0)
SCK
(CLKPOL = 1)
SS
Multimaster Operation
In a multimaster SPI system, all SCK pins are tied together, all MOSI pins are tied
together and all MISO pins are tied together. All SPI pins must then be configured in
OPEN-DRAIN Mode to prevent bus contention. At any one time, only one SPI device is
configured as the Master and all other SPI devices on the bus are configured as Slaves.
The Master enables a single Slave by asserting the SS pin on that Slave only. Then, the
single Master drives data out its SCK and MOSI pins to the SCK and MOSI pins on the
Slaves (including those which are not enabled). The enabled Slave drives data out its
MISO pin to the MISO Master pin.
For a Master device operating in a multimaster system, if the SS pin is configured as an
input and is driven Low by another Master, the COL bit is set to 1 in the SPI Status Regis-
ter. The COL bit indicates the occurrence of a multimaster collision (mode fault error con-
dition).
107
Slave Operation
The SPI block is configured for SLAVE Mode operation by setting the SPIEN bit to 1 and
the MMEN bit to 0 in the SPICTL Register and setting the SSIO bit to 0 in the SPIMODE
Register. The IRQE, PHASE, CLKPOL, and WOR bits in the SPICTL Register and the
NUMBITS field in the SPIMODE Register must be set to be consistent with the other SPI
devices. The STR bit in the SPICTL Register can be used, if appropriate, to force a start-
up interrupt. The BIRQ bit in the SPICTL Register and the SSV bit in the SPIMODE Reg-
ister is not used in SLAVE Mode. The SPI Baud Rate Generator is not used in SLAVE
Mode; therefore, the SPIBRH and SPIBRL registers are not required to be initialized.
If the slave has data to send to the master, the data must be written to the SPIDAT Register
before the transaction starts (first edge of SCK when SS is asserted). If the SPIDAT Regis-
ter is not written prior to the slave transaction, the MISO pin outputs whatever value is
currently in the SPIDAT Register.
Due to the delay resulting from synchronization of the SPI input signals to the internal sys-
tem clock, the maximum SPICLK baud rate that can be supported in SLAVE Mode is the
system clock frequency (XIN) divided by 8. This rate is controlled by the SPI Master.
Error Detection
The SPI contains error detection logic to support SPI communication protocols and recog-
nize when communication errors have occurred. The SPI Status Register indicates when a
data transmission error has been detected.
108
SPI Interrupts
When SPI interrupts are enabled, the SPI generates an interrupt after character transmis-
sion/reception completes in both Master and Slave modes. A character is defined to be 1
through 8 bits by the NUMBITS field in the SPI Mode Register. In SLAVE Mode it is not
necessary for SS to deassert between characters to generate the interrupt. The SPI in
SLAVE Mode also generates an interrupt if the SS signal deasserts prior to transfer of all
of the bits in a character (see the previous paragraph). Writing a 1 to the IRQ bit in the SPI
Status Register clears the pending SPI interrupt request. The IRQ bit must be cleared to 0
by the ISR to generate future interrupts. To start the transfer process, an SPI interrupt can
be forced by software writing a 1 to the STR bit in the SPICTL Register.
If the SPI is disabled, an SPI interrupt can be generated by a BRG time-out. This timer
function must be enabled by setting the BIRQ bit in the SPICTL Register. This BRG time-
out does not set the IRQ bit in the SPISTAT Register, just the SPI interrupt bit in the inter-
rupt controller.
The minimum baud rate is obtained by setting BRG[15:0] to 0000H for a clock divisor
value of (2 x 65536 = 131072).
When the SPI is disabled, BRG functions as a basic 16-bit timer with interrupt upon time-
out. Observe the following procedure to configure BRG as a timer with interrupt upon
time-out:
1. Disable the SPI by clearing the SPIEN bit in the SPI Control Register to 0.
2. Load the appropriate 16-bit count value into the SPI Baud Rate High and Low Byte
registers.
3. Enable BRG timer function and associated interrupt by setting the BIRQ bit in the SPI
Control Register to 1.
When configured as a general-purpose timer, the interrupt interval is calculated using the
following equation:
Interrupt Interval (s) = System Clock Period (s) ×BRG[15:0] ]
109
Bit 7 6 5 4 3 2 1 0
Field DATA
RESET X
R/W R/W
Address F60H
Bit Description
[7:0] SPI Data
DATA Transmit and/or receive data.
110
Bit 7 6 5 4 3 2 1 0
Field IRQE STR BIRQ PHASE CLKPOL WOR MMEN SPIEN
RESET 0
R/W R/W
Address F61H
Bit Description
[7] Interrupt Request Enable
IRQE 0 = SPI interrupts are disabled. No interrupt requests are sent to the Interrupt Controller.
1 = SPI interrupts are enabled. Interrupt requests are sent to the Interrupt Controller.
[6] Start an SPI Interrupt Request
STR 0 = No effect.
1 = Setting this bit to 1 also sets the IRQ bit in the SPI Status Register to 1. Setting this bit
forces the SPI to send an interrupt request to the Interrupt Control. This bit can be used by
software for a function similar to transmit buffer empty in a UART. Writing a 1 to the IRQ bit
in the SPI Status Register clears this bit to 0.
[5] BRG Timer Interrupt Request
BIRQ If the SPI is enabled, this bit has no effect. If the SPI is disabled:
0 = BRG timer function is disabled.
1 = BRG timer function and time-out interrupt are enabled.
[4] Phase Select
PHASE Sets the phase relationship of the data to the clock. For more information about operation of
the PHASE bit, see the SPI Clock Phase and Polarity Control section on page 104.
[3] Clock Polarity
CLKPOL 0 = SCK idles Low (0).
1 = SCK idle High (1).
[2] Wire-OR (Open-Drain) Mode Enabled
WOR 0 = SPI signal pins not configured for open-drain.
1 = All four SPI signal pins (SCK, SS, MISO, MOSI) configured for open-drain function. This
setting is typically used for multimaster and/or multislave configurations.
[1] SPI MASTER Mode Enable
MMEN 0 = SPI configured in SLAVE Mode.
1 = SPI configured in MASTER Mode.
[0] SPI Enable
SPIEN 0 = SPI disabled.
1 = SPI enabled.
111
Bit 7 6 5 4 3 2 1 0
Field IRQ OVR COL ABT Reserved TXST SLAS
RESET 0 1
R/W R/W* R
Address F62H
Note: *R/W = read access; write a 1 to clear the bit to 0.
Bit Description
[7] Interrupt Request
IRQ If SPIEN = 1, this bit is set if the STR bit in the SPICTL Register is set, or upon completion of
an SPI Master or Slave transaction. This bit does not set if SPIEN = 0 and the SPI Baud Rate
Generator is used as a timer to generate the SPI interrupt.
0 = No SPI interrupt request pending.
1 = SPI interrupt request is pending.
[6] Overrun
OVR 0 = An overrun error has not occurred.
1 = An overrun error has been detected.
[5] Collision
COL 0 = A multimaster collision (mode fault) has not occurred.
1 = A multimaster collision (mode fault) has been detected.
[4] SLAVE Mode Transaction Abort
ABT This bit is set if the SPI is configured in SLAVE Mode, a transaction is occurring and SS deas-
serts before all bits of a character have been transferred as defined by the NUMBITS field of
the SPIMODE Register. The IRQ bit also sets, indicating the transaction has completed.
0 = A SLAVE Mode transaction abort has not occurred.
1 = A SLAVE Mode transaction abort has been detected.
[3:2] Reserved
These bits are reserved and must be programmed to 00.
[1] Transmit Status
TXST 0 = No data transmission currently in progress.
1 = Data transmission currently in progress.
[0] Slave Select
SLAS If SPI is enabled as a Slave, then the following bit settings are true:
0 = SS input pin is asserted (Low)
1 = SS input is not asserted (High).
If SPI is enabled as a Master, this bit is not applicable.
112
Bit 7 6 5 4 3 2 1 0
Field Reserved DIAG NUMBITS[2:0] SSIO SSV
RESET 0
R/W R R/W
Address F63H
Bit Description
[7:6] Reserved
These bits are reserved and must be programmed to 00.
[5] Diagnostic Mode Control Bit
DIAG This bit is for SPI diagnostics. Setting this bit allows the BRG value to be read using the
SPIBRH and SPIBRL Register locations.
0 = Reading SPIBRH, SPIBRL returns the value in the SPIBRH and SPIBRL registers
1 = Reading SPIBRH returns bits [15:8] of the SPI Baud Rate Generator; and reading
SPIBRL returns bits [7:0] of the SPI Baud Rate Counter. The Baud Rate Counter High
and Low byte values are not buffered.
Caution: Be careful when reading these values while the BRG is counting, because the
read may interfere with the operation of the BRG counter.
[4:2] Number of Data Bits Per Character to Transfer
NUMBITS[2:0] This field contains the number of bits to shift for each character transfer. See the the SPI
Data Register section on page 109 for information about valid bit positions when the
character length is less than 8 bits.
000 = 8 bits.
001 = 1 bit.
010 = 2 bits.
011 = 3 bits.
100 = 4 bits.
101 = 5 bits.
110 = 6 bits.
111 = 7 bits.
113
Bit 7 6 5 4 3 2 1 0
Field SCKEN TCKEN SPISTATE
RESET 0
R/W R
Address F64H
Bit Description
[7] Shift Clock Enable
SCKEN 0 = The internal Shift Clock Enable signal is deasserted.
1 = The internal Shift Clock Enable signal is asserted (shift register is updated upon the next
system clock).
[6] Transmit Clock Enable
TCKEN 0 = The internal Transmit Clock Enable signal is deasserted.
1 = The internal Transmit Clock Enable signal is asserted. When this signal is asserted, the
serial data output is updated upon the next system clock (MOSI or MISO).
[5:0] SPI State Machine
SPISTATE Defines the current state of the internal SPI State Machine.
114
Bit 7 6 5 4 3 2 1 0
Field BRH
RESET 1
R/W R/W
Address F66H
Bit Description
[7:0] SPI Baud Rate High Byte
BRH Most significant byte, BRG[15:8], of the SPI Baud Rate Generator’s reload value.
Bit 7 6 5 4 3 2 1 0
Field BRL
RESET 1
R/W R/W
Address F67H
Bit Description
[7:0] SPI Baud Rate Low Byte
BRL Least significant byte, BRG[7:0], of the SPI Baud Rate Generator’s reload value.
115
I2C Controller
The I2C Controller makes the F0822 Series products bus-compatible with the I2C proto-
col. The I2C Controller consists of two bidirectional bus lines: a serial data signal (SDA)
and a serial clock signal (SCL). Features of the I2C Controller include:
• Transmit and Receive Operation in MASTER Mode
• Maximum data rate of 400 kbit/s
• 7-bit and 10-bit addressing modes for Slaves
• Unrestricted number of data bytes transmitted per transfer
The I2C Controller in the F0822 Series products does not operate in SLAVE Mode.
Architecture
Figure 25 displays the architecture of the I2C Controller.
116
SDA
SCL
Shift
ISHIFT
Load
I2CDATA
Baud Rate Generator
I2CBRH Receive
I2CBRL
I2CCTL I2CSTAT
Register Bus
I2C Interrupt
Operation
The I2C Controller operates in MASTER Mode to transmit and receive data. Only a single
master is supported. Arbitration between two masters must be accomplished in software.
I2C supports the following operations:
• Master transmits to a 7-bit slave
• Master transmits to a 10-bit slave
• Master receives from a 7-bit slave
• Master receives from a 10-bit slave
117
I2C Interrupts
The I2C Controller contains four sources of interrupts: Transmit, Receive, Not Acknowl-
edge and Baud Rate Generator. These four interrupt sources are combined into a single
interrupt request signal to the interrupt controller. The transmit interrupt is enabled by the
IEN and TXI bits of the control register. The Receive and Not Acknowledge interrupts are
enabled by the IEN bit of the control register. BRG interrupt is enabled by the BIRQ and
IEN bits of the control register.
Not Acknowledge interrupts occur when a Not Acknowledge condition is received from
the slave or sent by the I2C Controller and neither the start or stop bit is set. The Not
Acknowledge event sets the NCKI bit of the I2C Status Register and can only be cleared
by setting the start or stop bit in the I2C Control Register. When this interrupt occurs, the
I2C Controller waits until either the stop or start bit is set before performing any action. In
an ISR, the NCKI bit should always be checked prior to servicing transmit or receive
interrupt conditions because it indicates the transaction is being terminated.
Receive interrupts occur when a byte of data has been received by the I2C Controller
(Master reading data from Slave). This procedure sets the RDRF bit of the I2C Status Reg-
ister. The RDRF bit is cleared by reading the I2C Data Register. The RDRF bit is set dur-
ing the acknowledge phase. The I2C Controller pauses after the acknowledge phase until
the receive interrupt is cleared before performing any other action.
Transmit interrupts occur when the TDRE bit of the I2C Status Register sets and the TXI
bit in the I2C Control Register is set. Transmit interrupts occur under the following condi-
tions when the Transmit Data Register is empty:
• The I2C Controller is enabled
118
• The first bit of the byte of an address is shifting out and the RD bit of the I2C Status
Register is deasserted
• The first bit of a 10-bit address shifts out
• The first bit of write data shifts out
Note: Writing to the I2C Data Register always clears the TRDE bit to 0. When TDRE is asserted,
the I2C Controller pauses at the beginning of the Acknowledge cycle of the byte currently
shifting out until the data register is written with the next value to send or the stop or start
bits are set indicating the current byte is the last one to send.
The fourth interrupt source is the BRG. If the I2C Controller is disabled (IEN bit in the
I2CCTL Register = 0) and the BIRQ bit in the I2CCTL Register = 1, an interrupt is gener-
ated when the BRG counts down to 1. This allows the I2C Baud Rate Generator to be used
by software as a general purpose timer when IEN = 0.
Caution: A transmit (write) DMA operation hangs if the slave responds with a Not Acknowledge
before the last byte has been sent. After receiving the Not Acknowledge, the I2C Control-
ler sets the NCKI bit in the Status Register and pauses until either the stop or start bits in
the Control Register are set.
For a receive (read) DMA transaction to send a Not Acknowledge on the last byte, the
receive DMA must be set up to receive n–1 bytes, then software must set the NAK bit
and receive the last (nth) byte directly.
119
Note: The start condition is not sent until the start bit is set and data has been written to the I2C
Data Register.
Caution: Caution should be used in using the ACK status bit within a transaction because it is dif-
ficult for software to tell when it is updated by hardware.
When writing data to a slave, the I2C pauses at the beginning of the Acknowledge cycle if
the data register has not been written with the next value to be sent (TDRE bit in the I2C
Status Register equal to 1). In this scenario where software is not keeping up with the I2C
bus (TDRE asserted longer than one byte time), the Acknowledge clock cycle for byte n is
delayed until the data register is written with byte n+1, and appears to be grouped with the
data clock cycles for byte n+1. If either the start or stop bit is set, the I2C does not pause
prior to the Acknowledge cycle because no additional data is sent.
When a Not Acknowledge condition is received during a write (either during the address
or data phases), the I2C Controller generates the Not Acknowledge interrupt (NCKI = 1)
and pause until either the stop or start bit is set. Unless the Not Acknowledge was received
on the last byte, the data register will already have been written with the next address or
data byte to send. In this case the FLUSH bit of the control register should be set at the
same time the stop or start bit is set to remove the stale transmit data and enable subse-
quent transmit interrupts.
120
When reading data from the slave, the I2C pauses after the data Acknowledge cycle until
the receive interrupt is serviced and the RDRF bit of the status register is cleared by read-
ing the I2C Data Register. After the I2C Data Register has been read, the I2C reads the next
data byte.
121
The NCKI interrupt does not occur in the not acknowledge case because the stop bit
was set.
Observe the following procedure for a transmit operation to a 7-bit addressed slave:
1. Software asserts the IEN bit in the I2C Control Register.
2. Software asserts the TXI bit of the I2C Control Register to enable transmit interrupts.
3. The I2C interrupt asserts, because the I2C Data Register is empty.
4. Software responds to the TDRE bit by writing a 7-bit Slave address plus write bit (= 0)
to the I2C Data Register.
5. Software asserts the start bit of the I2C Control Register.
6. The I2C Controller sends the start condition to the I2C Slave.
7. The I2C Controller loads the I2C Shift Register with the contents of the I2C Data Reg-
ister.
8. After one bit of address has been shifted out by the SDA signal, the transmit interrupt
is asserted (TDRE = 1).
9. Software responds by writing the transmit data into the I2C Data Register.
10. The I2C Controller shifts the rest of the address and write bit out by the SDA signal.
11. If the I2C Slave sends an acknowledge (by pulling the SDA signal Low) during the
next High period of SCL the I2C Controller sets the ACK bit in the I2C Status Regis-
ter. Continue to Step 12.
If the slave does not acknowledge, the Not Acknowledge interrupt occurs (NCKI bit is
set in the Status Register, ACK bit is cleared). Software responds to the Not Acknowl-
edge interrupt by setting the stop and flush bits and clearing the TXI bit. The I2C Con-
troller sends the stop condition on the bus and clears the stop and NCKI bits. The
transaction is complete; ignore the remaining steps in this sequence.
122
12. The I2C Controller loads the contents of the I2C Shift Register with the contents of the
I2C Data Register.
13. The I2C Controller shifts the data out of using the SDA signal. After the first bit is
sent, the transmit interrupt is asserted.
14. If more bytes remain to be sent, return to Step 9.
15. Software responds by setting the stop bit of the I2C Control Register (or start bit to ini-
tiate a new transaction). In the STOP case, software clears the TXI bit of the I2C Con-
trol Register at the same time.
16. The I2C Controller completes transmission of the data on the SDA signal.
17. The slave can either Acknowledge or Not Acknowledge the last byte. Because either
the stop or start bit is already set, the NCKI interrupt does not occur.
18. The I2C Controller sends the stop (or restart) condition to the I2C bus. The stop or start
bit is cleared.
123
6. The I2C Controller sends the start condition to the I2C Slave.
7. The I2C Controller loads the I2C Shift Register with the contents of the I2C Data Reg-
ister.
8. After one bit of an address is shifted out by the SDA signal, the transmit interrupt is
asserted.
9. Software responds by writing the second byte of the address into the contents of the
I2C Data Register.
10. The I2C Controller shifts the rest of the first byte of address and write bit out the SDA
signal.
11. If the I2C Slave sends an acknowledge by pulling the SDA signal Low during the next
High period of SCL and the I2C Controller sets the ACK bit in the I2C Status Register,
continue to Step 12.
If the slave does not acknowledge the first address byte, the I2C Controller sets the
NCKI bit and clears the ACK bit in the I2C Status Register. Software responds to the
Not Acknowledge interrupt by setting the stop and flush bits and clearing the TXI bit.
The I2C Controller sends the stop condition on the bus and clears the stop and NCKI
bits. The transaction is complete; ignore the remaining steps in this sequence.
12. The I2C Controller loads the I2C Shift Register with the contents of the I2C Data Reg-
ister (2nd byte of address).
13. The I2C Controller shifts the second address byte out the SDA signal. After the first
bit has been sent, the transmit interrupt is asserted.
14. Software responds by setting the stop bit in the I2C Control Register. The TXI bit can
be cleared at the same time.
15. Software polls the stop bit of the I2C Control Register. Hardware deasserts the stop bit
when the transaction is completed (stop condition has been sent).
16. Software checks the ACK bit of the I2C Status Register. If the slave acknowledged,
the ACK bit is equal to 1. If the slave does not acknowledge, the ACK bit is equal to 0.
The NCKI interrupt do not occur because the stop bit was set.
124
The first seven bits transmitted in the first byte are 11110XX. The two XX bits are the two
most-significant bits of the 10-bit address. The lowest bit of the first byte transferred is the
read/write control bit (= 0). The transmit operation is carried out in the same manner as 7-
bit addressing.
Observe the following procedure for a transmit operation on a 10-bit addressed slave:
1. Software asserts the IEN bit in the I2C Control Register.
2. Software asserts the TXI bit of the I2C Control Register to enable transmit interrupts.
3. The I2C interrupt asserts because the I2C Data Register is empty.
4. Software responds to the TDRE interrupt by writing the first slave address byte to the
I2C Data Register. The least-significant bit must be 0 for the write operation.
5. Software asserts the start bit of the I2C Control Register.
6. The I2C Controller sends the start condition to the I2C Slave.
7. The I2C Controller loads the I2C Shift Register with the contents of the I2C Data Reg-
ister.
8. After one bit of address is shifted out by the SDA signal, the transmit interrupt is
asserted.
9. Software responds by writing the second byte of address into the contents of the I2C
Data Register.
10. The I2C Controller shifts the rest of the first byte of address and write bit out the SDA
signal.
11. If the I2C Slave acknowledges the first address byte by pulling the SDA signal Low
during the next High period of SCL, the I2C Controller sets the ACK bit in the I2C
Status Register. Continue to Step 12.
If the slave does not acknowledge the first address byte, the I2C Controller sets the
NCKI bit and clears the ACK bit in the I2C Status Register. Software responds to the
Not Acknowledge interrupt by setting the stop and flush bits and clearing the TXI bit.
The I2C Controller sends the stop condition on the bus and clears the stop and NCKI
bits. The transaction is complete; ignore the remainder of this sequence.
12. The I2C Controller loads the I2C Shift Register with the contents of the I2C Data Reg-
ister.
13. The I2C Controller shifts the second address byte out the SDA signal. After the first
bit has been sent, the transmit interrupt is asserted.
14. Software responds by writing a data byte to the I2C Data Register.
15. The I2C Controller completes shifting the contents of the shift register on the SDA
signal.
125
16. If the I2C Slave sends an acknowledge by pulling the SDA signal Low during the next
High period of SCL, the I2C Controller sets the ACK bit in the I2C Status Register.
Continue to Step 17.
If the slave does not acknowledge the second address byte or one of the data bytes, the
I2C Controller sets the NCKI bit and clears the ACK bit in the I2C Status Register.
Software responds to the Not Acknowledge interrupt by setting the stop and flush bits
and clearing the TXI bit. The I2C Controller sends the stop condition on the bus and
clears the stop and NCKI bits. The transaction is complete; ignore the remainder of
this sequence.
17. The I2C Controller shifts the data out by the SDA signal. After the first bit is sent, the
transmit interrupt is asserted.
18. If more bytes remain to be sent, return to Step 14.
19. If the last byte is currently being sent, software sets the stop bit of the I2C Control
Register (or start bit to initiate a new transaction). In the stop case, software simulta-
neously clears the TXI bit of the I2C Control Register.
20. The I2C Controller completes transmission of the last data byte on the SDA signal.
21. The slave can either Acknowledge or Not Acknowledge the last byte. Because either
the stop or start bit is already set, the NCKI interrupt does not occur.
22. The I2C Controller sends the stop (or restart) condition to the I2C bus and clears the
stop (or start) bit.
Figure 30. Receive Data Transfer Format for a 7-Bit Addressed Slave
Observe the following procedure for a read operation to a 7-bit addressed slave:
1. Software writes the I2C Data Register with a 7-bit Slave address plus the read bit (= 1).
2. Software asserts the start bit of the I2C Control Register.
3. If this transfer is a single byte transfer, Software asserts the NAK bit of the I2C Con-
trol Register so that after the first byte of data has been read by the I2C Controller, a
Not Acknowledge is sent to the I2C Slave.
4. The I2C Controller sends the start condition.
126
5. The I2C Controller shifts the address and read bit out the SDA signal.
6. If the I2C Slave acknowledges the address by pulling the SDA signal Low during the
next High period of SCL, the I2C Controller sets the ACK bit in the I2C Status Regis-
ter. Continue to Step 7.
If the slave does not acknowledge, the Not Acknowledge interrupt occurs (NCKI bit is
set in the Status Register, ACK bit is cleared). Software responds to the Not Acknowl-
edge interrupt by setting the stop bit and clearing the TXI bit. The I2C Controller
sends the stop condition on the bus and clears the stop and NCKI bits. The transaction
is complete; ignore the remainder of this sequence.
7. The I2C Controller shifts in the byte of data from the I2C Slave on the SDA signal.
The I2C Controller sends a Not Acknowledge to the I2C Slave if the NAK bit is set
(last byte), else it sends an Acknowledge.
8. The I2C Controller asserts the Receive interrupt (RDRF bit set in the Status Register).
9. Software responds by reading the I2C Data Register which clears the RDRF bit. If
there is only one more byte to receive, set the NAK bit of the I2C Control Register.
10. If there are more bytes to transfer, return to Step 7.
11. After the last byte is shifted in, a Not Acknowledge interrupt is generated by the I2C
Controller.
12. Software responds by setting the stop bit of the I2C Control Register.
13. A stop condition is sent to the I2C Slave, the stop and NCKI bits are cleared.
S Slave Address W=0 A Slave Address A S Slave Address R=1 A Data A Data A P
1st 7 bits 2nd Byte 1st 7 bits
Figure 31. Receive Data Format for a 10-Bit Addressed Slave
The first seven bits transmitted in the first byte are 11110XX. The two XX bits are the two
most significant bits of the 10-bit address. The lowest bit of the first byte transferred is the
write control bit.
Observe the following procedure for the data transfer procedure for a read operation to a
10-bit addressed slave:
127
1. Software writes 11110B followed by the two address bits and a 0 (write) to the I2C
Data Register.
2. Software asserts the start and TXI bits of the I2C Control Register.
3. The I2C Controller sends the start condition.
4. The I2C Controller loads the I2C Shift Register with the contents of the I2C Data Reg-
ister.
5. After the first bit has been shifted out, a transmit interrupt is asserted.
6. Software responds by writing the lower eight bits of address to the I2C Data Register.
7. The I2C Controller completes shifting of the two address bits and a 0 (write).
8. If the I2C Slave acknowledges the first address byte by pulling the SDA signal Low
during the next High period of SCL, the I2C Controller sets the ACK bit in the I2C
Status Register. Continue to Step 9.
If the slave does not acknowledge the first address byte, the I2C Controller sets the
NCKI bit and clears the ACK bit in the I2C Status Register. Software responds to the
Not Acknowledge interrupt by setting the stop and flush bits and clearing the TXI bit.
The I2C Controller sends the stop condition on the bus and clears the stop and NCKI
bits. The transaction is complete (ignore following steps).
9. The I2C Controller loads the I2C Shift Register with the contents of the I2C Data Reg-
ister (second address byte).
10. The I2C Controller shifts out the second address byte. After the first bit is shifted, the
I2C Controller generates a transmit interrupt.
11. Software responds by setting the start bit of the I2C Control Register to generate a
repeated start and by clearing the TXI bit.
12. Software responds by writing 11110B followed by the 2-bit Slave address and a 1
(read) to the I2C Data Register.
13. If only one byte is to be read, software sets the NAK bit of the I2C Control Register.
14. After the I2C Controller shifts out the 2nd address byte, the I2C Slave sends an
acknowledge by pulling the SDA signal Low during the next High period of SCL, the
I2C Controller sets the ACK bit in the I2C Status Register. Continue to Step 15.
If the slave does not acknowledge the second address byte, the I2C Controller sets the
NCKI bit and clears the ACK bit in the I2C Status Register. Software responds to the
Not Acknowledge interrupt by setting the stop and flush bits and clearing the TXI bit.
The I2C Controller sends the stop condition on the bus and clears the stop and NCKI
bits. The transaction is complete; ignore the remainder of this sequence.
15. The I2C Controller sends the repeated start condition.
128
16. The I2C Controller loads the I2C Shift Register with the contents of the I2C Data Reg-
ister (third address transfer).
17. The I2C Controller sends 11110B followed by the two most significant bits of the
slave read address and a 1 (read).
18. The I2C Slave sends an acknowledge by pulling the SDA signal Low during the next
High period of SCL.
If the slave were to Not Acknowledge at this point (this should not happen because the
slave did acknowledge the first two address bytes), software would respond by setting
the stop and flush bits and clearing the TXI bit. The I2C Controller sends the stop con-
dition on the bus and clears the stop and NCKI bits. The transaction is complete;
ignore the remainder of this sequence.
19. The I2C Controller shifts in a byte of data from the I2C Slave on the SDA signal. The
I2C Controller sends a Not Acknowledge to the I2C Slave if the NAK bit is set (last
byte), else it sends an Acknowledge.
20. The I2C Controller asserts the Receive interrupt (RDRF bit set in the Status Register).
21. Software responds by reading the I2C Data Register which clears the RDRF bit. If
there is only one more byte to receive, set the NAK bit of the I2C Control Register.
22. If there are one or more bytes to transfer, return to Step 19.
23. After the last byte is shifted in, a Not Acknowledge interrupt is generated by the I2C
Controller.
24. Software responds by setting the stop bit of the I2C Control Register.
25. A stop condition is sent to the I2C Slave and the stop and NCKI bits are cleared.
129
Bit 7 6 5 4 3 2 1 0
Field DATA
RESET 0
R/W R/W
Address F50H
Bit 7 6 5 4 3 2 1 0
Field TDRE RDRF ACK 10B RD TAS DSS NCKI
RESET 1 0
R/W R
Address F51H
Bit Description
[7] Transmit Data Register Empty
TDRE When the I2C Controller is enabled, this bit is 1 when the I2C Data Register is empty. When this
bit is set, an interrupt is generated if the TXI bit is set, except when the I2C Controller is shifting
in data during the reception of a byte or when shifting an address and the RD bit is set. This bit
is cleared by writing to the I2CDATA Register.
[6] Receive Data Register Full
RDRF This bit is set = 1 when the I2C Controller is enabled and the I2C Controller has received a byte
of data. When asserted, this bit causes the I2C Controller to generate an interrupt. This bit is
cleared by reading the I2C Data Register (unless the read is performed using execution of the
OCD’s Read Register command).
130
Caution: When making decisions based on this bit within a transaction, software cannot deter-
mine when the bit is updated by hardware. In the case of write transactions, the I2C pauses at
the beginning of the Acknowledge cycle if the next transmit data or address byte has not been
written (TDRE = 1) and STOP and start = 0. In this case the ACK bit is not updated until the
transmit interrupt is serviced and the Acknowledge cycle for the previous byte completes. For
examples on usage of the ACK bit, see the Address Only Transaction with a 7-Bit Address sec-
tion on page 120 and the Address-Only Transaction with a 10-Bit Address section on
page 122.
[4] 10-Bit Address
10B This bit indicates whether a 10-bit or 7-bit address is being transmitted. After the start bit is set,
if the five most-significant bits of the address are 11110B, this bit is set. When set, it is reset
after the first byte of the address has been sent.
[3] Read
RD This bit indicates the direction of transfer of the data. It is active High during a read. The status of
this bit is determined by the least-significant bit of the I2C Shift Register after the start bit is set.
[2] Transmit Address State
TAS This bit is active High while the address is being shifted out of the I2C Shift Register.
[1] Data Shift State
DSS This bit is active High while data is being shifted to or from the I2C Shift Register.
[0] NACK Interrupt
NCKI This bit is set High when a Not Acknowledge condition is received or sent and neither the start
nor the stop bit is active. When set, this bit generates an interrupt that can only be cleared by
setting the start or stop bit, allowing you to specify whether you want to perform a stop or a
repeated start.
131
Bit 7 6 5 4 3 2 1 0
Field IEN START STOP BIRQ TXI NAK FLUSH FILTEN
RESET 0
R/W R/W R/W R/W R/W R/W R/W W R/W
Address F52H
Bit Description
[7] I2C Enable
IEN 1 = The I2C transmitter and receiver are enabled.
0 = The I2C transmitter and receiver are disabled.
[6] Send Start Condition
START This bit sends the start condition. After it is asserted, it is cleared by the I2C Controller after it
sends the START condition or if the IEN bit is deasserted. If this bit is 1, it cannot be cleared to
0 by writing to the register. After this bit is set, the Start condition is sent if there is data in the I2C
Data or I2C Shift Register. If there is no data in one of these registers, the I2C Controller waits
until the data register is written. If this bit is set while the I2C Controller is shifting out data, it
generates a start condition after the byte shifts and the acknowledge phase completes. If the
stop bit is also set, it also waits until the stop condition is sent before sending the start condition.
[5] Send Stop Condition
STOP This bit causes the I2C Controller to issue a stop condition after the byte in the I2C Shift Regis-
ter has completed transmission or after a byte is received in a receive operation. After it is set,
this bit is reset by the I2C Controller after a stop condition is sent or by deasserting the IEN bit.
If this bit is 1, it cannot be cleared to 0 by writing to the register.
[4] Baud Rate Generator Interrupt Request
BIRQ This bit allows the I2C Controller to be used as an additional timer when the I2C Controller is
disabled. This bit is ignored when the I2C Controller is enabled.
1 = An interrupt occurs every time the BRG counts down to 1.
0 = No BRG interrupt occurs.
[3] Enable TDRE interrupts
TXI This bit enables the transmit interrupt when the I2C Data Register is empty (TDRE = 1).
1 = transmit interrupt (and DMA transmit request) is enabled.
0 = transmit interrupt (and DMA transmit request) is disabled.
[2] Send NAK
NAK This bit sends a Not Acknowledge condition after the next byte of data is read from the I2C
Slave. After it is asserted, it is deasserted after a Not Acknowledge is sent or the IEN bit is
deasserted. If this bit is 1, it cannot be cleared to 0 by writing to the register.
132
Bit 7 6 5 4 3 2 1 0
Field BRH
RESET FFH
R/W R/W
Address F53H
Bit Description
[7:0] I2C Baud Rate High Byte
BRH Most significant byte, BRG[15:8], of the I2C Baud Rate Generator’s reload value.
Note: If the DIAG bit in the I2C Diagnostic Control Register is set to 1, a read of the I2CBRH
Register returns the current value of the I2C Baud Rate Counter[15:8].
133
Bit 7 6 5 4 3 2 1 0
Field BRL
RESET FFH
R/W R/W
Address F54H
Bit Description
[7:0] I2C Baud Rate Low Byte
BRL Least significant byte, BRG[7:0], of the I2C Baud Rate Generator’s reload value.
Note: If the DIAG bit in the I2C Diagnostic Control Register is set to 1, a read of the I2CBRL
Register returns the current value of the I2C Baud Rate Counter [7:0].
Bit 7 6 5 4 3 2 1 0
Field SCLIN SDAIN STPCNT TXRXSTATE
RESET X 0
R/W R
Address F55H
Bit Description
[7] Serial Clock Input
SCLIN Value of the Serial Clock input signal.
[6] Serial Data Input
SDAIN Value of the Serial Data input signal.
[5] Stop Count
STPCNT Value of the internal Stop Count control signal.
134
135
Bit 7 6 5 4 3 2 1 0
Field Reserved DIAG
RESET 0
R/W R R/W
Address F56H
Bit Description
[7:1] Reserved
These bits are reserved and must be programmed to 0000000.
[0] Diagnostic Control Bit
DIAG Selects the read-back value of the Baud Rate Reload registers.
0 = Normal Mode. Reading the Baud Rate High and Low Byte registers returns the baud rate
reload value.
1 = Diagnostic Mode. Reading the Baud Rate High and Low Byte registers returns the baud
rate counter value.
136
Analog-to-Digital Converter
The Analog-to-Digital Converter (ADC) converts an analog input signal to a 10-bit binary
number. The features of the sigma-delta ADC include:
• Five analog input sources are multiplexed with GPIO ports
• Interrupt upon conversion complete
• Internal voltage reference generator
The ADC is available only in the Z8F0822, Z8F0821, Z8F0422, Z8F0421, Z8R0822,
Z8R0821, Z8R0422 and Z8R0421 devices.
Architecture
Figure 32 displays the three major functional blocks (converter, analog multiplexer and
voltage reference generator) of the ADC. The ADC converts an analog input signal to its
digital representation. The five-input analog multiplexer selects one of the five analog
input sources. The ADC requires an input reference voltage for the conversion. The volt-
age reference for the conversion can be input through the external VREF pin or generated
internally by the voltage reference generator.
137
Analog-to-Digital
Converter
Analog Input
IRQ Multiplexer
Reference Input
ANA0
ANA1
Analog Input ANA2
ANA3
ANA4
ANAIN[3:0]
Operation
This section describes the operational aspects of the ADC’s power-down and conversion
features.
Automatic Power-Down
If the ADC is idle (no conversions in progress) for 160 consecutive system clock cycles,
portions of the ADC are automatically powered down. From this powered-down state, the
ADC requires 40 system clock cycles to power up. The ADC powers up when a conver-
sion is requested via the ADC Control Register.
Single-Shot Conversion
When configured for single-shot conversion, the ADC performs a single analog-to-digital
conversion on the selected analog input channel. After completion of the conversion, the
ADC shuts down. Observe the following procedure for setting up the ADC and initiating a
single-shot conversion:
138
1. Enable the appropriate analog inputs by configuring the GPIO pins for alternate
function. This configuration disables the digital input and output drivers.
2. Write to the ADC Control Register to configure the ADC and begin the conversion.
The following bit fields in the ADC Control Register are written simultaneously:
– Write to the ANAIN[3:0] field to select one of the 5 analog input sources
– Clear CONT to 0 to select a single-shot conversion
– Write to the VREF bit to enable or disable the internal voltage reference generator
– Set CEN to 1 to start the conversion
5. If the ADC remains idle for 160 consecutive system clock cycles, it is automatically
powered-down.
Continuous Conversion
When configured for continuous conversion, the ADC continuously performs an
analog-to-digital conversion on the selected analog input. Each new data value over-writes
the previous value stored in the ADC Data registers. An interrupt is generated after each
conversion.
Caution: In CONTINUOUS Mode, ensure that ADC updates are limited by the input signal band-
width of the ADC and the latency of the ADC and its digital filter. Step changes at the
input are not seen at the next output from the ADC. The response of the ADC (in all
modes) is limited by the input signal bandwidth and the latency.
Observe the following procedure for setting up the ADC and initiating continuous conver-
sion:
1. Enable the appropriate analog input by configuring the GPIO pins for alternate
function. This disables the digital input and output driver.
139
2. Write to the ADC Control Register to configure the ADC for continuous conversion.
The bit fields in the ADC Control Register can be written simultaneously:
– Write to the ANAIN[3:0] field to select one of the 5 analog input sources.
– Set CONT to 1 to select continuous conversion.
– Write to the VREF bit to enable or disable the internal voltage reference generator.
– Set CEN to 1 to start the conversions.
3. When the first conversion in continuous operation is complete (after 5129 system
clock cycles, plus the 40 cycles for power-up, if necessary), the ADC control logic
performs the following operations:
– CEN resets to 0 to indicate the first conversion is complete. CEN remains 0 for all
subsequent conversions in continuous operation.
– An interrupt request is sent to the Interrupt Controller to indicate the conversion is
complete.
4. Thereafter, the ADC writes a new 10-bit data result to {ADCD_H[7:0],
ADCD_L[7:6]} every 256 system clock cycles. An interrupt request is sent to the
Interrupt Controller when each conversion is complete.
5. To disable continuous conversion, clear the CONT bit in the ADC Control Register to
0.
Bit 7 6 5 4 3 2 1 0
Field CEN Reserved VREF CONT ANAIN[3:0]
RESET 0 1 0
R/W R/W
Address F70H
140
Bit Description
[7] Conversion Enable
CEN 0 = Conversion is complete. Writing a 0 produces no effect. The ADC automatically clears
this bit to 0 when a conversion has been completed.
1 = Begin conversion. Writing a 1 to this bit starts a conversion. If a conversion is already in
progress, the conversion restarts. This bit remains 1 until the conversion is complete.
[6] Reserved
This bit is reserved and must be programmed to 0.
[5] Voltage Reference
VREF 0 = Internal reference generator enabled. The VREF pin must remain unconnected or capac-
itively coupled to analog ground (AVSS).
1 = Internal voltage reference generator disabled. An external voltage reference must be
provided through the VREF pin.
[4] Conversion
CONT 0 = SINGLE-SHOT conversion. ADC data is output one time at completion of the 5129 sys-
tem clock cycles.
1 = Continuous conversion. ADC data updated every 256 system clock cycles.
[3] Analog Input Select
ANAIN[3:0] These bits select the analog input for conversion. Not all Port pins in this list are available in
all packages for Z8 Encore! XP® F0822 Series. See the Signal and Pin Descriptions chapter
on page 7 for information regarding the port pins available with each package style.
Do not enable unavailable analog inputs.
0000 = ANA0.
0001 = ANA1.
0010 = ANA2.
0011 = ANA3.
0100 = ANA4.
0101 = Reserved.
011X = Reserved.
1XXX = Reserved.
141
Bit 7 6 5 4 3 2 1 0
Field ADCD_H
RESET X
R/W R
Address F72H
Bit Description
[7:0] ADC Data High Byte
ADCD_H This byte contains the upper eight bits of the 10-bit ADC output. These bits are not valid during
a single-shot conversion. During a continuous conversion, the last conversion output is held in
this register. These bits are undefined after a Reset.
142
Bit 7 6 5 4 3 2 1 0
Field ADCD_L Reserved
RESET X
R/W R
Address F73H
Bit Description
[7:6] ADC Data Low Bits
ADCD_L These are the least significant two bits of the 10-bit ADC output. These bits are undefined after
a Reset.
[5:0] Reserved
These bits are reserved and are always undefined.
143
Flash Memory
The products in the Z8 Encore! XP® F0822 Series feature either 8 KB (8192) or 4 KB
(4096) bytes of Flash memory with Read/Write/Erase capability. Flash memory is pro-
grammed and erased in-circuit by either user code or through the OCD.
The Flash memory array is arranged in 512-byte per page. The 512-byte page is the mini-
mum Flash block size that can be erased. Flash memory is divided into eight sectors which
is protected from programming and erase operations on a per sector basis.
Table 81 describes the Flash memory configuration for each device in the Z8F082xfamily.
Table 82 lists the sector address ranges. Figure 33 displays the Flash memory arrange-
ment.
Pages
Number Flash Memory Number of per
Part Number Flash Size of Pages Addresses Sector Size Sectors Sector
Z8F08xx 8 KB (8192) 16 0000H–1FFFH 1 KB (1024) 8 2
Z8F04xx 4 KB (4096) 8 0000H–0FFFH 0.5 KB (512) 8 1
144
8KB Flash
Program Memory
Addresses
1FFFH
1E00H
1DFFH
1C00H
1BFFH
1A00H
16 Pages
512 Bytes per Page
05FFH
0400H
03FFH
0200H
01FFH
0000H
Information Area
Table 83 describes the Z8 Encore! XP® F0822 Series Information Area. This 512-byte
Information Area is accessed by setting bit 7 of the Page Select Register to 1. When access
is enabled, the Information Area is mapped into Flash memory and overlays the 512 bytes
at addresses FE00H to FFFFH. When the Information Area access is enabled, LDC instruc-
tions return data from the Information Area. CPU instruction fetches always comes from
Flash memory regardless of the Information Area access bit. Access to the Information
Area is read-only.
145
Flash Memory
Address (Hex) Function
FE00H–FE3FH Reserved
FE40H–FE53H Part Number
20-character ASCII alphanumeric code
Left-justified and filled with zeros
FE54H–FFFFH Reserved
Operation
The Flash Controller provides the proper signals and timing for the Byte Programming,
Page Erase, and Mass Erase functions within Flash memory. The Flash Controller contains
a protection mechanism, using the Flash Control Register (FCTL), to prevent accidental
programming or erasure. The following subsections provide details about the various
operations (Lock, Unlock, Sector Protect, Byte Programming, Page Erase and Mass
Erase).
Caution: Flash programming and erasure are not supported for system clock frequencies below
20 kHz, above 20 MHz, or outside of the device operating frequency range. The Flash
Frequency High and Low Byte registers must be loaded with the correct value to ensure
proper Flash programming and erase operations.
146
147
Observe the following procedure to setup the Flash Sector Protect Register from user
code:
1. Write 00H to the Flash Control Register to reset the Flash Controller.
2. Write 5EH to the Flash Control Register to select the Flash Sector Protect Register.
3. Read and/or write the Flash Sector Protect Register which is now at Register File
address FF9H.
4. Write 00H to the Flash Control Register to return the Flash Controller to its reset state.
Byte Programming
When the Flash Controller is unlocked, writes to Flash memory from user code programs
a byte into the Flash if the address is located in the unlocked page. An erased Flash byte
contains all 1s (FFH). The programming operation is used to change bits from 1 to 0. To
change a Flash bit (or multiple bits) from zero to one requires a Page Erase or Mass Erase
operation.
Byte programming is accomplished using the eZ8 CPU’s LDC or LDCI instructions.
Refer to the eZ8 CPU Core User Manual (UM0128) for a description of the LDC and
LDCI instructions.
While the Flash Controller programs the contents of Flash memory, the eZ8 CPU idles but
the system clock and on-chip peripherals continue to operate. Interrupts that occur when a
programming operation is in progress are serviced after the programming operation is
complete. To exit programming mode and lock the Flash Controller, write 00H to the Flash
Control Register.
User code cannot program Flash memory on a page that is located in a protected sector.
When user code writes memory locations, only addresses located in the unlocked page are
programmed. Memory writes outside of the unlocked page are ignored.
Caution: Each memory location must not be programmed more than twice before an erase occurs.
Observe the following procedure to program the Flash from user code:
1. Write 00H to the Flash Control Register to reset the Flash Controller.
2. Write the page of memory to be programmed to the Page Select Register.
3. Write the first unlock command 73H to the Flash Control Register.
148
4. Write the second unlock command 8CH to the Flash Control Register.
5. Rewrite the page written in Step 2 to the Page Select Register.
6. Write Flash memory using LDC or LDCI instructions to program Flash memory.
7. Repeat Step 6 to program additional memory locations on the same page.
8. Write 00H to the Flash Control Register to lock the Flash Controller.
Page Erase
Flash memory can be erased one page (512 bytes) at a time. Page Erasing the Flash mem-
ory sets all bytes in that page to the value FFH. The Page Select Register identifies the
page to be erased. While the Flash Controller executes the Page Erase operation, the eZ8
CPU idles but the system clock and on-chip peripherals continue to operate. The eZ8 CPU
resumes operation after the Page Erase operation completes. Interrupts that occur when
the Page Erase operation is in progress are serviced after the Page Erase operation is com-
plete. When the Page Erase operation is complete, the Flash Controller returns to its
locked state. Only pages located in unprotected sectors can be erased.
Observe the following procedure to perform a Page Erase operation:
1. Write 00H to the Flash Control Register to reset the Flash Controller.
2. Write the page to be erased to the Page Select Register.
3. Write the first unlock command 73H to the Flash Control Register.
4. Write the second unlock command 8CH to the Flash Control Register.
5. Rewrite the page written in Step 2 to the Page Select Register.
6. Write the Page Erase command 95H to the Flash Control Register.
Mass Erase
Flash memory cannot be mass-erased by user code.
149
For more information about bypassing the Flash Controller, refer to the Third Party Flash
Programming Support for Z8 Encore! MCU Application Note (AN0117), available for
download at www.zilog.com.
150
Bit 7 6 5 4 3 2 1 0
Field FCMD
RESET 0
R/W W
Address FF8H
Bit Description
[7:0] Flash Command*
FCMD 73H = First unlock command.
8CH = Second unlock command.
95H = Page erase command.
63H = Mass erase command.
5EH = Flash Sector Protect Register select.
Note: *All other commands, or any command out of sequence, lock the Flash Controller.
151
Bit 7 6 5 4 3 2 1 0
Field Reserved FSTAT
RESET 0
R/W R
Address FF8H
Bit Description
[7:6] Reserved
These bits are reserved and must be programmed to 00.
[5:0] Flash Controller Status
FSTAT 00_0000 = Flash Controller locked.
00_0001 = First unlock command received.
00_0010 = Second unlock command received.
00_0011 = Flash Controller unlocked.
00_0100 = Flash Sector Protect Register selected.
00_1xxx = Program operation in progress.
01_0xxx = Page erase operation in progress.
10_0xxx = Mass erase operation in progress.
152
Bit 7 6 5 4 3 2 1 0
Field INFO_EN PAGE
RESET 0
R/W R/W
Address FF9H
Bit Description
[7] Information Area Enable
INFO_EN 0 = Information Area is not selected.
1 = Information Area is selected. The Information area is mapped into the Flash memory
address space at addresses FE00H through FFFFH.
[6:0] Page Select
PAGE This 7-bit field selects the Flash memory page for Programming and Page Erase operations.
Flash memory address[15:9] = PAGE[6:0].
153
Bit 7 6 5 4 3 2 1 0
Field SECT7 SECT6 SECT5 SECT4 SECT3 SECT2 SECT1 SECT0
RESET 0
R/W R/W*
Address FF9H
Note: *R/W = this register is accessible for read operations, but can only be written to 1 (via user code).
Bit Description
[7:0] Sector Protect
SECTn 0 = Sector n can be programmed or erased from user code.
1 = Sector n is protected and cannot be programmed or erased from user code. User code can
only write bits from 0 to 1.
Note: n indicates bits in the range [7:0].
Caution: Flash programming and erasure is not supported for system clock frequencies below
20 kHz, above 20 MHz, or outside of the valid operating frequency range for the device.
The Flash Frequency High and Low Byte registers must be loaded with the correct value
to ensure proper program and erase times.
154
Bit 7 6 5 4 3 2 1 0
Field FFREQH
RESET 0
R/W R/W
Address FFAH
Bit 7 6 5 4 3 2 1 0
Field FFREQL
RESET 0
R/W R/W
Address FFBH
Bit Description
[7:0] Flash Frequency High and Low Bytes
FFREQH, These 2 bytes, {FFREQH[7:0], FFREQL[7:0]}, contain the 16-bit Flash Frequency value.
FFREQL
155
Option Bits
Option bits allow user configuration of certain aspects of Z8 Encore! XP® F0822 Series
operation. The feature configuration data is stored in Flash memory and read during Reset.
Features available for control through the option bits are:
• Watchdog Timer time-out response selection–interrupt or Reset
• Watchdog Timer enabled at Reset
• The ability to prevent unwanted read access to user code in Flash memory
• The ability to prevent accidental programming and erasure of all or a portion of the user
code in Flash memory
• Voltage Brown-Out configuration is always enabled or disabled during STOP Mode to
reduce STOP Mode power consumption
• Oscillator Mode selection for high-, medium- and low-power crystal oscillators, or ex-
ternal RC oscillator
Operation
This section describes the type and configuration of the programmable Flash option bits.
156
Table 90. Option Bits at Flash Memory Address 0000H for 8K Series Flash Devices
Bit 7 6 5 4 3 2 1 0
Field WDT_RES WDT_AO OSC_SEL[1:0] VBO_AO RP Reserved FWP
RESET U
R/W R/W
Address Program Memory 0000H
Note: U = Unchanged by Reset; R/W = Read/Write.
Bit Description
[7] Watchdog Timer Reset
WDT_RES 0 = Watchdog Timer time-out generates an interrupt request. Interrupts must be globally
enabled for the eZ8 CPU to acknowledge the interrupt request.
1 = Watchdog Timer time-out causes a Reset. This setting is the default for unpro-
grammed (erased) Flash.
[6] Watchdog Timer Always On
WDT_AO 0 = Watchdog Timer is automatically enabled upon application of system power. Watch-
dog Timer can not be disabled.
1 = Watchdog Timer is enabled upon execution of the WDT instruction. After it is enabled,
the Watchdog Timer can only be disabled by a Reset or Stop Mode Recovery. This
setting is the default for unprogrammed (erased) Flash.
[5:4] OSCILLATOR Mode Selection
OSC_SEL[1:0] 00 = On-chip oscillator configured for use with external RC networks (<4 MHz).
01 = Minimum power for use with very-low-frequency crystals (32 kHz to 1.0 MHz).
10 = Medium power for use with medium frequency crystals or ceramic resonators
(0.5 MHz to 10.0 MHz).
11 = Maximum power for use with high-frequency crystals (8.0 MHz to 20.0 MHz). This
setting is the default for unprogrammed (erased) Flash.
[3] Voltage Brown-Out Protection Always On
VBO_AO 0 = Voltage Brown-Out Protection is disabled in STOP Mode to reduce total power con-
sumption.
1 = Voltage Brown-Out Protection is always enabled including during STOP Mode. This
setting is the default for unprogrammed (erased) Flash.
[2] Read Protect
RP 0 = User program code is inaccessible. Limited control features are available through the
OCD.
1 = User program code is accessible. All OCD commands are enabled. This setting is the
default for unprogrammed (erased) Flash.
Note: *Applies only to the Flash versions of the F0822 Series of devices.
157
Bit 7 6 5 4 3 2 1 0
Field Reserved
RESET U
R/W R/W
Address Program Memory 0001H
Note: U = Unchanged by Reset; R/W = Read/Write.
Bit Description
[7:0] Reserved
These option bits are reserved and must always be 1. This setting is the default for unpro-
grammed (erased) Flash.
158
On-Chip Debugger
Z8 Encore! XP® F0822 Series products have an integrated On-Chip Debugger (OCD) that
provides advanced debugging features, including:
• Reading and writing of the Register File
• Reading and (Flash version only) writing of Program and Data Memory
• Setting of breakpoints
• Executing eZ8 CPU instructions
Architecture
The OCD consists of four primary functional blocks: transmitter, receiver, autobaud gen-
erator, and debug controller. Figure 34 displays the architecture of the OCD.
Transmitter
Debug Controller
DBG Pin
Receiver
159
Operation
The following section describes the operation of the OCD.
OCD Interface
The OCD uses the DBG pin for communication with an external host. This one-pin inter-
face is a bidirectional open-drain interface that transmits and receives data. Data transmis-
sion is half-duplex, in that transmit and receive cannot occur simultaneously. The serial
data on the DBG pin is sent using the standard asynchronous data format defined in RS-
232. This pin can interface the Z8 Encore! XP® F0822 Series products to the serial port of
a host PC using minimal external hardware.Two different methods for connecting the
DBG pin to an RS-232 interface are shown in Figures 35 and 36.
Caution: For operation of the OCD, all power pins (VDD and AVDD) must be supplied with power,
and all ground pins (VSS and AVSS) must be properly grounded. The DBG pin is open-
drain and must always be connected to VDD through an external pull-up resistor to ensure
proper operation.
VDD
RS-232
Transceiver 10K Ohm
Diode
RS-232 TX DBG Pin
RS-232 RX
Figure 35. Interfacing the On-Chip Debugger’s DBG Pin with an RS-232 Interface, #1 of 2
160
VDD
RS-232
Transceiver 10KΩ
Open-Drain
Buffer
RS-232 TX DBG Pin
RS-232 RX
Figure 36. Interfacing the On-Chip Debugger’s DBG Pin with an RS-232 Interface, #2 of 2
Debug Mode
The operating characteristics of the Z8 Encore! XP® F0822 Series devices in DEBUG
Mode are:
• The eZ8 CPU fetch unit stops, idling the eZ8 CPU, unless directed by the OCD to ex-
ecute specific instructions
• The system clock operates unless in STOP Mode
• All enabled on-chip peripherals operate unless in STOP Mode
• Automatically exits HALT Mode
• Constantly refreshes the Watchdog Timer, if enabled
161
START D0 D1 D2 D3 D4 D5 D6 D7 STOP
162
If the OCD receives a serial break (nine or more continuous bits Low) the Autobaud
Detector/Generator resets. The Autobaud Detector/Generator can then be reconfigured by
sending 80H.
When the OCD detects one of these errors, it aborts any command currently in progress,
transmits a serial break that is 4096 system clock cycles in duration to the host, and resets
the Autobaud Detector/Generator. A framing error or transmit collision can be caused by
the host sending a serial break to the OCD. Because of the open-drain nature of the inter-
face, returning a serial break back to the host only extends the length of the serial break if
the host releases the serial break early.
The host transmits a serial break on the DBG pin when first connecting to the Z8 Encore!
XP® F0822 Series device or when recovering from an error. A serial break from the host
resets the Autobaud Generator/Detector but does not reset the OCD Control Register. A
serial break leaves the device in DEBUG Mode if that is the current mode. The OCD is
held in Reset until the end of the serial break when the DBG pin returns High. Because of
the open-drain nature of the DBG pin, the host can send a serial break to the OCD even if
the OCD is transmitting a character.
Breakpoints
Execution breakpoints are generated using the BRK instruction (Op Code 00H). When the
eZ8 CPU decodes a BRK instruction, it signals the OCD. If breakpoints are enabled, the
OCD idles the eZ8 CPU and enters DEBUG Mode. If breakpoints are not enabled, the
OCD ignores the BRK signal and the BRK instruction operates as a NOP instruction.
163
If breakpoints are enabled, the OCD can be configured to automatically enter DEBUG
Mode, or to loop on the break instruction. If the OCD is configured to loop on the BRK
instruction, then the CPU is still enabled to service DMA and interrupt requests.
The loop on a BRK instruction can be used to service interrupts in the background. For
interrupts to be serviced in the background, there cannot be any breakpoints in the ISR.
Otherwise, the CPU stops on the breakpoint in the interrupt routine. For interrupts to be
serviced in the background, interrupts must also be enabled. Debugging software should
not automatically enable interrupts when using this feature, because interrupts are typi-
cally disabled during critical sections of code where interrupts should not occur (such as
adjusting the stack pointer or modifying shared data).
Software can poll the IDLE bit of the OCDSTAT Register to determine if the OCD is loop-
ing on a BRK instruction. When software wants to stop the CPU on the BRK instruction it
is looping on, software should not set the DBGMODE bit of the OCDCTL Register. The
CPU can have vectored to and be in the middle of an ISR when this bit gets set. Instead,
software must clear the BRKLP bit. This allows the CPU to finish the ISR it is in and
return the BRK instruction. When the CPU returns to the BRK instruction it was previ-
ously looping on, it automatically sets the DBGMODE bit and enter DEBUG Mode.
Software should also note that the majority of the OCD commands are still disabled when
the eZ8 CPU is looping on a BRK instruction. The eZ8 CPU must be stopped and the part
must be in DEBUG Mode before these commands can be issued.
OCDCNTR Register
The OCD contains a multipurpose 16-bit counter register. It can be used for the following:
• Count system clock cycles between breakpoints
• Generate a BRK when it counts down to zero
• Generate a BRK when its value matches the Program Counter
When configured as a counter, the OCDCNTR Register starts counting when the OCD
leaves DEBUG Mode and stops counting when it enters DEBUG Mode again or when it
reaches the maximum count of FFFFH. The OCDCNTR Register automatically resets
itself to 0000H when the OCD exits DEBUG Mode if it is configured to count clock
cycles between breakpoints.
164
Caution: The OCDCNTR Register is used by many of the OCD commands. It counts the number
of bytes for the register and memory read/write commands. It holds the residual value
when generating the CRC. Therefore, if the OCDCNTR is being used to generate a BRK,
its value should be written as a last step before leaving DEBUG Mode.
Because this register is overwritten by various OCD commands, it should only be used to
generate temporary breakpoints, such as stepping over CALL instructions or running to a
specific instruction and stopping.
Enabled When
Command Not in DEBUG
Debug Command Byte Mode? Disabled by Read Protect Option Bit
Read OCD Revision 00H Yes –
Write OCD Counter Register 01H – –
Read OCD Status Register 02H Yes –
Read OCD Counter Register 03H – –
Write OCD Control Register 04H Yes Cannot clear DBGMODE bit
Read OCD Control Register 05H Yes –
Write Program Counter 06H – Disabled
Read Program Counter 07H – Disabled
Write Register 08H – Only writes of the peripheral control reg-
isters at address F00H–FFH are allowed.
Additionally, only the Mass Erase com-
mand is allowed to be written to the Flash
Control Register.
165
Enabled When
Command Not in DEBUG
Debug Command Byte Mode? Disabled by Read Protect Option Bit
Read Register 09H – Only reads of the peripheral control reg-
isters at address F00H–FFH are allowed.
Write Program Memory 0AH – Disabled
Read Program Memory 0BH – Disabled
Write Data Memory 0CH – Disabled
Read Data Memory 0DH – Disabled
Read Program Memory CRC 0EH – –
Reserved 0FH – –
Step Instruction 10H – Disabled
Stuff Instruction 11H – Disabled
Execute Instruction 12H – Disabled
Reserved 13H–FFH – –
In the following bulleted list of OCD Commands, data and commands sent from the host
to the OCD are identified by DBG ← Command/Data. Data sent from the OCD back to the
host is identified by DBG → Data.
Read OCD Revision (00H). The Read OCD Revision command determines the version of
the OCD. If OCD commands are added, removed, or changed, this revision number
changes.
DBG ← 00H
DBG → OCDREV[15:8] (Major revision number)
DBG → OCDREV[7:0] (Minor revision number)
Write OCD Counter Register (01H). The Write OCD Counter Register command writes
the data that follows to the OCDCNTR Register. If the device is not in DEBUG Mode, the
data is discarded.
DBG ← 01H
DBG ← OCDCNTR[15:8]
DBG ← OCDCNTR[7:0]
Read OCD Status Register (02H). The Read OCD Status Register command reads the
OCDSTAT Register.
DBG ← 02H
DBG → OCDSTAT[7:0]
Read OCD Counter Register (03H). The OCD Counter Register can be used to count
system clock cycles in between breakpoints, generate a BRK when it counts down to zero,
166
or generate a BRK when its value matches the Program Counter. Because this register is
really a down counter, the returned value is inverted when this register is read so the
returned result appears to be an up counter. If the device is not in DEBUG Mode, this com-
mand returns FFFFH.
DBG ← 03H
DBG → ~OCDCNTR[15:8]
DBG → ~OCDCNTR[7:0]
Write OCD Control Register (04H). The Write OCD Control Register command writes
the data that follows to the OCDCTL Register. When the Read Protect option bit is
enabled, the DBGMODE bit (OCDCTL[7]) can only be set to 1, it cannot be cleared to 0
and the only method of putting the device back into normal operating mode is to reset the
device.
DBG ← 04H
DBG ← OCDCTL[7:0]
Read OCD Control Register (05H). The Read OCD Control Register command reads the
value of the OCDCTL Register.
DBG ← 05H
DBG → OCDCTL[7:0]
Write Program Counter (06H). The Write Program Counter command writes the data
that follows to the eZ8 CPU’s Program Counter. If the device is not in DEBUG Mode or if
the Read Protect option bit is enabled, the Program Counter values are discarded.
DBG ← 06H
DBG ← ProgramCounter[15:8]
DBG ← ProgramCounter[7:0]
Read Program Counter (07H). The Read Program Counter command reads the value in
the eZ8 CPU’s Program Counter. If the device is not in DEBUG Mode or if the Read Pro-
tect option bit is enabled, this command returns FFFFH.
DBG ← 07H
DBG → ProgramCounter[15:8]
DBG → ProgramCounter[7:0]
Write Register (08H). The Write Register command writes data to the Register File. Data
can be written 1-256 bytes at a time (256 bytes can be written by setting size to zero). If
the device is not in DEBUG Mode, the address and data values are discarded. If the Read
Protect option bit is enabled, then only writes to the Flash Control registers are allowed
and all other register write data values are discarded.
DBG ← 08H
DBG ← {4’h0,Register Address[11:8]}
DBG ← Register Address[7:0]
DBG ← Size[7:0]
DBG ← 1-256 data bytes
167
Read Register (09H). The Read Register command reads data from the Register File.
Data can be read 1-256 bytes at a time (256 bytes can be read by setting size to zero).
Reading peripheral control registers through the OCD does not effect peripheral operation.
For example, register bits that are normally cleared upon a read operation will not be
affected (the WDTSTAT Register is affected by the OCD Read Register operation). If the
device is not in DEBUG Mode or if the Read Protect option bit is enabled, this command
returns FFH for all of the data values.
DBG ← 09H
DBG ← {4’h0,Register Address[11:8]
DBG ← Register Address[7:0]
DBG ← Size[7:0]
DBG → 1-256 data bytes
Write Program Memory (0AH). The Write Program Memory command writes data to
Program memory. This command is equivalent to the LDC and LDCI instructions. Data
can be written 1-65536 bytes at a time (65536 bytes can be written by setting size to zero).
The on-chip Flash Controller must be written to and unlocked for the programming opera-
tion to occur. If the Flash Controller is not unlocked, the data is discarded. If the device is
not in DEBUG Mode or if the Read Protect option bit is enabled, the data is discarded.
DBG ← 0AH
DBG ← Program Memory Address[15:8]
DBG ← Program Memory Address[7:0]
DBG ← Size[15:8]
DBG ← Size[7:0]
DBG ← 1-65536 data bytes
Read Program Memory (0BH). The Read Program Memory command reads data from
Program memory. This command is equivalent to the LDC and LDCI instructions. Data
can be read 1-65536 bytes at a time (65536 bytes can be read by setting size to zero). If the
device is not in DEBUG Mode or if the Read Protect option bit is enabled, this command
returns FFH for the data.
DBG ← 0BH
DBG ← Program Memory Address[15:8]
DBG ← Program Memory Address[7:0]
DBG ← Size[15:8]
DBG ← Size[7:0]
DBG → 1-65536 data bytes
(Flash version only) Write Data Memory (0CH). The Write Data Memory command
writes data to Data Memory. This command is equivalent to the LDE and LDEI instruc-
tions. Data can be written 1-65536 bytes at a time (65536 bytes can be written by setting
size to 0). If the device is not in DEBUG Mode or if the Read Protect option bit is enabled,
the data is discarded.
DBG ← 0CH
DBG ← Data Memory Address[15:8]
DBG ← Data Memory Address[7:0]
DBG ← Size[15:8]
168
DBG ← Size[7:0]
DBG ← 1-65536 data bytes
Read Data Memory (0DH). The Read Data Memory command reads from Data Memory.
This command is equivalent to the LDE and LDEI instructions. Data can be read 1-65536
bytes at a time (65536 bytes can be read by setting size to 0). If the device is not in
DEBUG Mode, this command returns FFH for the data.
DBG ← 0DH
DBG ← Data Memory Address[15:8]
DBG ← Data Memory Address[7:0]
DBG ← Size[15:8]
DBG ← Size[7:0]
DBG → 1-65536 data bytes
Read Program Memory CRC (0EH). The Read Program Memory CRC command com-
putes and returns the CRC (cyclic redundancy check) of Program memory using the 16-bit
CRC-CCITT polynomial. If the device is not in DEBUG Mode, this command returns
FFFFH for the CRC value. Unlike most other OCD Read commands, there is a delay from
issuing of the command until the OCD returns the data. The OCD reads the Program
memory, calculates the CRC value, and returns the result. The delay is a function of the
Program memory size and is approximately equal to the system clock period multiplied by
the number of bytes in the Program memory.
DBG ← 0EH
DBG → CRC[15:8]
DBG → CRC[7:0]
Step Instruction (10H). The Step Instruction command steps one assembly instruction at
the current Program Counter location. If the device is not in DEBUG Mode or the Read
Protect option bit is enabled, the OCD ignores this command.
DBG ← 10H
Stuff Instruction (11H). The Stuff Instruction command steps one assembly instruction
and allows specification of the first byte of the instruction. The remaining 0-4 bytes of the
instruction are read from Program memory. This command is useful for stepping over
instructions where the first byte of the instruction has been overwritten by a Breakpoint. If
the device is not in DEBUG Mode or the Read Protect option bit is enabled, the OCD
ignores this command.
DBG ← 11H
DBG ← opcode[7:0]
Execute Instruction (12H). The Execute Instruction command allows sending an entire
instruction to be executed to the eZ8 CPU. This command can also step over breakpoints.
The number of bytes to send for the instruction depends on the Op Code. If the device is
not in DEBUG Mode or the Read Protect option bit is enabled, the OCD ignores this com-
mand.
169
DBG ← 12H
DBG ← 1-5 byte opcode
Bit 7 6 5 4 3 2 1 0
Field DBGMODE BRKEN DBGACK BRKLOOP BRKPC BRKZRO Reserved RST
RESET 0
R/W R/W R R/W
Bit Description
[7] Debug Mode
DBGMODE Setting this bit to 1 causes the device to enter DEBUG Mode. When in DEBUG Mode, the
eZ8 CPU stops fetching new instructions. Clearing this bit causes the eZ8 CPU to start run-
ning again. This bit is automatically set when a BRK instruction is decoded and breakpoints
are enabled. If the Read Protect option bit is enabled, this bit can only be cleared by reset-
ting the device, it cannot be written to 0.
0 = The Z8 Encore! XP® F0822 Series device is operating in NORMAL Mode.
1 = The Z8 Encore! XP® F0822 Series device is in DEBUG Mode.
[6] Breakpoint Enable
BRKEN This bit controls the behavior of the BRK instruction (Op Code 00H). By default, breakpoints
are disabled and the BRK instruction behaves like an NOP instruction. If this bit is set to 1
and a BRK instruction is decoded, the OCD takes action dependent upon the BRKLOOP bit.
0 = BRK instruction is disabled.
1 = BRK instruction is enabled.
[5] Debug Acknowledge
DBGACK This bit enables the debug acknowledge feature. If this bit is set to 1, then the OCD sends
an Debug Acknowledge character (FFH) to the host when a Breakpoint occurs.
0 = Debug Acknowledge is disabled.
1 = Debug Acknowledge is enabled.
170
171
Bit 7 6 5 4 3 2 1 0
Field IDLE HALT RPEN Reserved
RESET 0
R/W R
Bit Description
[7] CPU Idling
IDLE This bit is set if the part is in DEBUG Mode (DBGMODE is 1), or if a BRK instruction occurred
since the last time OCDCTL was written. This can be used to determine if the CPU is running
or if it is idling.
0 = The eZ8 CPU is running.
1 = The eZ8 CPU is either stopped or looping on a BRK instruction.
[6] HALT Mode
HALT 0 = The device is not in HALT Mode.
1 = The device is in HALT Mode.
[5] Read Protect Option Bit Enabled
RPEN 0 = The Read Protect option bit is disabled (1).
1 = The Read Protect option bit is enabled (0), disabling many OCD commands.
[4:0] Reserved
These bits are reserved and must be programmed to 00000.
172
On-Chip Oscillator
Z8 Encore! XP® F0822 Series products feature an on-chip oscillator for use with external
crystals with frequencies from 32 kHz to 20 MHz. In addition, the oscillator can support
external RC networks with oscillation frequencies up to 4 MHz or ceramic resonators with
oscillation frequencies up to 20 MHz. This oscillator generates the primary system clock
for the internal eZ8 CPU and the majority of the on-chip peripherals. Alternatively, the
XIN input pin can also accept a CMOS-level clock input signal (32 kHz–20 MHz). If an
external clock generator is used, the XOUT pin must remain unconnected.
When configured for use with crystal oscillators or external clock drivers, the frequency of
the signal on the XIN input pin determines the frequency of the system clock (that is, no
internal clock divider). In RC operation, the system clock is driven by a clock divider
(divide by 2) to ensure 50% duty cycle.
Operating Modes
Z8 Encore! XP® F0822 Series products support 4 different oscillator modes:
• On-chip oscillator configured for use with external RC networks (< 4 MHz)
• Minimum power for use with very-low-frequency crystals (32 kHz to 1.0 MHz)
• Medium power for use with medium frequency crystals or ceramic resonators (0.5 MHz
to 10.0 MHz)
• Maximum power for use with high-frequency crystals or ceramic resonators (8.0 MHz
to 20.0 MHz)
The oscillator mode is selected through user-programmable option bits. For more informa-
tion, see the Option Bits chapter on page 155.
173
On-Chip Oscillator
XIN XOUT
R1 = 220Ω
Crystal
C1 = 22pF C2 = 22pF
174
VDD
XIN
6
1 10
Oscillator Frequency (kHz) = ----------------------------------------------------------------
0.4 R C + 4 C
Figure 40 displays the typical (3.3 V and 25°C) oscillator frequency as a function of the
capacitor (C in pF) employed in the RC network assuming a 45 k external resistor. For
very small values of C, the parasitic capacitance of the oscillator XIN pin and the printed
circuit board should be included in the estimation of the oscillator frequency.
It is possible to operate the RC oscillator using only the parasitic capacitance of the pack-
age and printed circuit board. To minimize sensitivity to external parasites, external capac-
itance values in excess of 20 pF are recommended.
175
4000
3750
3500
3250
3000
2750
2500
Frequency (kHz)
2250
2000
1750
1500
1250
1000
750
500
250
0
0 20 40 60 80 100 120 140 160 180 200 220 240 260 280 300 320 340 360 380 400 420 440 460 480 500
C (pF)
Caution: When using the external RC oscillator mode, the oscillator can stop oscillating if the
power supply drops below 2.7 V, but before the power supply drops to the Voltage Brown-
Out threshold. The oscillator resumes oscillation when the supply voltage exceeds 2.7 V.
176
Electrical Characteristics
The data in this chapter represents all known data prior to qualification and characteriza-
tion of the Z8 Encore! XP® F0822 Series of products, and is therefore subject to change.
Additional electrical characteristics may be found in the individual chapters of this docu-
ment.
Caution: Stresses greater than those listed in Table 97 can cause permanent damage to the device.
177
178
DC Characteristics
Table 98 lists the DC characteristics of the Z8 Encore! XP® F0822 Series products. All
voltages are referenced to VSS, the primary system ground.
TA = –40°C to 105°C
Symbol Parameter Minimum Typical Maximum Units Conditions
VDD Supply Voltage 2.7 – 3.6 V
VIL1 Low Level Input -0.3 – 0.3*VDD V For all input pins except
Voltage RESET, DBG, and XIN.
VIL2 Low Level Input –0.3 – 0.2*VDD V For RESET, DBG, and XIN.
Voltage
VIH1 High Level Input 0.7*VDD – 5.5 V Ports A and C pins when their
Voltage programmable pull-ups are dis-
abled.
VIH2 High Level Input 0.7*VDD – VDD+0.3 V Port B pins. Ports A and C pins
Voltage when their programmable pull-
ups are enabled.
VIH3 High Level Input 0.8*VDD – VDD+0.3 V RESET, DBG, and XIN pins.
Voltage
VOL1 Low Level Output – – 0.4 V IOL = 2 mA; VDD = 3.0 V
Voltage High Output Drive disabled.
VOH1 High Level Output 2.4 – – V IOH = –2 mA; VDD = 3.0 V
Voltage High Output Drive disabled.
VOL2 Low Level Output – – 0.6 V IOL = 20 mA; VDD = 3.3 V
Voltage High High Output Drive enabled
Drive TA = –40°C to +70°C
VOH2 High Level Output 2.4 – – V IOH = –20 mA; VDD = 3.3 V
Voltage High High Output Drive enabled;
Drive TA = –40°C to +70°C
VOL3 Low Level Output – – 0.6 V IOL = 15mA; VDD = 3.3 V
Voltage High High Output Drive enabled;
Drive TA = +70°C to +105°C
VOH3 High Level Output 2.4 – – V IOH = 15 mA; VDD = 3.3 V
Voltage High High Output Drive enabled;
Drive TA = +70°C to +105°C
VRAM RAM Data 0.7 – – V
Retention
IIL Input Leakage –5 – +5 µA VDD = 3.6 V;
Current VIN = VDD or VSS1
179
TA = –40°C to 105°C
Symbol Parameter Minimum Typical Maximum Units Conditions
ITL Tri-State Leakage –5 – +5 µA VDD = 3.6 V
Current
CPAD GPIO Port Pad – 8.02 – pF
Capacitance
CXIN XIN Pad – 8.02 – pF
Capacitance
CXOUT XOUT Pad – 9.52 – pF
Capacitance
IPU1 Weak Pull-up 9 20 50 µA VDD = 2.7–3.6 V
Current TA = 0°C to +70°C
IPU2 Weak Pull-up 7 20 75 µA VDD = 2.7–3.6 V
Current TA = –40°C to +105°C
1
Note: This condition excludes all pins that have on-chip pull-ups, when driven Low.
Note: 2 These values are provided for design guidance only and are not tested in production.
Figure 41 displays the typical active mode current consumption while operating at 25ºC,
3.3 V, plotted opposite the system clock frequency. All GPIO pins are configured as out-
puts and driven High.
15
12.5
10
Idd (mA)
7.5
2.5
0
0 5 10 15 20
System Clock Frequency (MHz)
Figure 41. Typical Active Mode IDD vs. System Clock Frequency
180
Figure 42 displays the maximum active mode current consumption across the full operat-
ing temperature range of the device and plotted opposite the system clock frequency. All
GPIO pins are configured as outputs and driven High.
15
12.5
10
Idd (mA)
7.5
2.5
0
0 5 10 15 20
Syste m Clock Fre que ncy (M Hz)
Figure 42. Maximum Active Mode IDD vs. System Clock Frequency
181
Figure 43 displays the typical current consumption in HALT Mode while operating at
25ºC plotted opposite the system clock frequency. All GPIO pins are configured as outputs
and driven High.
5.000
4.000
Idd (mA)
3.000
2.000
1.000
0.000
0 5 10 15 20
System Clock Frequency (MHz)
Figure 43. Typical HALT Mode IDD vs. System Clock Frequency
182
Figure 44 displays the maximum HALT Mode current consumption across the entire oper-
ating temperature range of the device and plotted opposite the system clock frequency. All
GPIO pins are configured as outputs and driven High.
5.000
4.000
Idd (mA)
3.000
2.000
1.000
0.000
0 5 10 15 20
System Clock Frequency (MHz)
Figure 44. Maximum HALT Mode ICC vs. System Clock Frequency
183
Figure 45 displays the maximum current consumption in STOP Mode with the VBO and
Watchdog Timer enabled plotted opposite the power supply voltage. All GPIO pins are
configured as outputs and driven High.
650
600
l
Idd (uA)
550
500
450
400
2.7 3 3.3 3.6
Vdd (V)
Figure 45. Maximum STOP Mode IDD with VBO Enabled vs. Power Supply Voltage
184
Figure 46 displays the maximum current consumption in STOP Mode with the VBO dis-
abled and Watchdog Timer enabled plotted opposite the power supply voltage. All GPIO
pins are configured as outputs and driven High. Disabling the Watchdog Timer and its
internal RC oscillator in STOP Mode will provide some additional reduction in STOP
Mode current consumption. This small current reduction is indistinquishable on the scale
of Figure 46.
200
150
Idd (uA)
100
50
0
2.7 3 3.3 3.6
Vd d (V)
Figure 46. Maximum STOP Mode IDD with VBO Disabled vs. Power Supply Voltage
185
AC Characteristics
Table 99 provides information about the AC characteristics and timing. All AC timing
information assumes a standard load of 50 pF on all outputs.
VDD = 2.7–3.6 V
TA = –40°C to 105°C
Symbol Parameter Minimum Maximum Units Conditions
FSYSCLK System Clock Frequency – 20.0 MHz
(ROM)
FSYSCLK System Clock Frequency – 20.0 MHz Read-only from Flash mem-
(Flash) ory.
0.032768 20.0 MHz Program or erasure of Flash
memory.
FXTAL Crystal Oscillator Frequency 0.032768 20.0 MHz System clock frequencies
below the crystal oscillator
minimum require an exter-
nal clock driver.
TXIN System Clock Period 50 – ns TCLK = 1/FSYSCLK
TXINH System Clock High Time 20 30 ns TCLK = 50 ns
TXINL System Clock Low Time 20 30 ns TCLK = 50 ns
186
Table 100. Power-On Reset and Voltage Brown-Out Electrical Characteristics and Timing
TA = –40°C to 105°C
Symbol Parameter Minimum Typical* Maximum Units Conditions
VPOR Power-On Reset 2.15 2.40 2.60 V VDD = VPOR
Voltage Threshold
VVBO Voltage Brown-Out 2.05 2.30 2.55 V VDD = VVBO
Reset Voltage
Threshold
VPOR to VVBO hys- 50 100 – mV
teresis
Starting VDD voltage – VSS – V
to ensure valid POR
TANA POR Analog Delay – 50 – µs VDD > VPOR; TPOR Digital
Reset delay follows TANA
TPOR POR Digital Delay – 5.0 – ms 50 WDT Oscillator cycles
(10 kHz) + 16 System Clock
cycles (20 MHz)
TVBO Voltage Brown-Out – 10 – µs VDD < VVBO to generate a
Pulse Rejection Reset.
Period
TRAMP Time for VDD to 0.10 – 100 ms
transition from VSS
to VPOR to ensure
valid Reset
Note: *Data in the typical column is from characterization at 3.3 V and 25°C. These values are provided for design
guidance only and are not tested in production.
187
Table 101 provides information about the external RC oscillator electrical characteristics
and timing, and Table 102 provides information about the Flash memory electrical charac-
teristics and timing.
TA = –40°C to 105°C
Symbol Parameter Minimum Typical* Maximum Units Conditions
VDD Operating Voltage Range 2.70 – – V
REXT External Resistance from 40 45 200 kΩ
XIN to VDD
CEXT External Capacitance 0 20 1000 pF
from XIN to VSS
FOSC External RC Oscillation – – 4 MHz
Frequency
Note: *When using the external RC oscillator mode, the oscillator can stop oscillating if the power supply drops below
2.7 V, but before the power supply drops to the voltage brown-out threshold. The oscillator will resume oscilla-
tion as soon as the supply voltage exceeds 2.7 V.
VDD = 2.7–3.6V
TA = –40°C to 105°C
Parameter Minimum Typical Maximum Units Notes
Flash Byte Read Time 50 – – µs
Flash Byte Program Time 20 – 40 µs
Flash Page Erase Time 10 – – ms
Flash Mass Erase Time 200 – – ms
Writes to Single Address – – 2
Before Next Erase
Flash Row Program Time – – 8 ms Cumulative program time for
single row cannot exceed limit
before next erase. This param-
eter is only an issue when
bypassing the Flash Controller.
Data Retention 100 – – years 25°C
Endurance 10,000 – – cycles Program/erase cycles
188
Table 103 lists Reset and Stop Mode Recovery pin timing data; Table 104 lists Watchdog
Timer Electrical Characteristics and Timing data.
TA = –40°C to 105°C
Symbol Parameter Minimum Typical* Maximum Units Conditions
TRESET Reset pin assertion to 4 – – TCLK Not in STOP Mode.
initiate a System Reset TCLK = System Clock
period.
TSMR Stop Mode Recovery pin 10 20 40 ns RESET, DBG and
Pulse Rejection Period GPIO pins configured
as SMR sources.
Note: *When using the external RC oscillator mode, the oscillator can stop oscillating if the power supply drops below
2.7 V, but before the power supply drops to the voltage brown-out threshold. The oscillator will resume oscillation
as soon as the supply voltage exceeds 2.7 V.
VDD = 2.7–3.6 V
TA = –40°C to 105°C
Symbol Parameter Minimum Typical Maximum Units Conditions
FWDT WDT Oscillator Frequency 5 10 20 kHz
IWDT WDT Oscillator Current including – <1 5 µA
internal RC oscillator
189
0.9
0.8
-3 dB
0.7
Frequency Response
0.6
0.5
-6 dB
0.4
0.3
0.2
0.1
0
0 5 10 15 20 25 30
Frequency (kHz)
190
VDD = 3.0–3.6 V
TA = –40°C to 105°C
Symbol Parameter Minimum Typical Maximum Units Conditions
Resolution 10 – – bits External VREF = 3.0 V
Differential Nonlinearity –0.25 – 0.25 lsb Guaranteed by design
(DNL)
Integral Nonlinearity –2.0 – 2.0 lsb External VREF = 3.0 V
(INL)
DC Offset Error –35 – 25 mV 80-pin QFP and 64-pin
LQFP packages.
VREF Internal Reference 1.9 2.0 2.4 V VDD = 3.0–3.6 V
Voltage TA = –40°C to 105°C
VCREF Voltage Coefficient of – 78 – mV/V VREF variation as a func-
Internal Reference tion of AVDD.
Voltage
TCREF Temperature – 1 – mV/°C
Coefficient of Internal
Reference Voltage
Single-Shot 5129 cycles System clock cycles
Conversion Period
Continuous Conversion 256 cycles System clock cycles
Period
RS Analog Source – – 150 Ω Recommended
Impedance
Zin Input Impedance 150 KΩ 20MHz system clock.
Input impedance
increases with lower sys-
tem clock frequency.
VREF External Reference AVDD V AVDD <= VDD. When
Voltage using an external refer-
ence voltage, decoupling
capacitance should be
placed from VREF to
AVSS.
IREF Current draw into VREF 25.0 40.0 µA
pin when driving with
external source.
191
TCLK
System
Clock
Port Value
Changes to 0
GPIO Pin
Input Value
GPIO Input
0 Latched
Data Latch
Into Port Input
Data Register
Delay (ns)
Parameter Abbreviation Minimum Maximum
TS_PORT Port Input Transition to XIN Fall Setup Time (not pictured) 5 –
TH_PORT XIN Fall to Port Input Transition Hold Time (not pictured) 5 –
TSMR GPIO Port Pin Pulse Width to Insure Stop Mode Recovery (for 1 µs
GPIO port pins enabled as SMR sources)
192
TCLK
XIN
T1 T2
Port Output
Delay (ns)
Parameter Abbreviation Minimum Maximum
GPIO Port Pins
T1 XIN Rise to Port Output Valid Delay – 15
T2 XIN Rise to Port Output Hold Time 2 –
193
TCLK
XIN
T1 T2
T3 T4
Delay (ns)
Parameter Abbreviation Minimum Maximum
DBG
T1 XIN Rise to DBG Valid Delay – 15
T2 XIN Rise to DBG Output Hold Time 2 –
T3 DBG to XIN Rise Input Setup Time 10 –
T4 DBG to XIN Rise Input Hold Time 5 –
DBG frequency System
Clock/4
194
SCK
T1
T2 T3
Delay (ns)
Parameter Abbreviation Minimum Maximum
SPI MASTER
T1 SCK Rise to MOSI output Valid Delay –5 +5
T2 MISO input to SCK (receive edge) Setup Time 20
T3 MISO input to SCK (receive edge) Hold Time 0
195
SCK
T1
T2 T3
T4
SS
(Input)
Delay (ns)
Parameter Abbreviation Minimum Maximum
SPI SLAVE
T1 SCK (transmit edge) to MISO output Valid Delay 2 * XIN period 3 * XIN period +
20 ns
T2 MOSI input to SCK (receive edge) Setup Time 0
T3 MOSI input to SCK (receive edge) Hold Time 3 * XIN period
T4 SS input assertion to SCK setup 1 * XIN period
196
I2C Timing
Figure 53 and Table 111 provide timing information for I2C pins.
SCL
(Output)
T1
T3
T2
Delay (ns)
Parameter Abbreviation Minimum Maximum
I2C
T1 SCL Fall to SDA output delay SCL period/4
T2 SDA Input to SCL rising edge Setup Time 0
T3 SDA Input to SCL falling edge Hold Time 0
197
UART Timing
Figure 54 and Table 112 provide timing information for UART pins for the case where the
Clear To Send input pin (CTS) is used for flow control. In this example, it is assumed that
the Driver Enable polarity has been configured to be Active Low and is represented here
by DE. The CTS to DE assertion delay (T1) assumes the UART Transmit Data Register
has been loaded with data prior to CTS assertion.
CTS
(Input)
T1
DE
(Output)
T2 T3
TXD Stop
Start Bit 0 Bit 1 Bit 7 Parity
(Output)
End of
Stop Bit(s)
Delay (ns)
Parameter Abbreviation Minimum Maximum
T1 CTS Fall to DE Assertion Delay 2 * XIN period 2 * XIN period + 1
Bit period
T2 DE Assertion to TXD Falling Edge (Start) Delay 1 Bit period 1 Bit period +
1 * XIN period
T3 End of Stop Bit(s) to DE Deassertion Delay 1 * XIN period 2 * XIN period
Figure 55 and Table 113 provide timing information for UART pins for the case where the
Clear To Send input signal (CTS) is not used for flow control. In this example, it is
assumed that the Driver Enable polarity has been configured to be Active Low and is rep-
198
resented here by DE. DE asserts after the UART Transmit Data Register has been written.
DE remains asserted for multiple characters as long as the Transmit Data Register is writ-
ten with the next character before the current character has completed.
DE
(Output)
T1 T2
TXD Stop
Start Bit 0 Bit 1 Bit 7 Parity
(Output)
End of
Stop Bit(s)
Delay (ns)
Parameter Abbreviation Minimum Maximum
T1 DE Assertion to TXD Falling Edge (Start) Delay 1 Bit period 1 Bit period +
1 * XIN period
T2 End of Stop Bit(s) to DE Deassertion Delay 1 * XIN period 2 * XIN period
199
200
Example 2. In general, when an instruction format requires an 8-bit register address, that
address can specify any register location in the range 0–255 or, using Escaped Mode
Addressing, a Working Register R0–R15. If the contents of Register 43H and Working
Register R8 are added and the result is stored in 43H, the assembly syntax and resulting
object code result is shown in Table 115.
201
The register file size varies, depending on device type. See the device-specific Z8 Encore!
XP Product Specification to determine the exact register file range available.
202
Table 117 contains additional symbols that are used throughout the Instruction Summary
and Instruction Set Description sections.
Symbol Definition
dst Destination Operand
src Source Operand
@ Indirect Address Prefix
SP Stack Pointer
PC Program Counter
FLAGS Flags Register
RP Register Pointer
# Immediate Operand Prefix
B Binary Number Suffix
% Hexadecimal Number Prefix
H Hexadecimal Number Suffix
203
Condition Codes
The C, Z, S, and V flags control the operation of the conditional jump (JP cc and JR cc)
instructions. Sixteen frequently useful functions of the flag settings are encoded in a 4-bit
field called the condition code (cc), which forms Bits 7:4 of the conditional jump instruc-
tions. The condition codes are summarized in Table 118. Some binary condition codes can
be created using more than one assembly code mnemonic. The result of the flag test oper-
ation decides if the conditional jump is executed.
Assembly
Binary Hex Mnemonic Definition Flag Test Operation
0000 0 F Always False –
0001 1 LT Less Than (S XOR V) = 1
0010 2 LE Less Than or Equal (Z OR (S XOR V)) = 1
0011 3 ULE Unsigned Less Than or Equal (C OR Z) = 1
0100 4 OV Overflow V=1
0101 5 Ml Minus S=1
0110 6 Z Zero Z=1
0110 6 EQ Equal Z=1
0111 7 C Carry C=1
0111 7 ULT Unsigned Less Than C=1
1000 8 T (or blank) Always True –
1001 9 GE Greater Than or Equal (S XOR V) = 0
1010 A GT Greater Than (Z OR (S XOR V)) = 0
1011 B UGT Unsigned Greater Than (C = 0 AND Z = 0) = 1
1100 C NOV No Overflow V=0
1101 D PL Plus S=0
1110 E NZ Non-Zero Z=0
1110 E NE Not Equal Z=0
1111 F NC No Carry C=0
1111 F UGE Unsigned Greater Than or C=0
Equal
204
Tables 119 through 126 contain the instructions belonging to each group and the number
of operands required for each instruction. Some instructions appear in more than one table
as these instruction can be considered as a subset of more than one category. Within these
tables, the source operand is identified as ’src’, the destination operand is ’dst’ and a con-
dition code is ’cc’.
205
206
207
208
Address
Op
Mode Flags
Assembly Symbolic Code(s) Fetch Instr.
Mnemonic Operation dst src (Hex) C Z S V D H Cycles Cycles
ADC dst, src dst ← dst + src + C r r 12 * * * * 0 * 2 3
r Ir 13 2 4
R R 14 3 3
R IR 15 3 4
R IM 16 3 3
IR IM 17 3 4
ADCX dst, src dst ← dst + src + C ER ER 18 * * * * 0 * 4 3
ER IM 19 4 3
Note: Flags Notation:
* = Value is a function of the result of the operation.
– = Unaffected.
X = Undefined.
0 = Reset to 0.
1 = Set to 1.
209
Address
Op
Mode Flags
Assembly Symbolic Code(s) Fetch Instr.
Mnemonic Operation dst src (Hex) C Z S V D H Cycles Cycles
ADD dst, src dst ← dst + src r r 02 * * * * 0 * 2 3
r Ir 03 2 4
R R 04 3 3
R IR 05 3 4
R IM 06 3 3
IR IM 07 3 4
ADDX dst, src dst ← dst + src ER ER 08 * * * * 0 * 4 3
ER IM 09 4 3
AND dst, src dst ← dst AND src r r 52 - * * 0 - - 2 3
r Ir 53 2 4
R R 54 3 3
R IR 55 3 4
R IM 56 3 3
IR IM 57 3 4
ANDX dst, src dst ← dst AND src ER ER 58 - * * 0 - - 4 3
ER IM 59 4 3
BCLR bit, dst dst[bit] ← 0 r E2 - - - - - - 2 2
BIT p, bit, dst dst[bit] ← p r E2 - - - - - - 2 2
BRK Debugger Break 00 - - - - - - 1 1
BSET bit, dst dst[bit] ← 1 r E2 - - - - - - 2 2
BSWAP dst dst[7:0] ← dst[0:7] R D5 X * * 0 - - 2 2
BTJ p, bit, src, if src[bit] = p r F6 - - - - - - 3 3
dst PC ← PC + X Ir F7 3 4
BTJNZ bit, src, if src[bit] = 1 r F6 - - - - - - 3 3
dst PC ← PC + X Ir F7 3 4
BTJZ bit, src, if src[bit] = 0 r F6 - - - - - - 3 3
dst PC ← PC + X Ir F7 3 4
Note: Flags Notation:
* = Value is a function of the result of the operation.
– = Unaffected.
X = Undefined.
0 = Reset to 0.
1 = Set to 1.
210
Address
Op
Mode Flags
Assembly Symbolic Code(s) Fetch Instr.
Mnemonic Operation dst src (Hex) C Z S V D H Cycles Cycles
CALL dst SP ← SP -2 IRR D4 - - - - - - 2 6
@SP ← PC DA D6 3 3
PC ← dst
CCF C ← ~C EF * - - - - - 1 2
CLR dst dst ← 00H R B0 - - - - - - 2 2
IR B1 2 3
COM dst dst ← ~dst R 60 - * * 0 - - 2 2
IR 61 2 3
CP dst, src dst – src r r A2 * * * * - - 2 3
r Ir A3 2 4
R R A4 3 3
R IR A5 3 4
R IM A6 3 3
IR IM A7 3 4
CPC dst, src dst – src – C r r 1F A2 * * * * - - 3 3
r Ir 1F A3 3 4
R R 1F A4 4 3
R IR 1F A5 4 4
R IM 1F A6 4 3
IR IM 1F A7 4 4
CPCX dst, src dst – src – C ER ER 1F A8 * * * * - - 5 3
ER IM 1F A9 5 3
CPX dst, src dst – src ER ER A8 * * * * - - 4 3
ER IM A9 4 3
DA dst dst ← DA(dst) R 40 * * * X - - 2 2
IR 41 2 3
DEC dst dst ← dst – 1 R 30 - * * * - - 2 2
IR 31 2 3
Note: Flags Notation:
* = Value is a function of the result of the operation.
– = Unaffected.
X = Undefined.
0 = Reset to 0.
1 = Set to 1.
211
Address
Op
Mode Flags
Assembly Symbolic Code(s) Fetch Instr.
Mnemonic Operation dst src (Hex) C Z S V D H Cycles Cycles
DECW dst dst ← dst – 1 RR 80 - * * * - - 2 5
IRR 81 2 6
DI IRQCTL[7] ← 0 8F - - - - - - 1 2
DJNZ dst, RA dst ← dst – 1 r 0A-FA - - - - - - 2 3
if dst 0
PC ← PC + X
EI IRQCTL[7] ← 1 9F - - - - - - 1 2
HALT HALT Mode 7F - - - - - - 1 2
INC dst dst ← dst + 1 R 20 - * * * - - 2 2
IR 21 2 3
r 0E-FE 1 2
INCW dst dst ← dst + 1 RR A0 - * * * - - 2 5
IRR A1 2 6
IRET FLAGS ← @SP BF * * * * * * 1 5
SP ← SP + 1
PC ← @SP
SP ← SP + 2
IRQCTL[7] ← 1
JP dst PC ← dst DA 8D - - - - - - 3 2
IRR C4 2 3
JP cc, dst if cc is true DA 0D-FD - - - - - - 3 2
PC ← dst
JR dst PC ← PC + X DA 8B - - - - - - 2 2
JR cc, dst if cc is true DA 0B-FB - - - - - - 2 2
PC ← PC + X
Note: Flags Notation:
* = Value is a function of the result of the operation.
– = Unaffected.
X = Undefined.
0 = Reset to 0.
1 = Set to 1.
212
Address
Op
Mode Flags
Assembly Symbolic Code(s) Fetch Instr.
Mnemonic Operation dst src (Hex) C Z S V D H Cycles Cycles
LD dst, rc dst ← src r IM 0C-FC - - - - - - 2 2
r X(r) C7 3 3
X(r) r D7 3 4
r Ir E3 2 3
R R E4 3 2
R IR E5 3 4
R IM E6 3 2
IR IM E7 3 3
Ir r F3 2 3
IR R F5 3 3
LDC dst, src dst ← src r Irr C2 - - - - - - 2 5
Ir Irr C5 2 9
Irr r D2 2 5
LDCI dst, src dst ← src Ir Irr C3 - - - - - - 2 9
r ← r + 1 Irr Ir D3 2 9
rr ← rr + 1
LDE dst, src dst ← src r Irr 82 - - - - - - 2 5
Irr r 92 2 5
LDEI dst, src dst ← src Ir Irr 83 - - - - - - 2 9
r ← r + 1 Irr Ir 93 2 9
rr ← rr + 1
LDWX dst, src dst ← src ER ER 1F E8 - - - - - - 5 4
Note: Flags Notation:
* = Value is a function of the result of the operation.
– = Unaffected.
X = Undefined.
0 = Reset to 0.
1 = Set to 1.
213
Address
Op
Mode Flags
Assembly Symbolic Code(s) Fetch Instr.
Mnemonic Operation dst src (Hex) C Z S V D H Cycles Cycles
LDX dst, src dst ← src r ER 84 - - - - - - 3 2
Ir ER 85 3 3
R IRR 86 3 4
IR IRR 87 3 5
r X(rr) 88 3 4
X(rr) r 89 3 4
ER r 94 3 2
ER Ir 95 3 3
IRR R 96 3 4
IRR IR 97 3 5
ER ER E8 4 2
ER IM E9 4 2
LEA dst, X(src) dst ← src + X r X(r) 98 - - - - - - 3 3
rr X(rr) 99 3 5
MULT dst dst[15:0] ← RR F4 - - - - - - 2 8
dst[15:8] * dst[7:0]
NOP No operation 0F - - - - - - 1 2
OR dst, src dst ← dst OR src r r 42 - * * 0 - - 2 3
r Ir 43 2 4
R R 44 3 3
R IR 45 3 4
R IM 46 3 3
IR IM 47 3 4
ORX dst, src dst ← dst OR src ER ER 48 - * * 0 - - 4 3
ER IM 49 4 3
POP dst dst ← @SP R 50 - - - - - - 2 2
SP ← SP + 1 IR 51 2 3
Note: Flags Notation:
* = Value is a function of the result of the operation.
– = Unaffected.
X = Undefined.
0 = Reset to 0.
1 = Set to 1.
214
Address
Op
Mode Flags
Assembly Symbolic Code(s) Fetch Instr.
Mnemonic Operation dst src (Hex) C Z S V D H Cycles Cycles
POPX dst dst ← @SP ER D8 - - - - - - 3 2
SP ← SP + 1
PUSH src SP ← SP – 1 R 70 - - - - - - 2 2
@SP ← src IR 71 2 3
PUSHX src SP ← SP – 1 ER C8 - - - - - - 3 2
@SP ← src
RCF C←0 CF 0 - - - - - 1 2
RET PC ← @SP AF - - - - - - 1 4
SP ← SP + 2
RL dst R 90 * * * * - - 2 2
C D7 D6 D5 D4 D3 D2 D1 D0
dst
IR 91 2 3
RLC dst R 10 * * * * - - 2 2
C D7 D6 D5 D4 D3 D2 D1 D0
dst IR 11 2 3
RR dst R E0 * * * * - - 2 2
D7 D6 D5 D4 D3 D2 D1 D0 C
dst
IR E1 2 3
RRC dst R C0 * * * * - - 2 2
D7 D6 D5 D4 D3 D2 D1 D0 C
dst IR C1 2 3
SBC dst, src dst ← dst – src – C r r 32 * * * * 1 * 2 3
r Ir 33 2 4
R R 34 3 3
R IR 35 3 4
R IM 36 3 3
IR IM 37 3 4
SBCX dst, src dst ← dst – src – C ER ER 38 * * * * 1 * 4 3
ER IM 39 4 3
SCF C←1 DF 1 - - - - - 1 2
SRA dst R D0 * * * 0 - - 2 2
D7 D6 D5 D4 D3 D2 D1 D0 C
dst
IR D1 2 3
Note: Flags Notation:
* = Value is a function of the result of the operation.
– = Unaffected.
X = Undefined.
0 = Reset to 0.
1 = Set to 1.
215
Address
Op
Mode Flags
Assembly Symbolic Code(s) Fetch Instr.
Mnemonic Operation dst src (Hex) C Z S V D H Cycles Cycles
SRL dst D7 D6 D5 D4 D3 D2 D1 D0 C R 1F C0 * * 0 * - - 3 2
dst
IR 1F C1 3 3
SRP src RP ← src IM 01 - - - - - - 2 2
STOP STOP Mode 6F - - - - - - 1 2
SUB dst, src dst ← dst – src r r 22 * * * * 1 * 2 3
r Ir 23 2 4
R R 24 3 3
R IR 25 3 4
R IM 26 3 3
IR IM 27 3 4
SUBX dst, src dst ← dst – src ER ER 28 * * * * 1 * 4 3
ER IM 29 4 3
SWAP dst dst[7:4] ↔ dst[3:0] R F0 X * * X - - 2 2
IR F1 2 3
TCM dst, src (NOT dst) AND src r r 62 - * * 0 - - 2 3
r Ir 63 2 4
R R 64 3 3
R IR 65 3 4
R IM 66 3 3
IR IM 67 3 4
TCMX dst, src (NOT dst) AND src ER ER 68 - * * 0 - - 4 3
ER IM 69 4 3
Note: Flags Notation:
* = Value is a function of the result of the operation.
– = Unaffected.
X = Undefined.
0 = Reset to 0.
1 = Set to 1.
216
Address
Op
Mode Flags
Assembly Symbolic Code(s) Fetch Instr.
Mnemonic Operation dst src (Hex) C Z S V D H Cycles Cycles
TM dst, src dst AND src r r 72 - * * 0 - - 2 3
r Ir 73 2 4
R R 74 3 3
R IR 75 3 4
R IM 76 3 3
IR IM 77 3 4
TMX dst, src dst AND src ER ER 78 - * * 0 - - 4 3
ER IM 79 4 3
TRAP Vector SP ← SP – 2 Vecto F2 - - - - - - 2 6
@SP ← PC r
SP ← SP – 1
@SP ← FLAGS
PC ← @Vector
WDT 5F - - - - - - 1 2
XOR dst, src dst ← dst XOR src r r B2 - * * 0 - - 2 3
r Ir B3 2 4
R R B4 3 3
R IR B5 3 4
R IM B6 3 3
IR IM B7 3 4
XORX dst, src dst ← dst XOR src ER ER B8 - * * 0 - - 4 3
ER IM B9 4 3
Note: Flags Notation:
* = Value is a function of the result of the operation.
– = Unaffected.
X = Undefined.
0 = Reset to 0.
1 = Set to 1.
217
Flags Register
The Flags Register contains the status information regarding the most recent arithmetic,
logical, bit manipulation or rotate and shift operation. The Flags Register contains six bits
of status information that are set or cleared by CPU operations. Four of the bits (C, V, Z
and S) can be tested with conditional jump instructions. Two flags (H and D) cannot be
tested and are used for Binary-Coded Decimal (BCD) arithmetic.
The two remaining bits, User Flags (F1 and F2), are available as general-purpose status
bits. User Flags are unaffected by arithmetic operations and must be set or cleared by
instructions. The User Flags cannot be used with conditional Jumps. They are undefined at
initial power-up and are unaffected by Reset. Figure 56 illustrates the flags and their bit
positions in the Flags Register.
Bit Bit
7 0
C Z S V D H F2 F1 Flags Register
User Flags
Overflow Flag
Sign Flag
Zero Flag
Carry Flag
Interrupts, the Software Trap (TRAP) instruction, and Illegal Instruction Traps all write
the value of the Flags Register to the stack. Executing an Interrupt Return (IRET) instruc-
tion restores the value saved on the stack into the Flags Register.
218
Op Code Maps
A description of the Op Code map data and the abbreviations are provided in Figure 57 and
Table 128. Figures 58 and 59 provide information about each of the eZ8 CPU instructions.
Op Code
Lower Nibble
3.3
Op Code
Upper Nibble A CP
R2,R1
219
220
6
Upper Nibble (Hex)
3.2 3.3
C SRL SRL
R1 IR1
5.4
D LDWX
ER2,ER1
221
Packaging
Zilog’s Z8 Encore! XP® F0822 Series of MCUs includes the Z8F0411, Z8F0421,
Z8F0811 and Z8F0821 devices, which are available in the following packages:
• 20-pin Small Shrink Outline Package (SSOP)
• 20-pin Plastic Dual-Inline Package (PDIP)
Zilog’s Z8 Encore! XP® F0822 Series of MCUs also includes the Z8F0412, Z8F0422,
Z8F0812 and Z8F0822 devices, which are available in the following packages:
• 28-pin Small Outline Integrated Circuit Package (SOIC)
• 28-pin Plastic Dual-Inline Package (PDIP)
Current diagrams for each of these packages are published in Zilog’s Packaging Product
Specification (PS0072), which is available free for download from the Zilog website.
222
Ordering Information
Order your Z8 Encore! XP® F0822 Series products from Zilog using the part numbers
shown in Table 129. For more information about ordering, please consult your local Zilog
sales office. The Sales Location page on the Zilog website lists all regional offices.
Description
Interrupts
I/O Lines
Flash
RAM
SPI
I2C
223
Description
Interrupts
I/O Lines
Flash
RAM
SPI
I2C
Z8F04xx with 4 KB Flash, 10-Bit Analog-to-Digital Converter
Standard Temperature: 0°C to 70°C
Z8F0421HH020SG 4 KB 1 KB 11 16 2 2 1 0 1 SSOP 20-pin package
Z8F0421PH020SG 4 KB 1 KB 11 16 2 2 1 0 1 PDIP 20-pin package
Z8F0422SJ020SG 4 KB 1 KB 19 19 2 5 1 1 1 SOIC 28-pin package
Z8F0422PJ020SG 4 KB 1 KB 19 19 2 5 1 1 1 PDIP 28-pin package
Extended Temperature: –40°C to 105°C
Z8F0421HH020EG 4 KB 1 KB 11 16 2 2 1 0 1 SSOP 20-pin package
Z8F0421PH020EG 4 KB 1 KB 11 16 2 2 1 0 1 PDIP 20-pin package
Z8F0422SJ020EG 4 KB 1 KB 19 19 2 5 1 1 1 SOIC 28-pin package
Z8F0422PJ020EG 4 KB 1 KB 19 19 2 5 1 1 1 PDIP 28-pin package
Z8F04xx with 4 KB Flash
Standard Temperature: 0°C to 70°C
Z8F0411HH020SG 4 KB 1 KB 11 16 2 0 1 0 1 SSOP 20-pin package
Z8F0411PH020SG 4 KB 1 KB 11 16 2 0 1 0 1 PDIP 20-pin package
Z8F0412SJ020SG 4 KB 1 KB 19 19 2 0 1 1 1 SOIC 28-pin package
Z8F0412PJ020SG 4 KB 1 KB 19 19 2 0 1 1 1 PDIP 28-pin package
Extended Temperature: –40°C to 105°C
Z8F0411HH020EG 4 KB 1 KB 11 16 2 0 1 0 1 SSOP 20-pin package
Z8F0411PH020EG 4 KB 1 KB 11 16 2 0 1 0 1 PDIP 20-pin package
Z8F0412SJ020EG 4 KB 1 KB 19 19 2 0 1 1 1 SOIC 28-pin package
Z8F0412PJ020EG 4 KB 1 KB 19 19 2 0 1 1 1 PDIP 28-pin package
Z8F08200100KITG Development Kit (20- and 28-pin)
ZUSBSC00100ZACG USB Smart Cable Accessory Kit
ZUSBOPTSC01ZACG Opto-Isolated USB Smart Cable Accessory Kit
Visit the Zilog website at http://www.zilog.com for ordering information about Z8 Encore!
XP® F0822 Series development tools and accessories.
224
Z8 F 08 21 H H 020 S G
Environmental Flow
G = Lead-Free Package
Temperature Range (°C)
S = Standard, 0 to 70
E = Extended, –40 to +105
Speed
020 = 20 MHz
Pin Count
H = 20
J = 28
Package
H = SSOP
P = PDIP
S = SOIC
Device Type
22 = 19 I/O lines, 5 ADC channels, one SPI
21 = 11 I/O lines, 2 ADC channels, no SPI
12 = 19 I/O lines, no ADC channels, one SPI
11 = 11 I/O lines, no ADC channels, no SPI
Memory Size
08 = 8 KB Flash, 1 KB RAM
04 = 4 KB Flash, 1 KB RAM
Memory Type
F = Flash
Device Family
Z8 = Zilog’s 8-Bit Microcontroller
225
Bit 7 6 5 4 3 2 1 0
Field TH
RESET 0
R/W R/W
Address F00H, F08H
226
Bit 7 6 5 4 3 2 1 0
Field TL
RESET 0 1
R/W R/W
Address F01H, F09H
Bit 7 6 5 4 3 2 1 0
Field TRH
RESET 1
R/W R/W
Address F02H, F0AH
Bit 7 6 5 4 3 2 1 0
Field TRL
RESET 1
R/W R/W
Address F03H, F0BH
227
Bit 7 6 5 4 3 2 1 0
Field PWMH
RESET 0
R/W R/W
Address F04H, F0CH
Bit 7 6 5 4 3 2 1 0
Field PWML
RESET 0
R/W R/W
Address F05H, F0DH
Bit 7 6 5 4 3 2 1 0
Field Reserved CSC Reserved
RESET 0
R/W R/W
Address F06H, F0EH, F16H, F1EH
228
Bit 7 6 5 4 3 2 1 0
Field TEN TPOL PRES TMODE
RESET 0
R/W R/W
Address F07H, F0FH
Bit 7 6 5 4 3 2 1 0
Field TH
RESET 0
R/W R/W
Address F00H, F08H
Bit 7 6 5 4 3 2 1 0
Field TL
RESET 0 1
R/W R/W
Address F01H, F09H
Bit 7 6 5 4 3 2 1 0
Field TRH
RESET 1
R/W R/W
Address F02H, F0AH
229
Bit 7 6 5 4 3 2 1 0
Field TRL
RESET 1
R/W R/W
Address F03H, F0BH
Bit 7 6 5 4 3 2 1 0
Field PWMH
RESET 0
R/W R/W
Address F04H, F0CH
Bit 7 6 5 4 3 2 1 0
Field PWML
RESET 0
R/W R/W
Address F05H, F0DH
Bit 7 6 5 4 3 2 1 0
Field Reserved CSC Reserved
RESET 0
R/W R/W
Address F06H, F0EH, F16H, F1EH
230
Bit 7 6 5 4 3 2 1 0
Field TEN TPOL PRES TMODE
RESET 0
R/W R/W
Address F07H, F0FH
Bit 7 6 5 4 3 2 1 0
Field TXD
RESET X X X X X X X X
R/W W W W W W W W W
Address F40H
Bit 7 6 5 4 3 2 1 0
Field RXD
RESET X
R/W R
Address F40H
231
Bit 7 6 5 4 3 2 1 0
Field RDA PE OE FE BRKD TDRE TXE CTS
RESET 0 1 X
R/W R
Address F41H
Bit 7 6 5 4 3 2 1 0
Field TEN REN CTSE PEN PSEL SBRK STOP LBEN
RESET 0
R/W R/W
Address F42H
Bit 7 6 5 4 3 2 1 0
Field MPMD[1] MPEN MPMD[0] MPBT DEPOL BRGCTL RDAIRQ IREN
RESET 0
R/W R/W
Address F43H
Bit 7 6 5 4 3 2 1 0
Field Reserved NEWFRM MPRX
RESET 0
R/W R R/W R
Address F44H
232
Bit 7 6 5 4 3 2 1 0
Field COMP_ADDR
RESET 0
R/W R/W
Address F45H
Bit 7 6 5 4 3 2 1 0
Field BRH
RESET 1
R/W R/W
Address F46H
Bit 7 6 5 4 3 2 1 0
Field BRL
RESET 1
R/W R/W
Address F47H
233
Bit 7 6 5 4 3 2 1 0
Field DATA
RESET 0
R/W R/W
Address F50H
Bit 7 6 5 4 3 2 1 0
Field TDRE RDRF ACK 10B RD TAS DSS NCKI
RESET 1 0
R/W R
Address F51H
Bit 7 6 5 4 3 2 1 0
Field IEN START STOP BIRQ TXI NAK FLUSH FILTEN
RESET 0
R/W R/W R/W R/W R/W R/W R/W W R/W
Address F52H
234
Bit 7 6 5 4 3 2 1 0
Field BRH
RESET FFH
R/W R/W
Address F53H
Bit 7 6 5 4 3 2 1 0
Field BRL
RESET FFH
R/W R/W
Address F54H
Bit 7 6 5 4 3 2 1 0
Field SCLIN SDAIN STPCNT TXRXSTATE
RESET X 0
R/W R
Address F55H
Bit 7 6 5 4 3 2 1 0
Field Reserved DIAG
RESET 0
R/W R R/W
Address F56H
235
Bit 7 6 5 4 3 2 1 0
Field DATA
RESET X
R/W R/W
Address F60H
Bit 7 6 5 4 3 2 1 0
Field IRQE STR BIRQ PHASE CLKPOL WOR MMEN SPIEN
RESET 0
R/W R/W
Address F61H
Bit 7 6 5 4 3 2 1 0
Field IRQ OVR COL ABT Reserved TXST SLAS
RESET 0 1
R/W R/W* R
Address F62H
Note: *R/W = read access; write a 1 to clear the bit to 0.
236
Bit 7 6 5 4 3 2 1 0
Field Reserved DIAG NUMBITS[2:0] SSIO SSV
RESET 0
R/W R R/W
Address F63H
Bit 7 6 5 4 3 2 1 0
Field SCKEN TCKEN SPISTATE
RESET 0
R/W R
Address F64H
Bit 7 6 5 4 3 2 1 0
Field BRH
RESET 1
R/W R/W
Address F66H
237
Bit 7 6 5 4 3 2 1 0
Field BRL
RESET 1
R/W R/W
Address F67H
Bit 7 6 5 4 3 2 1 0
Field CEN Reserved VREF CONT ANAIN[3:0]
RESET 0 1 0
R/W R/W
Address F70H
238
Bit 7 6 5 4 3 2 1 0
Field ADCD_H
RESET X
R/W R
Address F72H
Bit 7 6 5 4 3 2 1 0
Field ADCD_L Reserved
RESET X
R/W R
Address F73H
Bit 7 6 5 4 3 2 1 0
Field Reserved T1I T0I U0RXI U0TXI I2CI SPII ADCI
RESET 0
R/W R/W
Address FC0H
239
Bit 7 6 5 4 3 2 1 0
Field Reserved T1ENH T0ENH U0RENH U0TENH I2CENH SPIENH ADCENH
RESET 0
R/W R/W
Address FC1H
Bit 7 6 5 4 3 2 1 0
Field Reserved T1ENL T0ENL U0RENL U0TENL I2CENL SPIENL ADCENL
RESET 0
R/W R/W
Address FC2H
Bit 7 6 5 4 3 2 1 0
Field PA7I PA6I PA5I PA4I PA3I PA2I PA1I PA0I
RESET 0
R/W R/W
Address FC3H
Bit 7 6 5 4 3 2 1 0
Field PA7ENH PA6ENH PA5ENH PA4ENH PA3ENH PA2ENH PA1ENH PA0ENH
RESET 0
R/W R/W
Address FC4H
240
Bit 7 6 5 4 3 2 1 0
Field PA7ENL PA6ENL PA5ENL PA4ENL PA3ENL PA2ENL PA1ENL PA0ENL
RESET 0
R/W R/W
Address FC5H
Bit 7 6 5 4 3 2 1 0
Field Reserved PC3I PC2I PC1I PC0I
RESET 0
R/W R/W
Address FC6H
Bit 7 6 5 4 3 2 1 0
Field Reserved C3ENH C2ENH C1ENH C0ENH
RESET 0
R/W R/W
Address FC7H
Bit 7 6 5 4 3 2 1 0
Field Reserved C3ENL C2ENL C1ENL C0ENL
RESET 0
R/W R/W
Address FC8H
241
Bit 7 6 5 4 3 2 1 0
Field IRQE Reserved
RESET 0
R/W R/W R
Address FCFH
Bit 7 6 5 4 3 2 1 0
Field PADDR[7:0]
RESET 00H
R/W R/W
Address FD0H, FD4H, FD8H
Bit 7 6 5 4 3 2 1 0
Field PCTL
RESET 00H
R/W R/W
Address FD1H, FD5H, FD9H
242
Bit 7 6 5 4 3 2 1 0
Field PIN7 PIN6 PIN5 PIN4 PIN3 PIN2 PIN1 PIN0
RESET X
R/W R
Address FD2H, FD6H, FDAH
Bit 7 6 5 4 3 2 1 0
Field POUT7 POUT6 POUT5 POUT4 POUT3 POUT2 POUT1 POUT0
RESET 0
R/W R/W
Address FD3H, FD7H, FDBH
Bit 7 6 5 4 3 2 1 0
Field PADDR[7:0]
RESET 00H
R/W R/W
Address FD0H, FD4H, FD8H
Bit 7 6 5 4 3 2 1 0
Field PCTL
RESET 00H
R/W R/W
Address FD1H, FD5H, FD9H
243
Bit 7 6 5 4 3 2 1 0
Field PIN7 PIN6 PIN5 PIN4 PIN3 PIN2 PIN1 PIN0
RESET X
R/W R
Address FD2H, FD6H, FDAH
Bit 7 6 5 4 3 2 1 0
Field POUT7 POUT6 POUT5 POUT4 POUT3 POUT2 POUT1 POUT0
RESET 0
R/W R/W
Address FD3H, FD7H, FDBH
Bit 7 6 5 4 3 2 1 0
Field PADDR[7:0]
RESET 00H
R/W R/W
Address FD0H, FD4H, FD8H
Bit 7 6 5 4 3 2 1 0
Field PCTL
RESET 00H
R/W R/W
Address FD1H, FD5H, FD9H
244
Bit 7 6 5 4 3 2 1 0
Field PIN7 PIN6 PIN5 PIN4 PIN3 PIN2 PIN1 PIN0
RESET X
R/W R
Address FD2H, FD6H, FDAH
Bit 7 6 5 4 3 2 1 0
Field POUT7 POUT6 POUT5 POUT4 POUT3 POUT2 POUT1 POUT0
RESET 0
R/W R/W
Address FD3H, FD7H, FDBH
Bit 7 6 5 4 3 2 1 0
Field POR STOP WDT EXT Reserved
RESET See Table 49 on page 74. 0
R/W R
Address FF0H
245
Bit 7 6 5 4 3 2 1 0
Field WDTU
RESET 1
R/W R/W*
Address FF1H
Note: *R/W = a read returns the current WDT count value; a write sets the appropriate reload value.
Bit 7 6 5 4 3 2 1 0
Field WDTH
RESET 1
R/W R/W*
Address FF2H
Note: *R/W = a read returns the current WDT count value; a write sets the appropriate reload value.
Bit 7 6 5 4 3 2 1 0
Field WDTL
RESET 1
R/W R/W*
Address FF3H
Note: *R/W = a read returns the current WDT count value; a write sets the appropriate reload value.
246
Bit 7 6 5 4 3 2 1 0
Field FCMD
RESET 0
R/W W
Address FF8H
Bit 7 6 5 4 3 2 1 0
Field Reserved FSTAT
RESET 0
R/W R
Address FF8H
Bit 7 6 5 4 3 2 1 0
Field INFO_EN PAGE
RESET 0
R/W R/W
Address FF9H
247
Bit 7 6 5 4 3 2 1 0
Field SECT7 SECT6 SECT5 SECT4 SECT3 SECT2 SECT1 SECT0
RESET 0
R/W R/W*
Address FF9H
Note: *R/W = this register is accessible for read operations, but can only be written to 1 (via user code).
Bit 7 6 5 4 3 2 1 0
Field FFREQH
RESET 0
R/W R/W
Address FFAH
Bit 7 6 5 4 3 2 1 0
Field FFREQL
RESET 0
R/W R/W
Address FFBH
248
Index
Numerics BCLR 205
10-bit ADC 4 binary number suffix 202
BIT 205
bit 201
A clear 205
manipulation instructions 205
absolute maximum ratings 176
set 205
AC characteristics 185
set or clear 205
ADC 204
swap 205, 208
architecture 136
test and jump 207
automatic power-down 137
test and jump if non-zero 207
block diagram 137
test and jump if zero 207
continuous conversion 138
block diagram 3
control register 139
block transfer instructions 205
control register definitions 139
BRK 207
data high byte register 141
BSET 205
data low bits register 142
BSWAP 205, 208
electrical characteristics and timing 190
BTJ 207
operation 137
BTJNZ 207
single-shot conversion 137
BTJZ 207
ADCCTL register 139
ADCDH register 141
ADCDL register 142
ADCX 204
C
ADD 204 CALL procedure 207
additional symbols 202 capture mode 68
address space 14 capture/compare mode 69
ADDX 204 cc 201
analog signals 11 CCF 206
analog-to-digital converter (ADC) 136 characteristics, electrical 176
AND 207 clear 206
ANDX 207 clock phase (SPI) 104
arithmetic instructions 204 CLR 206
assembly language programming 199 COM 207
assembly language syntax 200 compare 68
compare - extended addressing 204
compare mode 68
B compare with carry 204
compare with carry - extended addressing 204
B 202
complement 207
b 201
complement carry flag 205, 206
baud rate generator, UART 88
249
250
251
252
253
254
255
rotate right through carry 208 single master, multiple slave system 102
RP 202 single master, single slave system 101
RR 202, 208 status register 111
rr 202 timing, PHASE = 0 105
RRC 208 timing, PHASE=1 106
SPI controller signals 10
SPI mode (SPIMODE) 112, 236
S SPIBRH register 114, 236
SBC 205 SPIBRL register 114, 237
SCF 205, 206 SPICTL register 110, 235
SCK 103 SPIDATA register 109, 235
SDA and SCL (IrDA) signals 117 SPIMODE register 112, 236
second opcode map after 1FH 220 SPISTAT register 111, 235
serial clock 104 SRA 208
serial peripheral interface (SPI) 101 src 202
set carry flag 205, 206 SRL 208
set register pointer 206 SRP 206
shift right arithmetic 208 SS, SPI signal 103
shift right logical 208 stack pointer 202
signal descriptions 10 status register, I2C 129
single-shot conversion (ADC) 137 STOP 206
SIO 5 stop mode 27, 206
slave data transfer formats (I2C) 123 stop mode recovery
slave select 104 sources 25
software trap 207 using a GPIO port pin transition 26
source operand 202 using watch-dog timer time-out 26
SP 202 SUB 205
SPI subtract 205
architecture 101 subtract - extended addressing 205
baud rate generator 108 subtract with carry 205
baud rate high and low byte register 114 subtract with carry - extended addressing 205
clock phase 104 SUBX 205
configured as slave 102 SWAP 208
control register 110 swap nibbles 208
control register definitions 109 symbols, additional 202
data register 109 system and core resets 21
error detection 107
interrupts 108
mode fault error 107 T
mode register 112 TCM 205
multi-master operation 106 TCMX 205
operation 103 test complement under mask 205
overrun error 107 test complement under mask - extended addressing
signals 103 205
256
257
X
X 202
XOR 207
XORX 207
Z
Z8 Encore!
block diagram 3
features 1
introduction 1
part selection guide 2
258
Customer Support
To share comments, get your technical questions answered or report issues you may be
experiencing with our products, please visit Zilog’s Technical Support page at
http://support.zilog.com.
To learn more about this product, find additional documentation or to discover other facets
about Zilog product offerings, please visit the Zilog Knowledge Base at http://zilog.com/
kb or consider participating in the Zilog Forum at http://zilog.com/forum.
This publication is subject to replacement by a later edition. To determine whether a later
edition exists, please visit the Zilog website at http://www.zilog.com.