MAXREFDES9004: C-source Reference for Operating the DS2485 Combined with a DS28E18 from a Cortex-M4 Microcontroller


Reference Design Disclaimer See the  Important Notice and Disclaimer  covering reference designs and other Maxim resources.


The DS2485 is a 1-Wire® master that performs protocol conversion between the I2C master and any attached 1-Wire slaves. For 1-Wire line driving, internal user-adjustable timers relieve the system host processor from generating time-critical 1-Wire waveforms, supporting both standard and overdrive communication speeds. The 1-Wire master has a selectable active or passive 1-Wire pullup. Strong pullup features support 1-Wire power delivery for 1-Wire devices that require additional current such as EEPROM writes or cryptographic operations. The MAXREFDES9004 is a reference design showcasing the DS2485 and its versatility in 1-Wire systems. It includes example design files for connecting an Arm® Cortex®-M4 host microcontroller with the DS2485 to communicate with a remotely connected DS28E18 1-Wire slave. It also includes example C-code firmware for supporting Arm Cortex-M4 microcontrollers that demonstrate how to integrate the DS2485 in software.


  • Dedicated 1-Wire Master for Convenient 1-Wire Processing
  • Up to 100m Remote Communication with Connected 1-Wire Slave Devices
  • C-Code Demonstrates How to Use the DS2485 in Software Including an Example with the DS28E18


A simple, cost-efficient, 1-Wire master is demonstrated using the DS2485 for a simple sensor application using the MAX32660 host microcontroller. This reference design includes the following major components: one each of MAX32660 Cortex-M4 microcontroller, DS2485 1-Wire master, DS28E18 1-Wire to I2C/SPI bridge and an I2C temperature sensor module. This document describes the hardware shown above as well as its supplementing software. It provides a detailed, systematic technical guide to set up and understand the MAXREFDES9004 reference design. The system has been built and tested, details of which follow later in this document.




Download the full circuit schematic.

PCB Layout


Download printed circuit board layout information.

All Design Files


Get the complete set of design files, including datasheet, schematic, PCB, BOM and software files.



Review the bill of materials used to build this design.

Details Section

Details Section

Quick Start Guide

This section includes a list of recommended equipment and instructions on how to set up the Windows®-based PC for the C-Demo software.

Required Equipment

  • PC with a Windows 10, Windows 8, or Windows 7 operating system (64-bit or 32-bit) and a spare USB 2.0 or higher port
  • Low-power Arm Micro Toolchain (Windows)
  • C-Demo software


The reference design is fully assembled and tested. Follow the steps below to set up the demo software:

  1. Download the ARMCortexToolchain.exe file.
  2. In a file viewer (Figure 1), double-click on ARMCortexToolchain.exe to begin the installation.

    File viewerFigure 1. File viewer.

  3. Follow the prompts on the setup wizard (Figure 2) to finish installation.

    Toolchain setup wizardFigure 2. Toolchain setup wizard.

  4. Navigate to the toolchain's install directory, open the Eclipse folder, and run Eclipse.bat to launch the Eclipse IDE, as shown in Figure 3.
  5. Eclipse launch location.Figure 3. Eclipse launch location.

  6. Create a workspace in a desired location, as shown in Figure 4.
  7. Eclipse workspace creationFigure 4. Eclipse workspace creation.

  8. 6) Download MAXREFDES9004 Software and extract the file, in any location, as shown in Figure 5.
  9. C-Demo extractionFigure 5. C-Demo extraction.

  10. In Eclipse, go to File\Import... and select Existing Projects into Workspace under the General folder. Click Next > and then Browse... to open the directory browser. Navigate to the C-demo installation directory. Select the extracted folder containing the example programs and click OK. In the panel, check the checkbox next to the desired projects to import. Check the box labelled Copy projects into workspace and click Finish, as shown in Figure 6.
  11. Importing C-Demo examplesFigure 6. Importing C-Demo examples.

  12. Open up a serial console and connect it to the MAX32660's corresponding serial COM port, as shown in Figure 7.
  13. Opening a serial consoleFigure 7. Opening a serial console.

  14. Select the example program to run under the drop-down box located next to the green 'Run' button, as shown in Figure 8. The output will be displayed onto the serial console as shown in Figure 9.
  15. Running the Read_Temperature demo programFigure 8. Running the Read_Temperature demo program.

    Console output for Read_Temperature demo programFigure 9. Console output for Read_Temperature demo program.

Detailed Description of Hardware

