void SetDAC(word input)
{
word moved,ctrl;
byte part1,part2;
moved=input<<2;
ctrl=moved|0x3000;
part1=ctrl>>8;
part2=ctrl&0x00FF;
Bit1_ClrVal();
SPI1_SendChar(part1);
SPI1_SendChar(part2);
Bit1_SetVal();
}
My private function to set up voltage on DAC output. Values 0-1023 can be inputted because of 10 bits resolution.
- activate SPI bean
- call functon in the code with input of your value (trimpot on the board changes range of voltage)
function simply divides data into two chars abnd sends it to SPI. Everything from specification of MAX5251. I suggest to have a look.