An SPI Temperature Sensor Interface with the Z8 Encore! SPI Bus

Similar documents
Getting Started with ESPI Interface Using the Z8 Encore! XP F1680

Using the Z8051 MCU s USI Peripheral as an SPI Interface

High Resolution Digital Weigh-Scale Design Using Z8 Encore! Microcontrollers

EEPROM Emulation with the ez80f91 MCU. Discussion

Interfacing Z8 Encore! XP MCUs with an I 2 C-Based Character LCD

Real Time Embedded Systems. Lecture 1 January 17, 2012

Challenge. Hardware Circuit Details. Solution. Result. Features and Functions. Z8 Encore! MC

Flash Loader Utility for the Z8 Encore! XP MCU

Lecture 14 Serial Peripheral Interface

PIN ASSIGNMENT PIN DESCRIPTION

Z8 Encore! XP F0822 Series

Boot Loader for the Z51F6412 MCU

Z8 Encore! XP F1680 Series 8-Bit Flash Solution with Extended Peripherals

An Automatic Temperature Control System Using RZK

Character LCD Interface for ez80acclaim! MCUs

S3 Flash In-System Programmer

A Simple Console Application for Z8 Encore! XP MCUs

Zilog Real-Time Kernel

Universal Motor Control with Z8 Encore! XP 8-Pin Highly Integrated Microcontroller

5x7 LED Matrix Display with Z8 Encore! XP

High-Performance 8-Bit Microcontrollers. Up to 8 10-Bit ADC Channels. Two 16-Bit Timers/PWM. Internal Precision Oscillator

Microcontrollers and Interfacing

Z8 Encore! XP 4K Series with extended Peripherals

Introduction the Serial Communications Huang Sections 9.2, 10.2 SCI Block User Guide SPI Block User Guide

C8051F700 Serial Peripheral Interface (SPI) Overview

Design and development of embedded systems for the Internet of Things (IoT) Fabio Angeletti Fabrizio Gattuso

< W3150A+ / W5100 Application Note for SPI >

ZLF645 Crimzon Flash Microcontroller with ZBase Database Industry Leading Universal Infrared Remote Control (UIR) Solution

Set Up a PLL Loop Filter on the ez80f91 MCU

Serial Peripheral Interface (SPI) Host Controller Data Sheet

Zatara Series ARM ASSP High-Performance 32-bit Solution for Secure Transactions

Serial Communication Controllers (SCC) MULTIPROTOCOL DATA COMMUNICATION SOLUTIONS

Digital Thermometers and Thermostats with SPI/3-Wire Interface

Application Note, V1.0, Jul AP XC16x. Interfacing the XC16x Microcontroller to a Serial SPI EEPROM. Microcontrollers

AN10428 UART-SPI Gateway for Philips SPI slave bridges

UART TO SPI SPECIFICATION

OUTLINE. SPI Theory SPI Implementation STM32F0 SPI Resources System Overview Registers SPI Application Initialization Interface Examples

Section 5 SERCOM. Tasks SPI. In this section you will learn:

AN510 Using SPI protocol with pressure sensor modules

Universität Dortmund. IO and Peripheral Interfaces

spi 1 Fri Oct 13 13:04:

Product Update. Errata to Z8 Encore! 8K Series Silicon. Z8 Encore! 8K Series Silicon with Date Codes 0402 and Later

Interfacing Techniques in Embedded Systems

Embedded Systems and Software. Serial Interconnect Buses I 2 C (SMB) and SPI

Implementing a Secure Digital Card with a ZNEO Microcontroller

SPI Overview and Operation

EE 456 Fall, Table 1 SPI bus signals. Figure 1 SPI Bus exchange of information between a master and a slave.

M68HC08 Microcontroller The MC68HC908GP32. General Description. MCU Block Diagram CPU08 1

LABORATORIO DI ARCHITETTURE E PROGRAMMAZIONE DEI SISTEMI ELETTRONICI INDUSTRIALI. Laboratory Lesson 9: Serial Peripheral Interface (SPI)

Emulating Dual SPI Using FlexIO