A detailed block diagram of the MAXREFDES9004 hardware is shown in Figure 10. This setup is designed to support multiple DS28E18 1-Wire slaves remotely connected to a DS2485 1-Wire master at distances over 100 meters. For this reference design, a Maxim Integrated® MAX32660 Cortex M4 microcontroller is used to interface with the DS2485 through its I2C peripheral. The MAX32660's I2C port pins, P0_8 and P0_9, are connected to the DS2485's SDA and SCL pins, respectively, each with a 10kΩ external pullup resistor connected to 3.3V. The DS2485 bridges 1-Wire communication with a remote DS28E18 device connected through a 100-meter long CAT5E twisted-pair cable. At the near-end of the cable resides a low-impedance P-channel MOSFET, Q1, which is controlled by the DS2485's GPIO pin and is designed to supply the 1-Wire bus with more current during heavy loads. At the far-end of the long cable resides a DS28E18 connected to a Sensirion SHTC3 I2C temperature and humidity sensor. See App Note 7478: DS28E18 Setup Guide for Remote I2C and SPI Sensors Featuring the DS2485 for more information on setting up the DS28E18 for long-line communication.

MAXREFDES9004 detailed block diagramFigure 10. MAXREFDES9004 detailed block diagram.

Detailed Description of Software

The MAXREFDES9004 software consists of C-code demonstration programs mainly showcasing the DS2485. See Table 1 for a detailed list of available C-programs. The software is supported on the MAXREFDES9004 hardware and includes the firmware and source files for programming an Arm Cortex-M4 processor-based microcontroller like the MAX32660. This C-Demo software utilizes a DS2485 1-Wire and a DS28E18 API for convenient interfacing within the system. The software is compatible with the Maxim toolchain, that can be found in the design resources tab of the MAX32660 and can be directly imported into an Eclipse IDE workspace. See the Quick Start section for details on how to set up the C-Demo software.

Table 1. Demos Overview

Demo Program Description
Read_Temperature Demo program showcasing majority of the DS2485's 1-Wire master features and the reference design hardware from Figure 11. Uses the DS2485-based 1-Wire API and the DS28E18 API to interface with a remote temperature sensor connected to a DS28E18.
One_Wire_Scripting Demo program showcasing the DS2485's 1-Wire scripting feature specifically. Uses the DS2485-based 1-Wire API to interface the DS2485 with a DS28E18 device.

DS2485 API

Table 2 presents a brief overview of the DS2485 API. This API allows the MAX32660 to interface with the DS2485 through I2C and provides access to each of the DS2485's device function commands.

Table 2. DS2485 API Overview

Function Description
DS2485_WriteMemory DS2485 performs a 'Write Memory' command.
DS2485_ReadMemory DS2485 performs a 'Read Memory' command.
DS2485_ReadStatus DS2485 performs a 'Read Status' command.
DS2485_SetI2CAddress DS2485 performs a 'Set I2C Address' command.
DS2485_SetPageProtection DS2485 performs a 'Set Page Protection' command.
DS2485_ReadOneWirePortConfig DS2485 performs a 'Read 1-Wire Port Config' command.
DS2485_WriteOneWirePortConfig DS2485 performs a 'Write 1-Wire Port Config' command.
DS2485_MasterReset DS2485 performs a 'Master Reset' command.
DS2485_OneWireScript DS2485 performs a '1-Wire Script' command.
DS2485_OneWireBlock DS2485 performs a '1-Wire Block' command.
DS2485_OneWireWriteBlock DS2485 performs a '1-Wire Write Block' command.
DS2485_OneWireReadBlock DS2485 performs a '1-Wire Read Block' command.
DS2485_OneWireSearch DS2485 performs a '1-Wire Search' command.
DS2485_FullCommandSequence DS2485 performs a 'Full Command Sequence' command.
DS2485_ComputeCrc16 DS2485 performs a 'Compute CRC16' command.

1-Wire API

The 1-Wire API provides full control of the 1-Wire interface. It includes a range of 1-Wire master functionality that is derived from the DS2485 API and is designed to interface with 1-Wire slave devices more easily. An overview of the 1-Wire API is shown in Table 3. See the demo program, "One_Wire_Scripting" for an example of how to use the 1-Wire API to read the DS28E18's device status.

Table 3. 1-Wire API Overview

