For a project I'm working one I have to use two DAC's. I have chosen for the DAC8881 DAC.
No I encountered a problem that I do not quite understand why it happens, so I hope one of you can help me a step further.
(Let me note that I'm not a hardcore programmer)
The DAC8881 seems to me to be quite a simple DAC and so I didn't expect any problems. I know that the problem I have is something I do/did wrong but for some reason I can't figure out what it is.
The problem I have is this:
- When I send a value to the DAC it doesn't output what I expect it to do. The output doesn't seem to have any logical pattern.
The control seems to stop at 0x7FFF and does not follow a linear pattern from 0x0000 to 0x7FFF.
Vref = 2.048V (LM4132AMF-2.0)
AVDD = 3.3V
DVDD = 3.3V
Default hardware setting:
Default boot:
Vout = 0V (Register = 0000h) RSTSEL -> GND
PDN = GND -> device is never powered down
SDOSEL = IOVDD -> Device in standalone mode
GAIN = GND -> Gain = 1x
!LDAC = GND -> DAC value immediately updated
!RST = +3v3 -> Device never hardware reset, excl. power cycle
RSTSEL = GND -> sets the boot output voltage register to 0x0000 / 0V
USB/BTC = IOVDD -> Straight Binary Code output
The circuit made is equivalent to: the Analog Output Closed-Loop Configuration shown in the datasheet on page 26. (on my board the RFB and Vout pins are connected at the point where the signal leaves the PCB)
Some Examples: (Just for your information: the real output voltage measured with a Fluke 115)
Send Code: (confirmed with Logic analyzer) 0x0C80 should be 0.1V at the output real output is: 0.064V
Send Code: (confirmed with Logic analyzer) 0x1900 should be 0.2V at the output real output is: 0.128V
Send Code: (confirmed with Logic analyzer) 0x2580 should be 0.3V at the output real output is: 0.008V
Send Code: (confirmed with Logic analyzer) 0x3200 should be 0.4V at the output real output is: 0.256V
Send Code: (confirmed with Logic analyzer) 0x3E80 should be 0.5V at the output real output is: 0.480V
Send Code: (confirmed with Logic analyzer) 0x4B00 should be 0.6V at the output real output is: 0.016V
Send Code: (confirmed with Logic analyzer) 0x5780 should be 0.7V at the output real output is: 0.056V
Send Code: (confirmed with Logic analyzer) 0x6400 should be 0.8V at the output real output is: 0.512V
Send Code: (confirmed with Logic analyzer) 0x7080 should be 0.9V at the output real output is: 0.768V
Send Code: (confirmed with Logic analyzer) 0x7D00 should be 1.0V at the output real output is: 0.960V
Send Code: (confirmed with Logic analyzer) 0x7FFF should be 1.024V at the output real output is: 1.024V
Send Code: (confirmed with Logic analyzer) 0x8980 should be 1.1V at the output real output is: 0.008V
Send Code: (confirmed with Logic analyzer) 0x9600 should be 1.2V at the output real output is: 0.032V
Send Code: (confirmed with Logic analyzer) 0xA280 should be 1.3V at the output real output is: 0.004V
Send Code: (confirmed with Logic analyzer) 0xAF00 should be 1.4V at the output real output is: 0.112V
Send Code: (confirmed with Logic analyzer) 0xBB80 should be 1.5V at the output real output is: 0.408V
Send Code: (confirmed with Logic analyzer) 0xC800 should be 1.6V at the output real output is: 1.024V
Send Code: (confirmed with Logic analyzer) 0xD480 should be 1.7V at the output real output is: 1.024V
Send Code: (confirmed with Logic analyzer) 0xE100 should be 1.8V at the output real output is: 1.536V
Send Code: (confirmed with Logic analyzer) 0xED80 should be 1.9V at the output real output is: 1.608V
Send Code: (confirmed with Logic analyzer) 0xFA00 should be 2.0V at the output real output is: 1.919V
Send Code: (confirmed with Logic analyzer) 0xFFFF should be 2.048V at the output real output is: 2.047V
-----------------------------------------------------------------------------------------------------------------------------------------------
A Small snippet of the code:
void SendVoltageToDACValue(int setpoint, GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
{
uint16_t DACValueToSend = 0;
DACValueToSend = setpoint;
SPI_DataToSend[0] = (uint8_t)((DACValueToSend & 0xFF00)>>8);
SPI_DataToSend[1] = (uint8_t)((DACValueToSend & 0x00FF));
digitalWrite(GPIOx, GPIO_Pin, LOW);
HAL_Delay(1);
HAL_SPI_Transmit(SPI_HANDLER, SPI_DataToSend, 2, SPI_TIMEOUT);
digitalWrite(GPIOx, GPIO_Pin, HIGH);
}
Do any of you have an Idea what the issue is here? I think it should be very simple but I just can't see it.
Thank you in advance for your time and effort