Introduction to I2C & SPI. Chapter 22

MOS INTEGRATED CIRCUIT

Z8 Encore! XP/Z8 Encore! Development Kits

Serial Communication. Simplex Half-Duplex Duplex

SPI Block User Guide V02.07

RL78 Serial interfaces

PARALLEL COMMUNICATIONS

XE166 Family AP Application Note. Microcontrollers. X E D r i v e C a r d H a r d w a r e D e s c r i p t i o n Board REV.

EDBG. Description. Programmers and Debuggers USER GUIDE

Section 16. Basic Sychronous Serial Port (BSSP)

± 2g Tri-axis Accelerometer Specifications

Module 3.C. Serial Peripheral Interface (SPI) Tim Rogers 2017

(Serial Periphrial Interface (SPI) Synchronous Bus)

Digital UART Product Specification

USER GUIDE EDBG. Description

Serial Peripheral Interface. What is it? Basic SPI. Capabilities. Protocol. Pros and Cons. Uses

Microcontrollers and Interfacing week 10 exercises

Z8 Encore! XP F0822 Series Development Kit

An SPI interface for the 65(C)02 family of microprocessors

Amarjeet Singh. January 30, 2012

PIC Serial Peripheral Interface (SPI) to Digital Pot

Environmental Data Acquisition Using (ENC28J60)

DS1306. Serial Alarm Real Time Clock (RTC)

Ethernet Smart Cable

ZigBee Compliant Platform 2.4G RF Low Power Transceiver Module for IEEE Standard. DATA SHEET Version B

AN2737 Application note Basic in-application programming example using the STM8 I 2 C and SPI peripherals Introduction

DS75 Digital Thermometer and Thermostat

Digital Thermometer and Thermostat

BOOST YOUR SYSTEM PERFORMANCE USING THE ZILOG ESCC CONTROLLER

XC2000 Family AP Application Note. Microcontrollers. XC2236N Drive Card Description V1.0,

Raspberry Pi - I/O Interfaces

HZX N03 Bluetooth 4.0 Low Energy Module Datasheet

Ethernet1 Xplained Pro

ZCRMZNICE01ZEMG Crimzon In-Circuit Emulator

DS1305EN. Serial Alarm Real-Time Clock

Arduino Uno R3 INTRODUCTION

ORDERING INFORMATION. OPERATION Measuring Temperature A block diagram of the DS1621 is shown in Figure 1. DESCRIPTION ORDERING PACKAGE

Serial Communication

DS Wire Digital Thermometer and Thermostat

ECE Microcontrollers. Serial Peripheral Interface (SPI) & NRF24 Radio

ZiLOG Real-Time Kernel Version 1.2.0

DEVBOARD3 DATASHEET. 10Mbits Ethernet & SD card Development Board PIC18F67J60 MICROCHIP

SPI Protocol of the TLE941xy family

CapSense I 2 C/SPI Timer Flash RAM

Software Serial Port Implemented with the PCA

SPI Universal Serial Communication Interface SPI Mode

AN5123 Application note

Serial Communication. Spring, 2018 Prof. Jungkeun Park

User-configurable Resolution. 9 to 12 bits (0.5 C to C)

IV B.Tech. I Sem (R13) ECE : Embedded Systems : UNIT -4 1 UNIT 4

Transcription:

Application Note An SPI Temperature Sensor Interface with the Z8 Encore! SPI Bus AN012703-0608 Abstract This Application Note provides an overview of Zilog s Z8 Encore! Serial Peripheral Interface (SPI) controller along with a method to interface the Z8 Encore! MCU with an SPI temperature sensor. The SPI-compatible devices such as EEPROMs, Analog-to-Digital Converters (ADC) and Temperature Sensors are widely used in the industry. The Z8 Encore! MCU family features a comprehensive set of peripherals, including an SPI controller that helps reduce the external component requirement and product cost. Note: The source code file AN0127- SC01.zip associated with this Application Note is available for download at www.zilog.com. Z8 Encore! Flash MCU Overview Z8 Encore! products are based on Zilog s ez8 TM CPU and introduce Flash Memory to Zilog s extensive line of 8-bit microcontrollers. Flash Memory in-circuit programming capability allows for faster development time and program changes in the field. The high-performance register-toregister based architecture of the ez8 core maintains backward compatibility with Z8 MCU. Featuring ez8 CPU, the new Z8 Encore! microcontrollers combine a 20 MHz core with Flash Memory, linear-register SRAM, and an extensive array of on-chip peripherals. These peripherals make the Z8 Encore! MCU suitable for various applications including motor control, security systems, home appliances, personal electronic devices, and sensors. Discussion A brief description of the SPI bus, SPI Controller and the SPI temperature sensor is provided below: SPI Bus Overview Z8 Encore! SPI Controller DS1722 Temperature Sensor Overview SPI Bus Overview The SPI is a synchronous interface allowing several SPI-type devices to be interconnected. In an SPI environment, there is always at least one device designated as the SPI master while the other SPI-type devices are designated as slave SPI devices. The SPI master device initiates and performs the required data transfers with a slave device. A slave device cannot initiate an SPI transfer (using the SPI control signals) and must be addressed by the master to enable it to communicate. The SPI master generates the SPI clock required for each transfer (1 data bit shifts in/out for each clock period). The master device also selects the slave device for communication. The data transfer mode is a fullduplex mode. SPI Bus Operation SPI is a full duplex, synchronous, characteroriented channel that supports a four-wire interface (serial clock, transmit, receive, and slave select). The SPI block consists of a transmitter and receiver section, a Baud Rate (clock) Generator (BRG) and a control unit. The transmitter and the receiver sections use the same clock. Copyright 2008 by Zilog, Inc. All rights reserved. www.zilog.com

During an SPI transfer, both the master and the slave SPI devices send and receive data simultaneously. The data and the serial clock require separate signals. When an SPI transfer occurs, a multi-bit (typically 8-bit) character is shifted out, on one data pin and a multi-bit 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 transmit and receive data on the SPI interface. The SPI shift register is a single byte register in both the transmit and receive directions. New data to be transmitted cannot be written into the shift register until the previous transmission is complete, and the received data (if valid) is read. SPI Signals The four basic SPI signals are: MISO (Master-In/Slave-Out) MOSI (Master-Out/Slave-In) SCK (SPI Serial Clock) SS (Slave Select) For detailed description on SPI signals, refer to the appropriate document. Z8 Encore! SPI Controller Features of the Z8 Encore! SPI Controller include: Full-duplex, synchronous, character-oriented communication Four wire interface Data transfer rates up to a maximum of one-fourth the system clock frequency Error detection Write and mode collision detection Dedicated Baud Rate Generator (BRG) DS1722 Temperature Sensor Overview The DS1722 Digital Thermometer (referred to as Temperature Sensor in this document) with an SPI Interface provides temperature readings that indicate the temperature of the device. No additional components are required. The device is a temperature-to-digital converter. Temperature readings are communicated from the DS1722 Temperature Sensor over an SPI interface. For applications that require greater temperature resolution, you can adjust the readout resolution from 8 to 12 bits by changing bits R2, R1, and R0 in the configuration or status register (see Configuration Register Programming on page 3). The DS1722 Temperature Sensor consists of four major components: Precision thermometer Analog-to-Digital Converter SPI/3-wire interface electronics Data registers The DS1722 Temperature Sensor requires no external components. After power-up, you can alter the configuration register to place the device in a continuous temperature conversion mode or in a one-shot conversion mode. In the continuous conversion mode, the DS1722 Temperature Sensor continuously converts the temperature and stores the result in the temperature register. As conversions are performed in the background, reading the temperature register does not affect the conversion that is in progress. In the one-shot temperature conversion mode, the DS1722 Temperature Sensor performs a single temperature conversion, stores the result in the temperature register and returns to the shutdown state. This conversion mode is ideal for powersensitive applications. AN012703-0608 Page 2 of 18

