ADS1255分析和总结分析和总结.docxVIP

  • 1
  • 0
  • 约2.2千字
  • 约 2页
  • 2023-03-26 发布于上海
  • 举报
/****************************************************************************/ /*液晶接口: lcd_rs~P4.0,lcd_rw~P4.1,lcd_en~P4.2,lcd_data~P5;**************/ /*ADS1255 接口:SCLK~P3.3,DIN~P3.1,DOUT~P3.2,DRDY~P2.2,CS~GND**********/ /****************************************************************************/ #include msp430x14x.h #define uint unsigned int #define uchar unsigned char #define lint long int /*************以下变量用于 ADS1255***************/ union{ long rlong; struct{ unsigned char lbyte; //低字节 unsigned char mbyte; //中间字节unsigned char hbyte; //高字节unsigned char zbyte; //符号 }Bytes; }Adc_result; /*************以下变量用于液晶***************/ char charTemp[4]; //用于存储转换后电压数字字符char String[]=the vol is:; double ads1255_value= 0.0000;//用于存储 ADS1255 的测量电压 //当整数部分为 4 位时小数后位数不能超过 4 位,并且 整数位加小数位再加小数点共是 8 位 /*************以下为添加各模块文件***************/ #include ads1255.h #include lcd1602.h /*************以下为主程序入口*******************/ void main( void ) { WDTCTL = WDTPW + WDTHOLD; P3DIR|=BIT4; P3OUT=~BIT4; /***********以下配置时钟************************/ // BCSCTL1 |= RSEL2 + RSEL1 + RSEL0; //The lowest nominal frequency is selected by setting RSELx=0 // DCOCTL |= DCO2 + DCO1 + DCO0; //Set max DCO frequency // BCSCTL2 = 0; /***********以下初始化液晶接口******************/ P4DIR|=0X07;//将 P4.0,P4.1,P4.2 设置为输出 P5DIR|=0XFF;//将 P5 设置为输出 /***********以下初始化 ADS1255 的程序**************/ P2DIR = ~BIT2; P3DIR = 0; P3SEL = 0; P3SEL |= BIT3 + BIT2 + BIT1; // Setup P3 for SPI mode U0CTL = CHAR + SYNC + MM + SWRST; // 8-bit, SPI, Master,Software reset enable U0TCTL = SSEL0 + SSEL1 + STC; // SMCLK, Normal polarity, 3-wire U0BR0 = 0x002; // SPICLK = SMCLK/2 U0BR1 = 0x000; U0MCTL = 0x000; ME1 = USPIE0; // 模块允许 U0CTL = ~SWRST; // SPI 允许 Set_Ads1255_Reset(); //ADS1255 复位while(P2IN BIT2); Write_Ads1255_Reg(0x04,0x03); while(P2IN BIT2); Write_Ads1255_Reg(0x04,0x00); while(P2IN BIT2); Write_Ads1255_Reg(0x04,0x03); while(P2IN BIT2); Write_Ads1255_Reg(0x04,0x00); Set_Ads1255_Reset(); Set_Ads1255_Selfcal(); Init_Ads1255(); /*******

文档评论(0)

1亿VIP精品文档

相关文档