Function Description
OneWire_Init Configures the DS2485 to default settings.
OneWire_ResetPulse Sends a 1-Wire reset pulse down the 1-Wire bus using the DS2485.
OneWire_WriteByte Sends a byte down the 1-Wire bus command using the DS2485.
OneWire_WriteBlock Sends a block of data down the 1-Wire bus using the DS2485.
OneWire_ReadByte Reads a byte from the 1-Wire bus using the DS2485.
OneWire_ReadBlock Reads a block of data from the 1-Wire bus using the DS2485.
OneWire_WriteBytePower Sends a byte down the 1-Wire bus and enables a strong pullup (SPU) immediately thereafter using the DS2485.
OneWire_ReadBytePower Read a byte from the 1-Wire bus and enables a strong pullup (SPU) immediately thereafter using the DS2485.
OneWire_Search Searches for slave devices on the 1-Wire bus using the DS2485.
OneWire_Set_OneWireMasterSpeed Configures the DS2485's 1-Wire Master speed between Standard and Overdrive.
OneWire_Set_tX Configures a DS2485's 1-Wire Master timing, 'X' (i.e., tRSTL, tMSP, etc.).
OneWire_Enable_APU Configures the DS2485's 'APU' setting.
OneWire_Enable_SPU Configures the DS2485's 'SPU' setting.
OneWire_Enable_OneWirePowerDown Configures the DS2485's 'Power Down' setting.
OneWire_Script_Add_X Adds a 1-Wire primitive command, 'X' (i.e., OW_RESET, DELAY, etc.) to a global buffer in software.
OneWire_Script_Execute Performs a '1-Wire Script' command using primitive commands from global buffer in software using the DS2485.


The C-Demo software also provides a DS28E18 API. A brief overview of the DS28E18 API is shown in Table 4. This API makes it easy to exercise all the features of the DS28E18 and can be used to integrate multiple I2C and SPI devices into a system. See the demo program, "Read_Temperature," for an example of how to use the DS28E18 API to read a temperature and humidity value from a remote Sensirion SHTC3 I2C sensor.

Table 4. DS28E18 API Overview

Function Description
DS28E18_Init Initializes all DS28E18 devices found on the 1-Wire bus.
DS28E18_SetSpeed Sets the DS28E18 speed between Standard and Overdrive.
DS28E18_WriteSequencer Writes specified data into the DS28E18 sequencer.
DS28E18_ReadSequencer Reads specified data from the DS28E18 sequencer.
DS28E18_RunSequencer Commands DS28E18 to execute specific I2C/SPI sequences from its sequencer.
DS28E18_WriteConfiguration Configures the DS28E18's general configuration settings.
DS28E18_ReadConfiguration Reads the DS28E18's general configuration settings.
DS28E18_WriteGpioConfiguration Configures the DS28E18's GPIO configuration settings.
DS28E18_ReadGpioConfiguration Reads the DS28E18's GPIO configuration settings.
DS28E18_DeviceStatus Reads the DS28E18's device status.
DS28E18_BuildPacket_X Builds 1-Wire packet for Sequencer Command, 'X' (i.e., I2C Start, SENS_VDD On, etc.) and stores it in a global buffer in software. Buffer can be used as a 'DS28E18_Write_sequencer' input.

Maxim Devices (3)

Part Number Name Product Family Order Design kits and evaluation modules
DS28E18 1-Wire® to I2C/SPI Bridge with Command Sequencer Secure Authentication Buy Now
DS2485 Advanced 1-Wire® Master with Memory Memory Buy Now
MAX32660 Tiny, Ultra-Low-Power Arm Cortex-M4 Processor with FPU-Based Microcontroller (MCU) with 256KB Flash and 96KB SRAM MCU - Microcontroller Buy Now

Maxim Devices (3)

Part Number Product Family
Secure Authentication
1-Wire® to I2C/SPI Bridge with Command Sequencer
Advanced 1-Wire® Master with Memory
MCU - Microcontroller
Tiny, Ultra-Low-Power Arm Cortex-M4 Processor with FPU-Based Microcontroller (MCU) with 256KB Flash and 96KB SRAM

Design Files (8)

Title Type Size Date
DS28E18 Schematic PDF 362KB 2021-11-21
DS2485 Schematic PDF 560KB 2021-11-21
DS28E18EVKit PCB PDF 604KB 2021-11-21
DS2485EVKit PCB PDF 356KB 2021-11-21
DS28E18 BOM XLSX 13KB 2021-11-21
DS2485 BOM XLSX 11KB 2021-11-21
DS2485 C-Demo ZIP 53KB 2021-11-21
MAXREFDES9004 All Design Files RAR 1MB 2021-11-21
Date Type

DS28E18 Schematic

(PDF, 362KB)


DS2485 Schematic

(PDF, 560KB)



(PDF, 604KB)



(PDF, 356KB)



(XLSX, 13KB)


DS2485 BOM

(XLSX, 11KB)


DS2485 C-Demo

(ZIP, 53KB)


MAXREFDES9004 All Design Files

(RAR, 1MB)

MAXREFDES9004 Related Videos

View All Videos