The temperature conversion results have a default resolution of 9 bits. In applications where small incremental temperature changes are critical, you can change the conversion resolution from 9 bits to 10 bits, 11 bits, or 12 bits, all of which can be accomplished by programming the Configuration register. Each additional bit of resolution approximately doubles the conversion time. 1 2 3 4 V DDD CE SCLK GND V DDA SER MODE SDI SDO 5 6 7 8 Pin Description SERMODE - Serial Interface Mode CE - Chip Enable SCLK - Serial Clock GND - Ground V DDA - Analog Supply Voltage SDO - Serial Data Out SDI - Serial Data In V DDD - Digital Supply Voltage Figure 1. Pin Assignment for DS1722 Configuration Register Programming The Configuration register is accessed in the DS1722 at address 00h for a read operation and at address 80h for a write operation. During SPI communication, data is first read from or written to the Configuration register. Table 1 displays the format of the Configuration register. SD is the shutdown bit and 1SHOT is the one shot/continuous temperature conversion bit. The entire register is volatile, and it powers-up in the default state. R0, R1, and R2 (see Table 2) are thermometer resolution bits. Table 1. Configuration/Status Register 1 1 1 1SHOT R2 R1 R0 SD MSB LSB Table 2. Thermometer Resolution Configuration R2 R1 R0 Thermometer Resolution Maximum Conversion Time 0 0 0 8-bit 0.075s 0 0 1 9-bit 0.15s 0 1 0 10-bit 0.3s 0 1 1 11-bit 0.6s 1 X X 12-bit 1.2s AN012703-0608 Page 3 of 18

Register Address Structure of DS1722 The area of interest in programming the DS1722 is the Configuration register. The programming is performed through the SPI communication interface by selecting the appropriate address of the desired register location. Table 3 lists the addresses for configuration and temperature registers. Table 3. Address Structure Read Address Write Address Active Register 00h 80h Configuration 01h No Access Temperature LSB 02h No Access Temperature MSB Z8 Encore! Interface to DS1722 Temperature Sensor Figure 2 displays the hardware setup of the Z8 Encore! MCU with DS1722 Temperature Sensor. In this setup, the microcontroller [MCU- Z8F6403] is the master device and the DS1722 Temperature Sensor is the slave device. Z8 Encore! SPI Device Driver The device driver software implementation provided here demonstrates the SPI capability of Z8 Encore! MCU. The main operations performed by the SPI device driver include: Initializing the SPI Port Writing Data to the Port, and Reading Data from the SPI Port MCU-Z8F6403 PC2/SS PC4 / MOSI PC5 / MISO PC3 / SCK 2 6 5 3 Thermometer DS1722 CE SDI SDO SCLK Figure 2. Z8 Encore! SPI Bus as Master in a Single Master, Single Slave System Interfacing SPI Temperature Sensor with Z8 Encore! MCU The hardware interfacing details and the device driver software implementation are provided in the following sections: Z8 Encore! Interface to DS1722 Temperature Sensor Z8 Encore! SPI Device Driver The Temperature Sensor specific operations include: Initializing the Temperature Sensor Reading from the Temperature Sensor The source code allows temperature readings from the sensor in the standalone mode displayed in Figure 3 on page 10. The actual write or read APIs can be easily exported into any user application. AN012703-0608 Page 4 of 18

