Hi,
I'm glad you've got it working. I don't understand the reference to "an extra bit" but perhaps it doesn't matter now that it works. I see that you have 17 bits in your SHIFTOUT command but you're actually only sending 16.
For reference, this is the datasheet I'm looking at. Section 5.2 explains how the write command works, ie 4 config bits and 12 databits for a total of 16bits. The transfer from the input shift register to the actual device will occur only if 16bits has been shifted in, you can't do less or it will be ignored.
If LDAC is low the output voltage will be updated at the rising edge of CS. If LDAC is high at the rising edge of CS the output will be updated at the falling edge of LDAC. This allows multiple DACs to be connected to the SPI bus and writen one after the other and then, with their LDAC pins connected together, their outputs gets updated simultanously instead of one by one as they are written to by the SPI bus.
On the next page, register 5.2 shows the write command register for the MCP4911 and what each of the config bits do. Again, no "extra bit" as far as I can see.
You can't just write the 10 databits to the device, you must transfer all 16 bits including the config bits - even if they don't actually change. If you don't transfer 16bits the transfer will be ignored as explained in section 5.2.
Here's something you could do to make it more clear what's happening.
Code:
OutWord VAR WORD
WRITE_DAC CON 0
Vref_BUF CON 16384
Vref_UnBuf CON 0
GAIN_1x CON 8192
GAIN_2x CON 0
VOut_ON CON 4096
VOut_OFF CON 0
OutWord = WRITE_DAC + VRef_UnBuf + GAIN_1x + VOut_ON + 456 ' Where 456 is your analog value.
SHIFTOUT SDI, CLK, 1, [OutWord\16]
The above would then shiftout the value 12744, which in binary is 0011000111001000.
/Henrik.
Bookmarks