Post Go back to editing

I Can not initialize the AD7734!

Hello, im trying connect the ADD7734 to a Dspic30F6012A microcontroller, but i have not sucess. The problem is the ADC never initialize because when i read the default value of a register i got something are not be default and the MOSI  are everytime the same value 0XFF and i don´t know why. To communicate with AD7734, i use the library of the ADC but to work with the SPI of DSPIC30F these library was changed. To build the code i used the specs of acess the registers of AD7734:

http://www.analog.com/media/en/technical-documentation/data-sheets/AD7734.pdf

I use the channel1,  AN1  to measure a range voltage between -10 to 10 V.

-12 Mhz Max conversion Time Rate

Timing Specifications :

-Read Op /CS Falling Edge to SCKL Falling Edge Setup Time

-Read at high SCKL

Write Operations :

- Data Valid to SCLK Rising edge Setup Time

/* Config. Registers */

- Mode Register:

00101111b

MD - 001 : Continuous Conversion Mode : After the conversion is complete, the relevant channel data register and channel status register are updated, the relevant RDY bit in the ADC status register is set, and the AD7734 continues converting on the next enabled channel.

CLKDIS - 0

DUMP - 1 : the DUMP bit is set to 1, the channel status register will be followed immediately by a

read of the channel data register regardless of whether the status or data register has been addressed through

the communication register. The continuous read mode will always be dump mode reading of the channel status

and data register, regardless of the dump bit value

CONTRD - 1

24 bit - 1

CLAMP - 1

- Communications Register : AD7734_REG_COMM Address 0x00

/*

Write Comm. Register

Write Mode. Register

Write Comm. Register

- Conversion On CH1 Complete

Read CH1 Status

Read CH1 Data

*/

- Channel Setup Registers channel 0-3 (4) Channel1 - 29h

00001000b - 08h

7-5 bit : 0

Stat OPT: 0

ENABLE : 1

2 bit : 0

1 -0 bit : 00    ( +/- 10v )

- Communications Register (Add 00h)

/* Address specifying to which register the read or write operation will be directed! */

7 : 0

6 : R = 0 ; W = 1

[5-0] : Address  ---001 (ANI1)

01XXX001b

CH1 Address 0x09

0101001 - 0x29

- Channel Data (08h-B0h) default 8000h - Channel1 09h

- ADC Status Register - 00000010 (RDY1)

In conversion modes, the register bits reflect the individual channel

status. When a conversion is complete, the corresponding channel

data register is updated and the corresponding RDY bit is set to 1.

When the channel data register is read, the corresponding bit is

reset to 0. The bit is also reset to 0 when no read operation has

taken place and the result of the next conversion is being updated

to the channel data register. Writing to the mode register resets

all the bits to 0

SPI ( DSPIC30F Microchip)

http://ww1.microchip.com/downloads/en/DeviceDoc/70046E.pdf

The SPI serial port consists of the following Special Function Registers (SFR):

- SPIxBUF: Address in SFR space that is used to buffer data to be transmitted and data that

is received. This address is shared by the SPIxTXB and SPIxRXB registers.

- SPIxCON: A control register that configures the module for various modes of operation.

- SPIxSTAT: A status register that indicates various status conditions.

Someone can help me? I put the code here and a printscreen of the logic analyzer.

Data Converters

