This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DAC8742H: SPI interface with micropython

Part Number: DAC8742H

I am trying to interface a DAC8742 HART ic with micropython on esp32 devboard, using SPI interface. I made a basic circuit for the ic, using the schematics of DAC8742H evaluation module.

these are my spi settings:

>>> spi
SPI(id=1, baudrate=10000000, polarity=0, phase=1, bits=8, firstbit=0, sck=18, mosi=23, miso=19)

IC pin setup:

2 :-  pulled up with 1M ohm resistor to 5v, final voltage - 2.3v
3 :-  NC
4:-   pulled up with 1M ohm resistor to 5v, final voltage - 2.3v
5:-   connected to ground
6:-   pulled up with 1M ohm resistor to 5v, final voltage - .9v +- .1v
7:-   IO32 of esp32 board
9:-   pulled up with 1M ohm resistor to 5v, final voltage - .85v
10:- pulled up with 1M ohm resistor to 5v, and connected to IO4 of esp32 as CS
11:- pulled up with 1M ohm resistor to 5v, and connected to IO18 of esp32 as CLK
12:- pulled up with 1M ohm resistor to 5v, and connected to IO23 of esp32 as MOSI
13:- pulled up with 1M ohm resistor to 5v, and connected to IO19 of esp32 as MISO
14,23 :- VCC of esp32 board, +5V
15,29,26:- GND of esp32 board
30,31:- pulled up with 1M ohm resistor to 5v, final voltage - 2.3v

I left the remaining pins open as currently I just want to interface with the IC and read it's registry data, then as a next step I will make the circuit for remaining pins and connect it to a signal source.

to read the registry i used the following command;

>>> a=bytearray([0x02,0x00,0x00])    # send this buffer
>>> b=bytearray([0x00,0x00,0x00])    # receive in this buffer
>>> spi.write_readinto(a,b)

>>> b
bytearray(b'\xff\xff\xff')            # this is what I received.

NO matter what I send the received bytes are the same. I tested it with CS pin high, low and not connected, the results were same.
Please help us in understanding the issue.

reference:
micropython spi doc: https://docs.micropython.org/en/latest/library/machine.SPI.html
DAC8742H evaluation module schematics: http://www.ti.com/lit/ug/slau700a/slau700a.pdf , page-17

  • Hi Nitish,

    I do not think you have wired your device in a valid configuration.  A 1MΩ resistor does not generally make for a good pullup, as any current load on the pin will cause a large voltage drop, as you are seeing.  I have not looked at the configurations of every pin you listed, but the biggest issue I see is the RST pin.  You are seeing .1 to .9V on that pin.  The RST pin is active low, meaning that it will be held in reset until the pin is high.  0.9V is too low for this pin.  I recommend that you use more reasonable resistor values to ensure the voltage at the IO pins are okay.  1kΩ is fine.

    This is also probably making pin 2, 4, 9, 30, 31 invalid as well.

    Thanks,

    Paul

  • Hi Paul, Thanx for the quick reply,

    I replaced the resistors with 1k ohm value in circuit, all the pulled-up pins have 4.5v on them including pin 6 (RST) ,but the output is still same.

  • Hi Nitish,

    Can you record the SPI communication with a scope or digital analyzer and share the image? Can you also post your schematic?

    Thanks,

    Paul

  • Any updates?

  • hello Paul, sorry for the delay,

    It turns out that the IC I was working with was defected, I made the breakout for 2nd IC  and the circuit is working great.

    Although I had to make changes in spi setting that I was doing wrong:

    - baudrate of 1,000,000 instead of 10,000,000
    - phase = 1 with polarity = 0
    (ref:- page 20, topic 7.4.5.2 of the datasheet)

    I used these settings with the old IC as well but I was not getting any output but works fine with the new one, thats why I concluded that the old IC is damaged.
    Now I am working on the registries.

  • Sounds good.  please let me know if you have any more questions.

    Thanks,

    Paul