Home
Develop a Dallas 1 Wire Master Using the Z8F1680 Series of
Contents
1. AN033101 0412 Page 12 of 13 Develop a Dallas 1 Wire Master Using the Z8F1680 Series of MCUs Application Note zilog r GIXYS 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 fac ets 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 AN Warning DO NOT USE THIS PRODUCT IN LIFE SUPPORT SYSTEMS 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
2. see the schematic diagram presented in Figure 1 on page 2 2 Connect the USB to RS 232 cable to the PC and connect the USB Smart Cable to the Z8F1680 Development Board 3 Connect the power cable to apply power to the Z8F1680 Development Board Configure the Software Observe the following procedure to configure the software 1 Open the BAUD_57600 HyperTerminal file located in the AN0331 SCO1 zip file Configure the settings in HyperTerminal to Baud 57600 Data Bits 8 Parity None Stop Bits 1 Flow Control None AN033101 0412 Page 10 of 13 Develop a Dallas 1 Wire Master Using the Z8F1680 Series of MCUs Application Note Zilog AnQAIXYS Con 2 Open ZDSII then navigate via the File menu in ZDSII to open the project file labeled ANO331 Develop 1 Wire interface using Z8F1680 zdsproj gt Note The project is set to an external clock frequency of 20MHz 3 Compile and download the program to the Z8F1680 Development Board 4 You should see the HyperTerminal display shown in Figure 5 the Serial ID may vary depending on the type of 1 Wire device you are using If you do not see this display verify your Configure Target settings in the ZDSII project settings Project Set tings Debugger Setup button to ensure that Clock Source is set to Exter nal and that Clock Frequency MHz is set to 20 00000 232 HyperTerminal File Edit View Call Transfer Help Cae D2 Dev
3. Read Scratchpad to DS18S20 ONEWIRE_Receive The Z8F1680 MCU reads entire scratchpad including the generated CRC byte made by the DS18S20 After the scratchpad data is gathered Byte 0 and Byte 1 which are the LSB and MSB of the temperature data respectively are fetched by the CPU This temperature data is fac tored into an actual temperature reading that is displayed in degrees Centigrade and Fahr enheit AN033101 0412 Page 9 of 13 Develop a Dallas 1 Wire Master Using the Z8F1680 Series of MCUs Application Note zilog AnGIXYs Testing Demonstrating the Application This 1 Wire application is comprised of the following hardware and software elements plus documentation Hardware e USB Smart Cable e USB to RS 232 cable e 4 7KQ resistor labeled R1 in Figure 1 on page 2 e 1 Wire Temperature Sensor DS18S20 e Z8F1680 Development Board with external 20MHz crystal Software e ZDSII version 5 0 0 for Z8 Encore XP MCUs e ANO331 SCO1 zip file containing project and source files e BAUD_57600 HyperTerminal file Documentation Z8 Encore XP F1680 Series 28 Pin Development Kit User Manual UM0203 Connect the Hardware Observe the following procedure to connect all hardware elements 1 Connect the 1 Wire Temperature Sensor DS18S20 to Vcc pin 3 GND pin 5 and DQ 1 Wire bus The DQ pin is connected through a 4 7 KQ pull up resistor to Port C Pin 7 Pin 13 of JP2 of the Z8F1680 Development Board
4. bus see Fig ure 2 e The pull up resistor pulls the data line High at all times e The 1 Wire Master initiates the data line Low for at least 480us and not more than 640s during its reset sequence then sets the data line to open drain or high imped ance e The 1 Wire Slave sets a presence pulse by triggering the data line to Low after 15 60 us from the time the Master sets the data line to open drain e The Master checks the data line for this presence pulse approximately 60 240us from the time the data line is set to open drain e The 1 Wire Slave undergoes a recovery period of at least 1 ps MASTER Tx RESET PULSE MASTER Rx 480us minimum gt lt _ 480us minimum _ 1 WIRE DEVICE Tx lt presence pulse i 60 240 us 1 WIRE DEVICE waits 15 60 us Veu 1 WIRE BUS GND LINE TYPE LEGEND mm Bus master pulling low m WIRE pulling low Resistor pullup Figure 2 Reset Timing Diagram Write 0 The following sequence of events occurs when a WriteO command is issued over the 1 Wire bus see Figure 3 1 The Master writes to bit 0 by pulling the data line Low for at least 60s then releasing the data line as open drain 2 The Master waits for a minimum recovery period of 1 us before sending the next bit Write 1 The following sequence of events occurs when a Writel command is issued over the 1 Wire bus see Figure 3 AN033101 0412 Page 3 o
5. functions to systems where interconnects must be minimized For more information about the Maxim Dallas 1 Wire Interface visit http www maxim ic com products 1 wire The 1 Wire bus employs a single wire data line to receive and transmit data its architec ture requires a pull up resistor to pull up the voltage on the data line at the Master side This pull up resistor is used to power the 1 Wire device during idle time The 1 Wire bus also communicates via half duplex transmission in which the Master and Slave can transmit and receive commands one at a time the Master initiates and controls all 1 Wire operations The 1 Wire bus operates in a three phase transaction scenario which includes a reset sequence an 8 bit ROM command sequence and an 8 bit function command sequence Additionally the 1 Wire bus uses conventional CMOS TTL logic and operates at 2 8 V to 6 0V 1 The 1 Wire protocol is a registered trademark of Maxim Dallas Semiconductor AN033101 0412 Page 1 of 13 Develop a Dallas 1 Wire Master Using the Z8F1680 Series of MCUs Application Note zilog AnGIXYS Theory of Operation The 1 Wire bus protocol is called Wire because it only uses one data line to send and receive data from the 1 Wire device Communication between the Z8F1680 MCU and the 1 Wire device is set up in a Master Slave interface The 1 Wire Bus Connection to the Z8F1680 Series MCU The entire Z8 Encore XP Family of MCUs can interface as m
6. 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 2012 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 ZMOTION are trademarks or registered trademarks of Zilog Inc All other product or service names are the property of their respective owners AN033101 0412 Page 13 of 13
7. value as follows reloadValue 4 20 000 000 Hz imsec reloadValue 5000 or 0x1388 Timer e Required time interval 10 4 us e Prescale 4 e Mode CONTINUOUS e Timer Clock Frequency 20MHz Using the same equation used to calculate for Timer0 we can calculate the Timer reload value reloadValue 4 20 000 000 Hz 10 4usec reloadValue 52 or 0x34 gt Note Additional delay time can be factored in with an assembly instruction called NOP asm nop The NOP instruction is used as a special delay mechanism to achieve a 1 Wire timing requirement of less than 10 4us the Z8F1680 MCU s timer is not able to pro vide this delay time However a NOP instruction requires only 1 instruction cycle to com plete and meets this 1 Wire timing restriction Reset Function The Master initiates communication via a system reset function i e Reset In this Reset function the Master sets the port pin to output and sets the data line to Low for at least 480us then releases the data line sets it to input and 15 60us after it releases the data line the Master checks the data line for a presence pulse from the 1 Wire device The presence pulse is used to determine if a 1 Wire device is present This presence pulse exists if the data line is pulled down by the 1 Wire device between 60 240us after the Master has released the data line as open drain AN033101 0412 Page 6 of 13 Develop a Dallas 1 Wire Master Using th
8. 0 Vpu 1 WIRE BUS GND Master samples 15us LINE TYPE LEGEND m Bus master pulling low mu 1 WIRE pulling low Resistor pullup Figure 4 Read Timing Diagram Software Implementation 1 Wire communication consists of a three phase operation sequence that includes a Reset sequence a ROM sequence and a function sequence The Write 0 Write 1 and Read bits are the basic building blocks of the ROM and function command sequences All timing requirements for the Maxim Dallas 1 Wire bus are catered by the Z8F1680 MCU s timers via interrupts An API library has been created with the 1 Wire function this library can be modified by the user depending on the GPIO pin to be used with the 1 Wire interface There are items to consider regarding the usage of Timer0 and Timer to meet the timing requirement range imposed by the Maxim Dallas 1 Wire protocol as the following dis cussion shows TimerO e Required time interval 1 ms e Prescale 4 e Mode CONTINUOUS Timer Clock Frequency 20MHz The equation below calculates the required CONTINUOUS Mode time out interval reloadValue prescale TimerClockFrequency Hz CONTINUOUS _Mode_Time Out_Period s AN033101 0412 Page 5 of 13 Develop a Dallas 1 Wire Master Using the Z8F1680 Series of MCUs Application Note zilog AnGIXys Plugging these values into the above equation to achieve a CONTINUOUS Mode time out interval of 1 ms solves for the Timer0 reload
9. Application Note Z l 0g Develop a Dallas 1 Wire Master ank chile Using the Z8F1680 Series of AnEI LX YS Company Abstract gt Note MCUs AN033101 0412 This Application Note describes how to interface the Dallas 1 Wire bus with Zilog s Z8F1680 Series of MCUs as master devices The Z8F0880 Z8F1680 and Z8F2480 devices that comprise Zilog s Z8F1680 Series features multiple general purpose input and output pins which can be easily configured to interface to the Maxim Dallas Semiconduc tor 1 Wire device Because there is no hardware support for the 1 Wire protocol the Z8F1680 MCU can communicate over the 1 Wire bus via software control i e bit bang ing For this application a DS18S20 temperature sensor is used as a demonstration of the 1 Wire protocol through a single slave configuration The source code file associated with this application note ANO331 SCO1 zip is available free for download from the Zilog website This source code has been tested with version 5 0 0 of Zilog Developer Studio ZDSID for Z8 Encore XP MCUs Subsequent releases of ZDSII may require you to modify the code supplied with this application Overview of the 1 Wire Bus gt Note 1 Wire products provide a combination of memory mixed signal and secure authentica tion functions via a single contact serial interface With both power and communication delivered via serial protocol 1 Wire devices are unmatched in their ability to provide key
10. asters with the 1 Wire bus interface the 1 Wire device can be connected as a slave to any of the general purpose input output Z8 Encore XP MCU pins The DS18S20 temperature sensor can be powered by an external supply on the Vcc pin or it can operate under parasite power which allows the DS18S20 to function without an external supply However parasite power is not recommended for use under extreme high temperatures due to potentially unstable communications resulting from high leakage currents that could occur The advantage of a conventional power supply method over the parasite power method is that an external MOSFET pull up is not required As a result the 1 Wire bus is free from transaction overhead associated with the use of parasite power Figure 1 shows a sche matic diagram of the 1 Wire bus with an external pull up resistor that is used to pull the data line to logic High using an external power supply VCC Z8F1680 GND Figure 1 Schematic Diagram of the 1 Wire Interface with a Z8F1680 Series MCU Discussion 1 Wire Bus Operation The 1 Wire bus consists of four basic operations Reset Write 0 Bit Write 1 Bit and Read Bit This section discusses these four operations wherein the activity of the 1 Wire proto col occurs AN033101 0412 Page 2 of 13 Develop a Dallas 1 Wire Master Using the Z8F1680 Series of MCUs Application Note zilog f IXYS Reset The following events occur when a Reset command is issued over the 1 Wire
11. e Z8F1680 Series of MCUs Application Note zilog AnEHIXYS The following routine resets all 1 Wire devices void Reset_Function void output_TX initialize ports as OUTPUT ONEWIRE_OUT ONEWIRE_PIN Pull Low delay_us TIME_480to0640us delay 480yus Rx input_RX initialize ports as INPUT and presence pulse will appear delay_us TIME_470us vest of 480 us slot Tx Write 0 Function In the routine that follows the Master sets the port pin to output and pulls the data line by sending logic Low within 60 120us The port pin is next set to input to release the data line a recovery period of 11s ensues on the 1 Wire device void Write _Zero_Bit void output_TX set port to OUTPUT ONEWIRE_OUT ONEWIRE_PIN LOGIC LOW delay_us TIME_60to0120s time slot at 60 120ns input_RX pull up release SET AS INPUT to draw pull up delay_us TIME_RECOVERY recovery time from lps to infinity Write 1 Function In the following routine the Master sets the port pin to output and pulls the data line by sending a logic Low within 15us Next the port pin is set to input to release the data line of the 1 Wire device void Write _One_Bit void output_TX set port output ONEWIRE_OUT ONEWIRE_PIN pull logic low asm nop delay withi
12. f 13 Develop a Dallas 1 Wire Master Using the Z8F1680 Series of MCUs Application Note zilog AnBIIXYS 1 The Master writes to bit 1 by pulling the data line Low within 15s then releasing it by setting the data line to open drain 2 The Master waits for a minimum recovery period of 1 us before sending the next bit START START OF SLOT OF SLOT MASTER WRITE 1 SLOT Aus lt Trec lt MASTER WRITE 0 SLOT 60us lt Ty 0 lt 120us gt I Sips Vpu 1 WIRE BUS GND Samples Samples MIN MIN i 15ps lt 15us 30us 15us 15us 30us LINE TYPE LEGEND mum Bus master pulling low E 1 WIRE pulling low Resistor pullup Figure 3 Write Timing Diagram Read The following sequence of events occurs when a Read command is issued over the 1 Wire bus 1 The Master pulls the data line Low for at least 1 us then releases the bus 2 After releasing the data line the Master waits for a period of 15s then checks the data line 3 The Master reads logic 0 if the data line is Low within 15s otherwise the Master reads logic 1 if the data line is High A read write timing diagram of these events is shown in Figure 4 AN033101 0412 Page 4 of 13 Develop a Dallas 1 Wire Master Using the Z8F1680 Series of MCUs Application Note zilog AnGIXYS MASTER READ 0 SLOT MASTER READ 1 SLOT tus lt Trec lt
13. ice Serial ID 0x10 0x58 Oxd Ox3P 0x12 0x8 0x0 Oxee Device is DS 18820 1 Wire Temperature Sensor TempC 26 degrees C ii TempF 78 degrees F 57600 8 N 1 Figure 5 1 Wire Interface Output to HyperTerminal Results The temperature readings as displayed in HyperTerminal indicate that the firmware developed for the Z8F1680 and DS18S20 devices satisfies the the timing requirements of the 1 Wire interface The Device ID of the 1 Wire temperature sensor is detected and dis played as well AN033101 0412 Page 11 of 13 Develop a Dallas 1 Wire Master Using the Z8F1680 Series of MCUs Application Note zilog AnQAIXYS Con Summary This application note discusses the implementation of a Dallas 1 Wire interface using Zilog s Z8F1680 Series microcontrollers The application passes the timing requirements of the 1 Wire interface and successfully implements the 1 Wire interface with a 1 Wire temperature sensor The firmware described herein can be used with other types of 1 Wire devices which can be determined by means of identifying a device s family code References The following document describes the functional specifications of the Z8F1680 MCU which is a member of Zilog s Z8 Encore XP Series of MCUs e Z8 Encore XP F1680 Series Product Specification PS0250 The following documents can be found on http www maxim ic com e 1 Wire Devices e 1 Wire Tutorial e 1 Wire Parasite Power Digital Thermometer
14. n 1 15ys input_RX pull up release delay_us TIME_RECOVERY recovery time Read Function In this routine the Master sets the port pin to output and pulls the data line by sending a logic Low for a minimum of 1 us then releasing the bus The 1 Wire device begins trans mitting a 1 or 0 on the bus AN033101 0412 Page 7 of 13 Develop a Dallas 1 Wire Master Using the Z8F1680 Series of MCUs Application Note zilog AnGIXYS UINT8 Read_Bit void output_TX set as output to pull logic Low ONEWIRE_OUT amp ONEWIRE_PIN asm nop input_RX set as input for pull up asm nop if ONEWIRE_IN amp ONEWIRE_PIN checks the bits of data if the data is in the specified bus return 1 reads as 1 else return 0 reads as 0 Transmit Byte Function In the following routine the transmit byte function is used to transmit a byte of data to the 1 Wire device These 8 bits of data are interpreted as WriteO and Writel with the least significant bit sent first void onewire_CMD UINTS8 data UINT8 i 0 for i 0 1 lt 8 1i if data amp 0x01 lt lt i check every bit to send to DS18S20 Write_One_Bit write 1 into 1 Wire device else Write_Zero_Bit write 0 into 1 Wire device J Receive Byte Function In the routine that follows the received byte function interprets the received bit
15. s of data on the data line This function is also used as an indicator of the maximum number of bytes that the device is expected to receive AN033101 0412 Page 8 of 13 Develop a Dallas 1 Wire Master Using the Z8F1680 Series of MCUs Application Note zilog AnGIXYs UINT8 ONEWIRE_Receive void UINT UINT UINT 8 value 0 8 i 0 8 bit 0 i 0 i lt 8 i receives the data byte 8 bits bit read_bit if bit value 1 lt lt i delay_us TIME_50to60us 50ys delay for data integrity return value DS18S20 Temperature Sensor Operation with the 1 Wire Device The 1 Wire interface application focuses on the void Read_Temperature void function With this function the DS18S20 sensor follows a transaction sequence i e the Reset ROM and Function sequences of the 1 Wire interface as indicated in Table 1 Table 1 DS18S20 Temperature Sensor Functions Function Description Reset_Function The Z8F1680 MCU issues reset pulse and check if DS18S20 responds with a presence pulse onewire_CMD SKIP_ROM The Z8F1680 MCU issues Skip ROM command to DS18S820 onewire_CMD CONVERT_T The Z8F1680 MCU issues Convert T command in which DS18S20 converts temperature Reset_Function The Z8F1680 MCU issues reset pulse onewire_CMD SKIP_ROM The Z8F1680 MCU issues Skip ROM Command onewire_CMD RD_SCRPAD The Z8F1680 MCU issues
Download Pdf Manuals
Related Search
Related Contents
Genius LuxePad A110 Pro Tools DigiRack-Plug-Ins-Handbuch EasyAVR6 Manual de usuario Puritan Bennett Hilti 3490200 Use and Care Manual Fluke PM3370B Hunting Equipment User Manual unimax 1010 / promax 1020 duomax 1030 / polymax 1040 FICHA DE DATOS DE SEGURIDAD (REACH) LinRS Interface Copyright © All rights reserved.
Failed to retrieve file