This post was last edited by littleshrimp on 2017-11-25 17:22 LTC2756 is an (18)-bit current output ADC from Linear Corporation. It uses SPI communication and the output range can be set via SPI Features Maximum 18-bit INL error: ±1LSB over the entire temperature range Six output ranges are available through programming or pin strapping: 0V to 5V, 0V to 10V, –2.5V to 7.5V, ±2.5V, ±5V, ±10V Monotonous is guaranteed over the entire temperature range Glitch Pulse: 0.4nVs (3V), 2nVs (5V)18-Bit Settling Time: 2.1μs2.7V to 5.5V Single Supply OperationReference Current Constant for All CodesVoltage Controlled Offset and Gain TrimSerial Interface with Readback of All RegistersClear to 0V and Power-On Reset to 0V (Independent of Output Range)28-Lead SSOP Package
The timing control is relatively simple. 4 bytes of data are sent through SPI The high 4 bits of the first byte are the control command The remaining 3 bytes are code data or span data according to the command type
The power supply uses +-5V and +-15V The positive power supply LDO uses Linear's LT3042 The negative power supply LDO uses TI's TPS7A4901 The LTC2756 has only 0.5uA operating current. In addition to using an external LDO, you can also use the LTC6655 voltage reference on the board for power supply. But saying all this is useless, because my multimeter only has 2.5 digits I can't evaluate its performance at all [attach]331579 [/attach] After connecting the power supply, use MSP430FR5969 to make the LTC2756 output voltage increase by 1LSB between 0 and 5V // MSP430FR5969 // ----------------- // /|\| 虾扯蛋| // | | Littleshrimp | // --|RST | // | | // | P1.6|-> Data Out (UCB0SIMO) // | | // | P1.7|<- Data In (UCB0SOMI) // | | // | P2.2|-> Serial Clock Out (UCB0CLK) // | P1.3|-> Slave Select (UCB0STE) // //****************************************************************************** #include
#include
#define LTC2756_CMD_WRITE_SPAN 2 //Write Span
#define LTC2756_CMD_WRITE_CODE 3 //Write Code
#define LTC2756_CMD_UPDATE 4 //Update
#define LTC2756_CMD_WRITE_SPAN_UPDATE 6 //Write Span; Update
#define LTC2756_CMD_WRITE_CODE_UPDATE 7 //Write Code; Update
#define LTC2756_CMD_READ_INPUT_SPAN 10 //Read Input Span Register
#define LTC2756_CMD_READ_INPUT_CODE 11 //Read Input Code Register
#define LTC2756_CMD_READ_DAC_SPAN 12 //Read DAC Span Register
#define LTC2756_CMD_READ_DAC_CODE 13 //Read DAC Code Register
#define LTC2756_CMD_NO_OPERATION 15 //No Operation
//Table 2. Span Codes
//S3 S2 S1 S0 SPAN
#define SPAN_UNIPOLAR_0_5 0 //0 0 0 0 Unipolar 0V to 5V
#define SPAN_UNIPOLAR_0_10 1 //0 0 0 1 Unipolar 0V to 10V
#define SPAN_BIPOLAR_5 2 //0 0 1 0 Bipolar –5V to 5V
#define SPAN_BIPOLAR_10 3 //0 0 1 1 Bipolar –10V to 10V
#define SPAN_BIPOLAR_2_5 4 //0 1 0 0 Bipolar –2.5V to 2.5V
#define SPAN_BIPOLAR_2_5_7_5 5 //0 1 0 1 Bipolar –2.5V to 7.5V
#define CS_LOW() P1DIR|= BIT3;P1OUT &= ~BIT3;
#define CS_HIGHT() P1DIR|= BIT3;P1OUT |= BIT3;
void spi_init(void)
{
P1DIR |= BIT3;
P1OUT |= BIT3;
P2SEL1 |= BIT2; // Configure slave clk
P1SEL1 |= BIT6 | BIT7; // Configure SOMI and MISO
// Configure USCI_A0 for SPI operation
UCB0CTLW0 = UCSWRST; // **Put state machine in reset**
// 3-pin, 8-bit SPI master
UCB0CTLW0 |= UCMST | UCSYNC | UCCKPL | UCMSB | UCMODE_1;
// Clock polarity high, MSB
UCB0CTLW0 |= UCSSEL__SMCLK; // SMCLK
UCB0BR0 = 0x02; // /2
UCB0BR1 = 0; //
// UCA0MCTLW = 0; // No modulation
UCB0CTLW0 &= ~UCSWRST; // **Initialize USCI state machine**
}
uint8_t spi_write_read_byte(uint8_t d)
{
while ((UCB0STATW & UCBUSY)); // USCI transmitting or receiving
UCB0TXBUF = d; // Send next value
while ((UCB0STATW & UCBUSY)); // USCI transmitting or receiving
return UCB0RXBUF;
}
void dco_init(void)
{
PM5CTL0 &= ~LOCKLPM5;
// Configure one FRAM waitstate as required by the device datasheet for MCLK
// operation beyond 8MHz _before_ configuring the clock system.
FRCTL0 = FRCTLPW | NWAITS_1;
// Clock System Setup
CSCTL0_H = CSKEY >> 8; // Unlock CS registers
CSCTL1 = DCORSEL | DCOFSEL_4; // Set DCO to 16MHz
CSCTL2 = SELA__VLOCLK | SELS__DCOCLK | SELM__DCOCLK; // Set SMCLK = MCLK = DCO,
// ACLK = VLOCLK
CSCTL3 = DIVA__1 | DIVS__1 | DIVM__1; // Set all dividers
CSCTL0_H = 0; // Lock CS registers
}
void dac_set_span(uint8_t span)
{
CS_LOW();
spi_write_read_byte(LTC2756_CMD_WRITE_SPAN << 4);
spi_write_read_byte(0x00);//bit17~bit10;
spi_write_read_byte(span);//bit9~bit2;
spi_write_read_byte(0x00);//bit1~bit0
CS_HIGHT();
}
void dac_set_code(uint32_t code)
{
CS_LOW();
spi_write_read_byte(LTC2756_CMD_WRITE_CODE_UPDATE << 4);
spi_write_read_byte(code >> 10);//bit17~bit10;
spi_write_read_byte(code >> 2);//bit9~bit2;
spi_write_read_byte(code << 6);//bit1~bit0
CS_HIGHT();
}
int main(void)
{
uint32_t i;
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
dco_init();
spi_init();
dac_set_span(SPAN_UNIPOLAR_0_5);
while(1)
{
for(i=0;i<262144;i+=100)
{
dac_set_code(i);
}
}
}
[/code]
工程
282.msp430fr5969 spi ltc2756.rar
(7.34 KB, downloads: 9)
此内容由EEWORLD论坛网友littleshrimp原创,如需转载或用于商业用途请随意,无需征得作者同意或注明出处