Hi Christopher,
I can't see why it shouldn't work. The MCP4911 exepcts data MSB first which is what the MSSP module in the PIC does so there should be no need to move around the bits. What you do need to do though is to "merge" the 4 control bits with the 12 (10) databits into two bytes which you then send using the MSSP module.
Totally untested:
Code:
Control VAR BYTE
Value VAR WORD
DataToSend VAR WORD
Control = 9
Value = 300
DataToSend = (Control << 12) + (Value << 2)
' DataToSend now contains (in binary): 1001010010110000
' The red bits are the control bits '9', the green bits are the value '300' (10bits) and the blue bits are just padding to get the full 16 bits width.
LOW PortE.6
SSPBUF = DataToSend.HighByte
' Wait for byte to go out.
SSPBUF = DataToSend.LowByte
' Wait for byte to go out.
HIGH PortE.6
/Henrik.
Bookmarks