Table 4. Register bits used for initialization of SPI Port Register Name Bit Name Explanation SPICTL PHASE; CLKPOL PHASE bit is set to 1 and Clock Polarity (CLKPOL) bit is set to 0 to select data transmission on the rising edge and data reception on the falling edge of the clock. MMEN MMEN bit is set to enable the SPI controller to Master mode. SPIEN SPIEN bit is set to enable the SPI bus. SPIMODE SSIO SSIO bit is set to 1 to configure the SS pin as an output (for Master mode only) SPIBRH SPIBRL BRH BRL BRH bit is set to 0 and BRL bit is set to 9C to get the baud rate 59076 bps at 18.432 MHz. For information on the bit fields of the registers, see Z8 Encore! SPI Register Description on page 6. Initializing the SPI Port This routine initializes a specified port (Port C) for SPI function, sets the baud rate and the mode of operation. Table 4 lists the registers and their bit descriptions. Writing Data to the Port This routine describes the data write functionality of the SPI device driver. The data written to the SPI port are either the device register address or the control word for configuring the device. The main functions in the SPI data write operation include: Setting the SSV bit High, enabling the chip select. Writing the address byte into SPI data register. Waiting for buffer to empty. Writing the data byte into SPI data register. Waiting for buffer to empty. Setting the SSV bit LOW to disable the chip select. Reading Data from the SPI Port This routine describes the data read functionality of the SPI device driver. The data that is read from the SPI port is the temperature reading of the device that was addressed by the write operation. The main functions in the SPI data read operation include: Setting the SSV bit High, in the SPI mode register, enabling the chip select. Writing the address byte into SPI data register. Waiting for buffer to empty. Shifting data from Temperature Sensor to SPI data register. Waiting for buffer to empty. Reading the data byte from the SPI data register. Setting the SSV bit Low to disable the chip select. Initializing the Temperature Sensor This routine describes initialization of the Temperature Sensor. Initialization varies from device to device. In this example, the sensor is initialized for 12-Bit ADC resolution and continuous operating mode. AN012703-0608 Page 5 of 18

Reading from the Temperature Sensor This routine is the main routine for reading the temperature from the Temperature Sensor. The three Temperature Sensor APIs are: Temperature Sensor initialization Read SPI Write SPI The Temperature Sensor can convert the data continuously. A timer is set to generate interrupts periodically to read the temperature from the sensor. The temperature reading from the sensor is therefore performed within the timer interrupt routine. SPI Baud Rate High and Low Byte Registers The SPI Baud Rate High and Low Byte registers combine to form a 16-bit reload value, BRG[15:0], for the SPI Baud Rate Generator. The reload value must be greater than or equal to 0002H for proper SPI operation (maximum baud rate is system clock frequency divided by 4). The SPI baud rate is calculated by the following equation: SPI Baud Rate (bits/s) = System Clock Frequency (Hz) 2 x BRG [15:0] Z8 Encore! SPI Register Description The Z8 Encore! SPI registers are briefly described in this section. SPI Control Registers The following registers comprise the SPI control registers and can be custom configured (see Table 5 through Table 10): SPI Data register (SPIDATA) SPI Control register (SPICTL) SPI Status register (SPISTAT) SPI Mode register (SPIMODE) SPI Baud Rate High Byte register (SPIBRH) SPI Baud Rate Low Byte register (SPIBRL) AN012703-0608 Page 6 of 18

Table 5. SPI Data Register (SPIDATA) BITS 7 6 5 4 3 2 1 0 FIELD DATA RESET X X X X X X X X R/W R/W R/W R/W R/W R/W R/W R/W R/W ADDR F60H Bit Position Value (H) Description [7:0] DATA Transmit/receive data Table 6. SPI Control Register (SPICTL) BITS 7 6 5 4 3 2 1 0 FIELD IRQE STR BIRQ PHASE CLKPOL WOR MMEN SPIEN RESET 0 0 0 0 0 0 0 0 R/W R/W R/W R/W R/W R/W R/W R/W R/W ADDR F61H Bit Position Value (H) Description [7] IRQE Interrupt Request Enable [6] STR Start an SPI Interrupt Request [5] BIRQ BRG Timer Interrupt Request [4] PHASE Phase Select [3] CLKPOL Clock Polarity [2] WOR Wire-OR(Open-Drain)Mode Enable [1] MMEN SPI Master Mode Enable [0] SPIEN SPI Enable AN012703-0608 Page 7 of 18