attachments.zip
  • Hi bmalbusca,

    I understand that in the first part your initialization routine, you are trying to reset the part and then read the Status register of Channel 2 to get the default value. Upon checking you source code and the scope shot of the digital line, I noticed the following:

    1. The RESET sequence lacks a byte of 1's.

         -The datasheet states that you need to send 32 1's in order to reset the part (page 23). What you can do is to modify the  AD7734_Reset function and add another 0xFF to the array containing the reset sequence and change the size accordingly.

    2. Incorrect data written to the Communication register.

         -Since you want to read the contents of channel 2 Status register, 0x61 must be written to the Communication register, this would tell the part that the next operation would be a read to the channel 2 status register. Also it is recommended to write 0 to the AD7734 while reading data. This means that, the sequence 0x61 and 0x00 should be written to the part.

    3.  SPI clock polarity.

         -Check your clock polarity and make your SPI clock idle state high. I think you can do this by setting the value of SPI1CONbits.CKP to 1.

    Can you try these and see if it will solve your problem?

    Regards,

    RC

  • Hello,

    Thanks a lot for your help. But i have tried yours tips and i continue to get nothing in data out canal of the AD7734. I write the 0x61 and before a tried to read  but the value of MISO  is the same 0xFF. Maybe the  problem are the Chip and not the code, but the current drain is a normal for the component(10 mA). Can the cause of this problem are the fact of aren't any pull-up or pull-down resistor on MISO?

    I attached the source code and a printscreen of the implementation.

    Thanks.

    bmalbusca.

  • Hi bmalbusca,

    Can you please share a copy your schematic? The MISO should be fine even without a pull-up/pull-down resistor. Also if possible, can you probe the digital lines using an oscilloscope?

    Regards,

    RC

  • Hello RC,

    Yes, i attached the schematic and the photos of Oscilloscope. The signal viewed in oscilloscope was got something but get too noise.

    Thanks a lot

    bmalbusca.

  • Hi bmalbusca,

    I noticed that you labeled the DIN of AD7734 with OUTADC and DOUT with INADC but it was not shown how these pins are connected to you microcontroller, just to make sure that the pins are not interchanged, can you please check that DIN is connected to the microcontroller's SDO/MOSI and DOUT is connected to SDI/MISO?

    I also noticed that you left REFIN(-), BIASHI and BIASLO open. Although it will not matter in your problem at the moment but you might run some problems with it later when you start gathering data. In normal circuit configuration, REFIN(-) and BIASLO should be connected to ground (0 V) while BIASHI should be connected to your voltage reference (2.5 V).

    Regards,

    RC

  • Hello RC,

    I fixed the schematic and STILL CONTINUING TO HAVE THE SAME PROBLEM. I see the signal (MISO), but the voltage peak to peak is about 600 mV, so the microcontroller don't catch anything ( I tried put the pull-Up resistor to up the signal, but amplitude are too low to make the signal "legible"). More than this, I have a question about the oscillator. In Datasheet, you don't have some reference to the oscillator, nothing more than the frequency( 6.144MHz) and the capacitors (33pF). The amplitude of the Mclk in this situation is around 1.36 V, are supposed? Mclkin is a impluse voltage  and Mclkout is a clock out of the oscillator?

    (Updated 01:45h ):

    The ADC (Slave) are not responding to SPI.

    The signal in the MISO is a simple noise , thats because in MOSI i got the same noise. The Oscillator are doing nothing on ADC, because when  i remove the oscillator i got the same noise  when i get the oscillator there (and i don't have oscillation on the two sides of oscillator). The chosen Oscillator are a  6.144 Mhz but of 18 pF (link : QCS6.14400F18B23M - QANTEK TECHNOLOGY CORPORATION - CRYSTAL, 6.144MHZ, 18PF, 12.5MM X 4.6MM | Farnell element14 Portugal http://pt.farnell.com/qantek-technology-corporation/qcs6-14400f18b23m/crystal-6-144mhz-18pf-12-5mm-x/dp/2508476 ) and not the 33pF given on Datasheet. Can i have some problem with that choice? I tried put in parallel plus one capacitor witch side of oscillator to obtain something about 33 pF ( in correct words 36 pF ) but the problem was the same.

    I attached the schematic and the photos of the Oscilloscope.

    Thanks a lot,

    bmalbusca

  • Hi bmalbusca,

    The crystal you are using should be fine for your application but it should not matter in your current problem since it the microcontroller (master) is providing the clock when communicating with the part. Can you please check if the grounds of both AD7734 and microcontroller are properly connected? Also, to check if we could communicate to the part, can you please try any of the following?

    1. Write 0x38, 0x20 to set the part in continuous conversion mode and check if the /RDY pin is pulsing at the default conversion rate.

    2. Write 0x01, 0xC0 to configure the P0 and P1 pins as outputs and check the pins if they are HIGH.

    Can you please send a scopeshot of the digital lines (sclk, miso, mosi and cs) during these writes? Also, if you have a spare part, can you try replacing the current  one to check if you could get the same response.

    Regards,

    RC

  • This question has been assumed as answered either offline via email or with a multi-part answer. This question has now been closed out. If you have an inquiry related to this topic please post a new question in the applicable product forum.

    Thank you,
    EZ Admin