Quote Originally Posted by HenrikOlsson View Post
Yes, Robert is spot on of course.
The reason for doing it is that we need to left justify the bits in the word we're shifting out (because the device wants MSB first). It moves the four control bits from the lower four bits of Control to the top four bits of ValueOfToSend then it adds in the actual value shifted two positions to the left in order to "put it" after the first four bits.
/Henrik.
I get it now. Thanks for the explanation.
By the way, you had the control value set to 9 in your example so I used that but looking at the datasheet that doesn't seem to be a valid command. Does it really work with a control value of 9?
The control value of 9 is actually for the MCP4912. I'm testing a few things at once.