Table 7. SPI Status Register (SPISTAT) BITS 7 6 5 4 3 2 1 0 FIELD IRQ OVR COL Reserved TXST SLAS RESET 0 0 0 0 0 0 R/W R/W* R/W* R/W* R R R ADDR F62H Note: R/W*-Read access. Write 1 to clear the bit to 0. Bit Position Value (H) Description [7] IRQ Interrupt Request [6] OVR Overrun [5] COL Collision [4:2] Reserved These bits are reserved and must be 0 [1] TXST Transmit Status [0] SLAS Slave Select (If SPI is enabled as a Master, this bit is not applicable) Table 8. SPI Mode Register (SPIMODE) BITS 7 6 5 4 3 2 1 0 FIELD RESERVED NUMBITS [2:0] SSIO SSV RESET 0 0 0 0 0 0 R/W R R/W R/W R/W R/W R/W ADDR F63H Bit Position Value (H) Description [7:5] Reserved These bits are reserved and must be 0 [4:2] NUMBITS[2:0] Number of Date Bits to Transfer [1] SSIO Slave Select I/O [0] SSV Slave Select Value (The SSV bit has no effect if SSIO=0 or SPI configured as a Slave) AN012703-0608 Page 8 of 18

Table 9. SPI Baud Rate High Byte Register (SPIBRH) BITS 7 6 5 4 3 2 1 0 FIELD BRH RESET 1 1 1 1 1 1 1 1 R/W R/W R/W R/W R/W R/W R/W R/W R/W ADDR F66H Bit Position Value (H) Description [7:0] BRH SPI Baud Rate High Byte Table 10. SPI Baud Rate Low Byte Register (SPIBRL) BITS 7 6 5 4 3 2 1 0 FIELD BRL RESET 1 1 1 1 1 1 1 1 R/W R/W R/W R/W R/W R/W R/W R/W R/W ADDR F67H Bit Position Value (H) Description [7:0] BRL SPI Baud Rate Low Byte For more details on registers, refer to ez80 CPU User Manual (UM0077). Testing Figure 3 on page 10 displays the setup used to test the SPI Temperature Sensor s device driver functionality. AN012703-0608 Page 9 of 18

Logic State Analyzer 8-Bit 8-Bit CLK Z8F6403 MCU Port G Port E PC2 - SS PC4 - MOSI PC5 - MISO PC3 - SCK SPI Temperature Sensor DS 1722 Figure 3. Test Setup for Z8 Encore! SPI Device Driver The equipment used for testing are listed below: Z8 Encore! Flash Microcontroller Development Kit (Z8ENCORE000ZCO), that contains the ZDS II- Z8 Encore! v4.1.0 Logic state analyzer- HP1661A The Logic State Analyser is used to capture the binary data from the SPI device driver through Ports G and E of the Z8 Encore! MCU. A test program is written to send the data from the device driver to Port G and Port E. To view this program, refer to the software project files. Alternatively, a PC with the HyperTerminal application, connected through the UART port can also be used to capture the test results, with a test program written specifically for the same. Summary This Application Note provides an overview of the SPI bus and the APIs to interface Z8 Encore! SPI (in master mode) with a DS1722 Temperature Sensor in a slave mode. These SPI device driver APIs can also be used with other devices like ADC and EEPROM, with minimum modification. References The documents associated with Z8 Encore!, ez8 CPU, and DS1722 are provided below: ez8 TM CPU User Manual (UM0128) DS1722 Digital Thermometer with SPI/3-Wire Interface (DS1722) Using the SPI device driver software, the temperature readings (binary data) were successfully taken from the DS1722 Temperature Sensor present on the Z8 Encore! Development Board. AN012703-0608 Page 10 of 18

Appendix A Glossary Table 11 lists the definitions for terms and abbreviations used in this Application Note. Table 11. Glossary Terms/Abbreviations API CPU GPIO HEX MCU MISO MOSI SCK SS SPI ZDS Definitions Application Programming Interface Central Processing Unit General-Purpose Input/Output Hexadecimal Microcontroller Unit Master-In/Slave-Out Master-Out/Slave-In SPI Serial Clock Slave Select Serial Peripheral Interface Zilog Developer Studio AN012703-0608 Page 11 of 18

Appendix B Flowcharts This appendix contains the flowcharts for the SPI temperature sensor application described in this Application Note. Figure 4 displays the initialization of SPI Device Driver in which the baud rate 59076 bps is calculated for 18.432 MHz clock speed. START Configure Port C for alternate function to enable the SPI Initialize SPI control register PHASE = 1[rising edge] MODE = MASTER MODE SPIEN = ENABLE SPI Configure SPI mode register bit SSIO as an output Configure the baud rate generator Set BRG = 0x009C [59076 bits/sec] END Figure 4. Z8 Encore! SPI Initialization Routine AN012703-0608 Page 12 of 18

