Hi,
I'm using DAC8775 with +/- 15V external power supply for channel A, I want to use channel A as current source,.
Is there any initialization sequence for that? and what are the steps to generate 1mA on channel A for example.
Thanks,
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi,
I'm using DAC8775 with +/- 15V external power supply for channel A, I want to use channel A as current source,.
Is there any initialization sequence for that? and what are the steps to generate 1mA on channel A for example.
Thanks,
This is the initialization code, but still doesn't work!
void DAC8775_init()
{
// Initialize SPI
SPI_A0_init();
// Initialize ALARM pin as input with interrupt
P6REN |= DAC8775_ALARM_PIN; // Enable internal resistor
P6OUT |= DAC8775_ALARM_PIN; // Set resistor as pull-up
P6DIR &= DAC8775_ALARM_PIN; // Set pin as input
P6OUT &= ~(DAC8775_CLR_PIN + DAC8775_LDAC_PIN + DAC8775_RST_PIN); // Initialize as LOW
P6OUT |= DAC8775_CS_PIN; // Initialize as HIGH
P6DIR |= DAC8775_RST_PIN + DAC8775_CS_PIN + DAC8775_CLR_PIN + DAC8775_LDAC_PIN; // Set as output pins
// Set RST as HIGH
P6OUT |= DAC8775_RST_PIN;
DAC8775_writeToRegister(DAC8775_RST, 0x0001); // Software Reset
DAC8775_writeToRegister(DAC8775_RST_CONFIG, 0x0012);// Enable Reference, Power-off Condition, change to High-Z for VOUT and IOUT
DAC8775_writeToRegister(DAC8775_SELECT_DAC, 0x0020);// Select DAC Channel A
DAC8775_writeToRegister(DAC8775_CONFIG_DAC, 0x000F);// Set for 4 to 20mA range
DAC8775_writeToRegister(DAC8775_CONFIG_DAC, 0x100F);// Enable output
DAC8775_writeToRegister(DAC8775_DAC_DATA, 0x8000); // Write DAC Data Register value to mid-scale
}
void DAC8775_writeToRegister(uint8_t registerAddress, uint16_t value)
{
DAC8775_select();
SPI_A0_sendByte(registerAddress);
SPI_A0_sendByte((value & 0xFF00) >> 8);
SPI_A0_sendByte(value & 0x00FF);
DAC8775_deselect();
}
Hi Wahib,
There are several potential issues with the schematic you've supplied. I've provided an overview of my feedback below:
Please also provide a complete SPI transaction with the following signals:
Best Regards,
Matt
Hi Matt,
First of all thanks for your kind help, I checked the SPI and LDAC transactions and figured out the problem,
The new code now is:
#include "dac8775.h"
inline void DAC8775_select()
{
P6OUT &= ~DAC8775_CS_PIN;
}
inline void DAC8775_deselect()
{
P6OUT |= DAC8775_CS_PIN;
}
void DAC8775_init()
{
// Initialize SPI
SPI_A0_init();
// Initialize ALARM pin as input with interrupt
P6REN |= DAC8775_ALARM_PIN; // Enable internal resistor
P6OUT |= DAC8775_ALARM_PIN; // Set resistor as pull-up
P6DIR &= DAC8775_ALARM_PIN; // Set pin as input
P6OUT &= ~(DAC8775_CLR_PIN + DAC8775_RST_PIN); // Initialize as LOW
P6OUT |= DAC8775_CS_PIN + DAC8775_LDAC_PIN; // Initialize as HIGH
P6DIR |= DAC8775_RST_PIN + DAC8775_CS_PIN + DAC8775_CLR_PIN + DAC8775_LDAC_PIN; // Set as output pins
// Set RST as HIGH
P6OUT |= DAC8775_RST_PIN;
DAC8775_writeToRegister(DAC8775_RST, 0x0001); // Software Reset
DAC8775_writeToRegister(DAC8775_RST_CONFIG, 0x0012);// Enable Reference, Power-off Condition, change to High-Z for VOUT and IOUT
DAC8775_writeToRegister(DAC8775_SELECT_DAC, 0x0020);// Select DAC Channel A
DAC8775_writeToRegister(DAC8775_CONFIG_DAC, 0x0007);// Set for -24mA to +20mA range
DAC8775_writeToRegister(DAC8775_CONFIG_DAC, 0x1007);// Enable output
}
void DAC8775_writeToRegister(uint8_t registerAddress, uint16_t value)
{
DAC8775_select();
SPI_A0_sendByte(registerAddress);
SPI_A0_sendByte((value & 0xFF00) >> 8);
SPI_A0_sendByte(value & 0x00FF);
P6OUT &= ~DAC8775_LDAC_PIN;
DAC8775_deselect();
P6OUT |= DAC8775_LDAC_PIN;
}
the issue was that LDAC should go LOW before making SYNC goes to HIGH, then LDAC should be set to HIGH again after making SYNC HIGH.
The other thing was for CLK of SPI it has to be set with ClockPolarity = 0 and ClockPhase = 0.
and to update channel current value:
DAC8775_writeToRegister(DAC8775_DAC_DATA, 19114); // -10mA
DAC8775_writeToRegister(DAC8775_DAC_DATA, 46421); // +10mA