I'm interfacing AD7849(16-bit serial DAC) with PIC24FV16KM202 microcontroller using its SPI protocol. My DAC can work in unipolar as well as in bipolar mode depending upon the reference we provide to it. I'm using it in unipolar mode(0 to 10V). On i/p of 0x0000, it should give an o/p of 0V and on i/p of 0xFFFF it should provide 10V. But it shows a peculiar behavior. It gives its full range o/p on 0x7F7F and after that it starts repeating itself in terms of o/p e.g. when I fix higher byte and vary only lower byte in steps like 0x0000, 0x0001, 0x0002, 0x0003 and so on, o/p changes linearly but only up to 0x007F and after that repetition starts. 0x007F is like 0x00FF and 0x0080 is like 0x0000, same is the case when I keep lower byte constant and vary higher byte like 0x0000, 0x0100, 0x0200, 0x0300 and so on, o/p varies accordingly but gets repeated after 0x7F00 whereas it should've given full range o/p voltage on 0xFFFF not on 0x7F7F. Here's the code which I've written.
Please help me with this problem.