Discussion in 'The Projects Forum' started by blah2222, Mar 2, 2014.

  1. blah2222

    Thread Starter Well-Known Member

    May 3, 2010
    Hi all,

    I am programming an MCP4821 DAC using SW_SPI on my PIC18F2550 and have had virtually no issues with setting the output voltage, except for the odd Power-on-Reset.

    The reference voltage of the DAC is 2.048V and the values that I am trying to set it for are between 100mV and 300mV. The issue that I am noticing is that every now and then the first write to DAC after a POR causes an output voltage roughly equal to the reference voltage (2.048V). Subsequent writes alleviate the issue and operation is as expected, but I'm not 100% sure what is happening as this does not occur on every POR.

    From Page 16 in the datasheet:

    The Power-On Reset (POR) circuit ensures that the DACs power-up with SHDN = 0 (high-impedance). The devices will continue to have a high-impedance output until a valid Write command is performed to either of the DAC registers and the LDAC pin meets the input low threshold. If the power supply voltage is less than the POR threshold (Vpor = 2.0V, typical), the DACs will be held in their reset state. They will remain in that state until Vdd > Vpor and a subsequent Write command is received.

    I have a 1uF cap on the output, 0.1uF cap on the supply pin, and LDAC tied low as per the datasheets suggestions.

    I have single-triggered the first SPI write sequence of bits and it matches with what is expected. I have no idea how the output would be set to ~2V as the bit sequence would have to be pretty different.

    Wondering if anyone has experienced this or has any idea on what might be happening.

    Thank you.
  2. JohnInTX


    Jun 26, 2012
    Nothing specific but a couple of things to think about.

    Be sure to pull up CS/ external to the PIC so that the DAC will ignore garbage on the SPI bus as the power comes up.

    Use care in initializing the IO to be sure you don't toggle CS/ during initIO.

    Make sure the SPI bus is properly configured before using CS/, especially SCK with the right polarity and relationship to SDO. You should not have to do this but as a test you can dry-fire the SPI by sending something with CS/=1 to be sure that you don't have a partial byte written due to power up issues.

    Consider using the PWRT on the PIC to hold it in reset until the power has had a chance to stabilize on a cold start.

    If you are using separate supplies, be sure to check the power up sequencing to make sure all are up and happy before any SPI comms.

    Good luck!
    Last edited: Mar 2, 2014
    blah2222 likes this.
  3. blah2222

    Thread Starter Well-Known Member

    May 3, 2010
    Thank you for the suggestions, I made sure to initialize the pins properly.

    I figured out the issue. Looks like I had the SPI setup in Mode 1 when I thought it was in Mode 0 for the DAC to read correctly...