Figure 5 displays the data write routine of the SPI device driver. START Set SSV bit = 1 in SPI MODE Register Write to SPI Data Register (SPI Data=address) Tx buffer empty? NO YES Write to SPI Data Register (SPI Data=data) Tx buffer empty? NO YES Set SSV bit = 0 in SPI MODE Register END Figure 5. SPI Device Driver Write Routine AN012703-0608 Page 13 of 18

Figure 6 displays the data read routine of the SPI device driver. START Set SSV bit = 1 in SPI MODE Register Write to SPI Data Register (SPI Data=address) Tx buffer empty? NO YES Write to SPI Data Register (SPI Data=0x00) Tx buffer empty? NO YES Read from SPI Data Register (Data=SPI Data) Set SSV bit=0 in SPI MODE Register END Figure 6. SPI Device Driver Read Routine AN012703-0608 Page 14 of 18

Figure 7 displays the routine for Temperature Sensor initialization. This routine varies from device to device. Here, the sensor is initialized for 12-bit ADC resolution and continuous operating mode. START Call function to write the control word for 12-bit resolution and continuous ADC operation to SPI slave device END Figure 7. Temperature Sensor Initialization AN012703-0608 Page 15 of 18

Figure 8 displays the flowchart for the routine to read from the temperature sensor. Temperature reading is controlled by the interrupt. START Initialize the SPI controller Initialize the SPI temperature sensor by calling the initialization routine Initialize timer to generate interrupt for reading the temperature NO Interrupt generated? YES Read HIGH data byte from Temperature sensor Read LOW data byte from Temperature sensor Figure 8. Reading from the Temperature Sensor AN012703-0608 Page 16 of 18

Appendix C Examples of Z8 Encore! SPI Bus Operating Modes This appendix displays example for the operating modes which suggest ways to connect the master or slave device with Z8 Encore! MCU. Z8 Encore! can be used in other modes as well. Figure 8 displays SPI of Z8 Encore! configured as master in a Single Master Multiple Slave system. In this mode, the SS pin of SPI interface can be tied to the V CC, and the GPIO pins can be used as a chip select. Multiple sensors can be connected in parallel and the data can be read one at a time by selecting the sensor chip, using the CE signal. PC2 - SS V CC SPI Temp. Sensor DS1722 (Sensor -1) MCU-Z8F603 GPIO - SS1 GPIO - SS2 PC4 - MOSI PC5 - MISO PC3 - SCK SPI Temp. Sensor DS1722 (Sensor -2) Figure 8. SPI configured as a Master in a Single Master, Multiple Slave System Figure 9 displays SPI of Z8 Encore! configured as a slave. The SS pin and CLK pin are used as input pins. PC2 - SS MCU-Z8F6403 PC4 - MOSI PC5 - MISO PC3 - SCK SPI Master Device Figure 9. SPI Configured as a Slave in a Single Master Single Slave System AN012703-0608 Page 17 of 18

Warning: DO NOT USE IN LIFE SUPPORT LIFE SUPPORT POLICY ZILOG'S PRODUCTS ARE NOT AUTHORIZED FOR USE AS CRITICAL COMPONENTS IN LIFE SUPPORT DEVICES OR SYSTEMS WITHOUT THE EXPRESS PRIOR WRITTEN APPROVAL OF THE PRESIDENT AND GENERAL COUNSEL OF ZILOG CORPORATION. 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 critical component is any component in a life support device or system whose failure to perform can be reasonably expected to cause the failure of the life support device or system or to affect its safety or effectiveness. Document Disclaimer 2008 by 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!, and Z8 Encore! XP are registered trademarks of Zilog, Inc. ez8 is a trademark of Zilog, Inc. All other product or service names are the property of their respective owners. AN012703-0608 Page 18 of 18