Wiki

This version is outdated by a newer approved version.DiffThis version (04 Jul 2018 11:54) was approved by Alexandra Banut.The Previously approved version (02 Oct 2015 18:23) is available.Diff

This is an old revision of the document!


AD717X No-OS Software Drivers

Introduction

This document describes the No-OS software used to control the AD717X family parts and includes an example of how to initialize a AD7176 part.

Overview

The AD717x family of products are fast settling, high resolution, highly accurate, multiplexed Σ-Δ analog-to-digital converters (ADC) for low bandwidth input signals, with resolution options of both 32bit and 24bit available. The products are available in both TSSOP of LFCSP depending on the product selected. AD717x family of devices include:

The inputs to the ADC can be configured as fully differential or pseudo differential inputs depending on the product chosen, this can be done via the integrated crosspoint multiplexer. An integrated precision, 2.5 V, low drift (2ppm/°C), band gap internal reference (with an output reference buffer) adds functionality and reduces the external component count. A maximum channel scan data rate is 50 kSPS (with a settling time of 20 μs), resulting in fully settled data of 17 noise free bits. User-selectable output data rates range from 5 SPS to 250 kSPS can be obtained from AD7175, AD7176 and AD7177 devices. A maximum channel scan data rate is 6.1 kSPS (with a settling time of 161 μs). User-selectable output data rates range from 1.25 SPS to 31.25 kSPS can be obtained from AD7172, AD7173 devices. The AD717x devices offers three key digital filters. The fast settling filter maximizes the channel scan rate. The Sinc3 filter maximizes the resolution for single-channel, low speed applications. For 50 Hz and 60 Hz environments, the AD717x specific filter minimizes the settling times or maximizes the rejection of the line frequency. These enhanced filters enable simultaneous 50 Hz and 60 Hz rejection with a 27 SPS output data rate (with a settling time of 36 ms). System offset and gain errors can be corrected on a per channel basis. This per channel configurability extends to the type of filter and output data rate used for each channel. All switching of the crosspoint multiplexer is controlled by the ADC and can be configured to automatically control an external multiplexer via the GPIO pins. The specified operating temperature range is −40°C to +105°C.

Applications

  • Process control : PLC/DCS modules
  • Temperature and pressure measurement
  • Medical and scientific multichannel instrumentation
  • Chromatography

Supported Devices

Entire AD717X family.

Evaluation Boards

Driver Description

The driver contains two parts:

  • The driver for the AD717X family, which may be used, without modifications, with any microcontroller.
  • The Communication Driver, where the specific communication functions for the desired type of processor and communication protocol have to be implemented. This driver implements the communication with the device and hides the actual details of the communication protocol to the ADI driver.

The Communication Driver has a standard interface, so the AD717X driver can be used exactly as it is provided.

There are three functions which are called by the AD717X driver:

  • SPI_Init() – initializes the communication peripheral.
  • SPI_Write() – writes data to the device.
  • SPI_Read() – reads data from the device.

SPI driver architecture

The AD717X driver contains the following:

  • AD717X.h - Header file of the driver. Contains the register map definitions, the driver function declarations, custom data types to be used by the driver and driver specific constants.
  • AD717X.c - Implementation file of the driver. Contains the implementations of the driver functions.

The driver works with any of the following headers by including them in your main project just as you include the ad717x.h header:

  • AD7172_2_regs.h
  • AD7172_4_regs.h
  • AD7173_8_regs.h
  • AD7175_2_regs.h
  • AD7175_8_regs.h
  • AD7176_2_regs.h
  • AD7177_2_regs.h

Each header declares an array of all register of the device that the header describes.

The following functions are implemented in this version of AD717X driver:

Function Description
ad717x_st_reg *AD717X_GetReg(struct ad717x_device *device, uint8_t reg_address)
Retrieves a pointer to the register that matches the given address.
int32_t AD717X_ReadRegister(struct ad717x_device *device, uint8_t addr)
Reads the value of the specified register.
int32_t AD717X_WriteRegister(struct ad717x_device *device, uint8_t addr)
Writes the value of the specified register.
int32_t AD717X_Reset(struct ad717x_device *device)
Resets the device.
int32_t AD717X_WaitForReady(struct ad717x_device *device, uint32_t timeout)
Waits until a new conversion result is available.
int32_t AD717X_ReadData(struct ad717x_device *device, int32_t* pData)
Reads the conversion result from the device.
uint8_t AD717X_ComputeCRC8(uint8_t* pBuf, uint8_t bufSize)
Computes the CRC checksum for a data buffer.
uint8_t AD717X_ComputeXOR8(uint8_t * pBuf, uint8_t bufSize)
Computes the XOR checksum for a data buffer.
void AD717X_UpdateCRCSetting(struct ad717x_device *device)
Updates the CRC settings.
int32_t AD717X_Setup(struct ad717x_device *device, uint8_t slave_select, ad717x_st_reg *regs, uint8_t num_regs)
Initializes the AD717x.

Downloads

Using the API

The driver can only work together with a structure that holds the state of a device, where state means all information about the device including a copy of all register values written to the device at a certain point. This structure will henceforth be referred as an instance of a driver.
All driver functions take a handler of a driver instance as the first argument. This allows the driver to be used with multiple devices simultaneously, without the need to replicate the .c and .h files.

Before using any API call an instance of the driver must first be created and then initialized using the AD717X_Setup() which has the following parameters:

  • device: the reference of the new driver instance. A new instance can be obtained by simply declaring one:
     struct ad717x_device my_ad7176_2; 
  • slave_select: the index of the SPI Chip Select. It will be stored into the driver instance to be used with all SPI calls for that particular instance.
  • regs: must point to a register array of the device. It will too be stored into the driver and used by the driver. The ad7176_2_regs array defined and initialized in ad7176_2_regs.h can be passed here as parameter provided that the following directive is added inside the file where the driver is being used:
     #define AD7176_2_INIT 

    Alternatively, a new register array can be defined by user which must be properly initialized before calling AD717X_Setup() function.

    ad717x_st_reg my_ad7176_2_regs[] = 
    {
        { AD717X_STATUS_REG, 0x00, 1 },
        { AD717X_ADCMODE_REG, 0x0000, 2 },
        ...
    }
  • num_regs: must provide the number of elements in regs.

A AD717X_Setup() call will also reset the part then use all register values stored in the array pointed by the regs parameter to configure the part (the registers that are “Read-only” will not be written during this call).

The following code snipped provides an example of driver usage:

/* Create a new driver instance */
struct ad717x_device my_ad7176_2;
struct ad717x_device *ad7176_2_handler = &my_ad7176_2;
 
/* Other variables */
long timeout = 1000;
long ret;
long sample;
.
.
.
/* Initialize the driver instance and let's use the ad7176_2_regs array defined in ad7176_2_regs.h */
#define AD7176_2_INIT
AD717X_Setup(ad7176_2_handler, AD7176_2_SLAVE_ID, (ad717x_st_reg *)&ad7176_2_regs,
             sizeof(ad7176_2_regs) / sizeof(ad7176_2_regs[0]));
 
/* Read data from the ADC */
ret = AD717X_WaitForReady(ad7176_2_handler, timeout);
if (ret < 0)
    /* Something went wrong, check the value of ret! */
 
ret = AD717X_ReadData(ad7176_2_handler, &sample);
if (ret < 0)
        /* Something went wrong, check the value of ret! */

More information

01 Jun 2012 12:17
resources/tools-software/uc-drivers/ad717x.1530698003.txt.gz · Last modified: 04 Jul 2018 11:53 by Alexandra Banut