联想电脑e430c驱动

发布时间: 2023-04-17 13:10 阅读: 文章来源:转载
本帖最后由 littleshrimp 于 2017-11-25 17:22 编辑

LTC2756是Linear公司的一款(18)位电流输出ADC

使用SPI通信,可通过SPI设置输出范围

特点

最大 18 位 INL 误差:在整个温度范围内为 1LSB

可通过编程或引脚搭接提供 6 种输出范围:0V 至 5V、0V 至 10V、–2.5V 至 7.5V、2.5V、5V、10V

在整个温度范围内可保证单调

干扰脉冲:0.4nV•s (3V),2nV•s (5V)

18 位稳定时间:2.1μs

2.7V 至 5.5V 单电源操作

对于所有代码基准电流保持恒定

电压控制型偏移和增益修整

具所有寄存器回读功能的串行接口

清至 0V 和上电复位至 0V (这与输出范围无关)

28 引脚 SSOP 封装

时序控制起来比较简单,通过SPI发送4个字节数据

第1个字节高4位为控制命令

剩余3个字节根据命令类型选择是code数据,还是span数据

电源使用+-5V和+-15V供电

正电源LDO使用了Linear的LT3042

负电源LDO使用了TI的TPS7A4901

LTC2756只有0.5uA的工作电流,除使用外部LDO还可以使用板子上的LTC6655电压基准供电

不过说这些都没什么用,因为我的万用表只有2位半

根本没法评测它的性能

连接好电源后通过MSP430FR5969使LTC2756输出电压在0~5V之间以1LSB递增

实验锯齿波效果

代码

[C] 纯文本查看 复制代码

?

001002003004005006007008009010011012013014015016017018019020021022023024025026027028029030031032033034035036037038039040041042043044045046047048049050051052053054055056057058059060061062063064065066067068069070071072073074075076077078079080081082083084085086087088089090091092093094095096097098099100101102103104105106107108109110111112113114115116117//******************************************************************************// MSP430FR5969// -----------------// /|\| 虾扯蛋 |// | | Littleshrimp |// --|RST |// | |// | P1.6|-> Data Out (UCB0SIMO)// | |// | P1.7| 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 10);//bit17~bit10; spi_write_read_byte(code >> 2);//bit9~bit2; spi_write_read_byte(code

•••展开全文
相关文章