⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cs5532software.txt

📁 串行A/D CS5532的程序
💻 TXT
📖 第 1 页 / 共 2 页
字号:
             CS5532_WRITE_ONE_BYTE(0x82);//using gain setup register 1
             CS5532_SDO=1;
             while(CS5532_SDO==1);
             DELAY_TIMES(0xFF);

             //读取偏移/增益寄存器自校准数据存到EEPROM
             if(SWITCH_calibration==0)
             {
                   //读偏移寄存器数据
                    CS5532_WRITE_ONE_BYTE(0x09);   //read the offset register 1
                    Tempdata.Four_1byte[0]=CS5532_READ_ONE_BYTE();
                    Tempdata.Four_1byte[1]=CS5532_READ_ONE_BYTE();
                    Tempdata.Four_1byte[2]=CS5532_READ_ONE_BYTE();
                    Tempdata.Four_1byte[3]=CS5532_READ_ONE_BYTE();
                    DELAY_TIMES(0xFF);
                    //读增益寄存器数据
                    CS5532_WRITE_ONE_BYTE(0x0A);   //read the offset register 1
                    Taredata.Four_1byte[0]=CS5532_READ_ONE_BYTE();
                    Taredata.Four_1byte[1]=CS5532_READ_ONE_BYTE();
                    Taredata.Four_1byte[2]=CS5532_READ_ONE_BYTE();
                    Taredata.Four_1byte[3]=CS5532_READ_ONE_BYTE();
                   // DELAY_TIMES(0xFF);
                     //写容许
                    HT93LC46_EWEN(); 
	             DELAY_TIMES(0x0A);
	             //写偏移数据到EEPROM
	              HT93LC46_WRITE_ONE_BYTE(0x31,Tempdata.Four_1byte[0]);
    		       DELAY_TIMES(0x0A);
    		       HT93LC46_WRITE_ONE_BYTE(0x32,Tempdata.Four_1byte[1]);
    		       DELAY_TIMES(0x0A);
    		       HT93LC46_WRITE_ONE_BYTE(0x33, Tempdata.Four_1byte[2]);
    		       DELAY_TIMES(0x0A);
    		       HT93LC46_WRITE_ONE_BYTE(0x34, Tempdata.Four_1byte[3]);
    		       DELAY_TIMES(0x0A);
    		       //写增益数据到EEPROM
	              HT93LC46_WRITE_ONE_BYTE(0x35,Taredata.Four_1byte[0]);
    		       DELAY_TIMES(0x0A);
    		       HT93LC46_WRITE_ONE_BYTE(0x36,Taredata.Four_1byte[1]);
    		       DELAY_TIMES(0x0A);
    		       HT93LC46_WRITE_ONE_BYTE(0x37, Taredata.Four_1byte[2]);
    		       DELAY_TIMES(0x0A);
    		       HT93LC46_WRITE_ONE_BYTE(0x38, Taredata.Four_1byte[3]);
    		       DELAY_TIMES(0x0A);       
                     //禁止写
    		       HT93LC46_EWDS();
	              DELAY_TIMES(0x0A);
             }
         }
         
         CS5532_self_calibration_0ffset_flag=0;
         CS5532_self_calibration_gain_flag=0;
         CS5532_sys_calibration_0ffset_flag=0;
         CS5532_sys_calibration_gain_flag=0;
             
}

void CS5532_AIN2_CALIBRATION(void)
{
       //自校准
       if(CS5532_self_calibration_0ffset_flag||CS5532_self_calibration_gain_flag)
         {      
              //设置CS5532配置寄存器IS=1,SIGNAL INPUT SHORT   
             CS5532_WRITE_ONE_BYTE(0x03);  //set the cs5532 system configuration register
             CS5532_WRITE_ONE_BYTE(0x0A);  // 1V < Vref < 2.5V
             CS5532_WRITE_ONE_BYTE(0x00);  //IS=1,FRS=0;
             CS5532_WRITE_ONE_BYTE(0x00);  
             CS5532_WRITE_ONE_BYTE(0x00);  
             DELAY_TIMES(0xAA);    //delay about 20ms
             
             //设置通道寄存器设为低速率
             CS5532_WRITE_ONE_BYTE(0x15);  //channel 2 setup register
             CS5532_WRITE_ONE_BYTE(0x72);//gain 64,7.5sps 
             CS5532_WRITE_ONE_BYTE(0x01);  // bipolar performing 
             CS5532_WRITE_ONE_BYTE(0x72);  
             CS5532_WRITE_ONE_BYTE(0x01);  
             DELAY_TIMES(0xAA);    //delay about 20ms
             
             //偏移寄存器自校准self calibration of offset
             CS5532_WRITE_ONE_BYTE(0x91);//using offset setup register 3
             CS5532_SDO=1;
             while(CS5532_SDO==1);
             DELAY_TIMES(0xFF);
             DELAY_TIMES(0xFF);

              //设置CS5532配置寄存器IS=0,SIGNAL INPUT NORMAL OPERATION  
             CS5532_WRITE_ONE_BYTE(0x03);  //set the cs5532 system configuration register
             CS5532_WRITE_ONE_BYTE(0x02);  // 1V < Vref < 2.5V
             CS5532_WRITE_ONE_BYTE(0x00);  //IS=0,FRS=0;
             CS5532_WRITE_ONE_BYTE(0x00);  
             CS5532_WRITE_ONE_BYTE(0x00);  
             DELAY_TIMES(0xAA);    //delay about 20ms
                    
             //增益寄存器自校准self calibration of gain
             CS5532_WRITE_ONE_BYTE(0x92);//using gain setup register 3
             CS5532_SDO=1;
             while(CS5532_SDO==1);
             DELAY_TIMES(0xFF);
             DELAY_TIMES(0xFF);

             //读取偏移/增益寄存器自校准数据存到EEPROM
             if(SWITCH_calibration==0)
             {
                   //读偏移寄存器数据
                    if(CS5532_self_calibration_0ffset_flag)
                    {
                            CS5532_WRITE_ONE_BYTE(0x19);   //read the offset register 2
                            Tempdata.Four_1byte[0]=CS5532_READ_ONE_BYTE();
                            Tempdata.Four_1byte[1]=CS5532_READ_ONE_BYTE();
                            Tempdata.Four_1byte[2]=CS5532_READ_ONE_BYTE();
                            Tempdata.Four_1byte[3]=CS5532_READ_ONE_BYTE();
                            DELAY_TIMES(0xFF);
                    }
                    //读增益寄存器数据
                    if(CS5532_self_calibration_gain_flag)
                    {
                            CS5532_WRITE_ONE_BYTE(0x1A);   //read the offset register 2
                            Taredata.Four_1byte[0]=CS5532_READ_ONE_BYTE();
                            Taredata.Four_1byte[1]=CS5532_READ_ONE_BYTE();
                            Taredata.Four_1byte[2]=CS5532_READ_ONE_BYTE();
                            Taredata.Four_1byte[3]=CS5532_READ_ONE_BYTE();
                            DELAY_TIMES(0xFF);
                    }
                    
                     //写容许
                    HT93LC46_EWEN(); 
	             DELAY_TIMES(0x0A);
	             
	             //写偏移数据到EEPROM
	              if(CS5532_self_calibration_0ffset_flag)
	              {
        	              HT93LC46_WRITE_ONE_BYTE(0x21,Tempdata.Four_1byte[0]);
            		       DELAY_TIMES(0x0A);
            		       HT93LC46_WRITE_ONE_BYTE(0x22,Tempdata.Four_1byte[1]);
            		       DELAY_TIMES(0x0A);
            		       HT93LC46_WRITE_ONE_BYTE(0x23, Tempdata.Four_1byte[2]);
            		       DELAY_TIMES(0x0A);
            		       HT93LC46_WRITE_ONE_BYTE(0x24, Tempdata.Four_1byte[3]);
            		       DELAY_TIMES(0x0A);
    		       }
    		       
    		       //写增益数据到EEPROM
    		       if(CS5532_self_calibration_gain_flag)
    		       {
        	              HT93LC46_WRITE_ONE_BYTE(0x25,Taredata.Four_1byte[0]);
            		       DELAY_TIMES(0x0A);
            		       HT93LC46_WRITE_ONE_BYTE(0x26,Taredata.Four_1byte[1]);
            		       DELAY_TIMES(0x0A);
            		       HT93LC46_WRITE_ONE_BYTE(0x27, Taredata.Four_1byte[2]);
            		       DELAY_TIMES(0x0A);
            		       HT93LC46_WRITE_ONE_BYTE(0x28, Taredata.Four_1byte[3]);
            		       DELAY_TIMES(0x0A);
    		       }
                     //禁止写
    		       HT93LC46_EWDS();
	              DELAY_TIMES(0x0A);
             }
             
            
         }

         //系统校准
         if(CS5532_sys_calibration_0ffset_flag||CS5532_sys_calibration_gain_flag)
         {
                 /*
                  //设置CS5532配置寄存器  
                 CS5532_WRITE_ONE_BYTE(0x03);  //set the cs5532 system configuration register
                 CS5532_WRITE_ONE_BYTE(0x02);  // 1V < Vref < 2.5V
                 CS5532_WRITE_ONE_BYTE(0x10);  //FRS=0;OGS=1;
                 CS5532_WRITE_ONE_BYTE(0x00);  
                 CS5532_WRITE_ONE_BYTE(0x00);  
                 DELAY_TIMES(0xAA);    //delay about 20ms
                 */
                 //设置通道寄存器设为低速率
                 CS5532_WRITE_ONE_BYTE(0x15);  //channel 2 setup register
                 CS5532_WRITE_ONE_BYTE(0x72);//gain 64,7.5sps 
                 CS5532_WRITE_ONE_BYTE(0x01);  // bipolar performing 
                 CS5532_WRITE_ONE_BYTE(0x5A);//gain 8,7.5sps   
                 CS5532_WRITE_ONE_BYTE(0x01);//using channel2  
                 DELAY_TIMES(0xAA);    //delay about 20ms
                 if(CS5532_sys_calibration_0ffset_flag)
                 {
                         //偏移寄存器系统校准system calibration of offset
                         CS5532_WRITE_ONE_BYTE(0x95);//using offset setup register 3
                        // CS5532_WRITE_ONE_BYTE(0x9D);//using offset setup register 4
                         CS5532_SDO=1;
                         while(CS5532_SDO==1);
                         DELAY_TIMES(0xFF);
                         DELAY_TIMES(0xFF);
                 }
                 if(CS5532_sys_calibration_gain_flag)
                 {
                         //增益寄存器系统校准system calibration of gain
                         CS5532_WRITE_ONE_BYTE(0x96);//using offset setup register 3
                       //  CS5532_WRITE_ONE_BYTE(0x9E);//using offset setup register 4
                         CS5532_SDO=1;
                         while(CS5532_SDO==1);
                         DELAY_TIMES(0xFF);
                         DELAY_TIMES(0xFF);
                 }
                 
                 //读取偏移/增益寄存器系统校准数据存到EEPROM
                 if(SWITCH_calibration==0)
                 {
                        
                           //读偏移寄存器数据
                            if(CS5532_sys_calibration_0ffset_flag)
                            {
                                    CS5532_WRITE_ONE_BYTE(0x19);   //read the offset register 2
                                    Tempdata.Four_1byte[0]=CS5532_READ_ONE_BYTE();
                                    Tempdata.Four_1byte[1]=CS5532_READ_ONE_BYTE();
                                    Tempdata.Four_1byte[2]=CS5532_READ_ONE_BYTE();
                                    Tempdata.Four_1byte[3]=CS5532_READ_ONE_BYTE();
                                    DELAY_TIMES(0xFF);
                            }
                            
                            //读增益寄存器数据
                            if(CS5532_sys_calibration_gain_flag)
                            {
                                    CS5532_WRITE_ONE_BYTE(0x1A);   //read the offset register 2
                                    Taredata.Four_1byte[0]=CS5532_READ_ONE_BYTE();
                                    Taredata.Four_1byte[1]=CS5532_READ_ONE_BYTE();
                                    Taredata.Four_1byte[2]=CS5532_READ_ONE_BYTE();
                                    Taredata.Four_1byte[3]=CS5532_READ_ONE_BYTE();
                                  //  Taredata.One_4byte>>=1;
                            }
                           // DELAY_TIMES(0xFF);
                             //写容许
                            HT93LC46_EWEN(); 
        	             DELAY_TIMES(0x0A);
        	             
        	             //写偏移数据到EEPROM
        	             if(CS5532_sys_calibration_0ffset_flag)
        	             {
        	                     
                	              HT93LC46_WRITE_ONE_BYTE(0x29,Tempdata.Four_1byte[0]);
                    		       DELAY_TIMES(0x0A);
                    		       HT93LC46_WRITE_ONE_BYTE(0x2A,Tempdata.Four_1byte[1]);
                    		       DELAY_TIMES(0x0A);
                    		       HT93LC46_WRITE_ONE_BYTE(0x2B, Tempdata.Four_1byte[2]);
                    		       DELAY_TIMES(0x0A);
                    		       HT93LC46_WRITE_ONE_BYTE(0x2C, Tempdata.Four_1byte[3]);
                    		       DELAY_TIMES(0x0A);
            		       }
            		       
            		       //写增益数据到EEPROM
            		       if(CS5532_sys_calibration_gain_flag)
            		       {           		       
                	              HT93LC46_WRITE_ONE_BYTE(0x2D,Taredata.Four_1byte[0]);
                    		       DELAY_TIMES(0x0A);
                    		       HT93LC46_WRITE_ONE_BYTE(0x2E,Taredata.Four_1byte[1]);
                    		       DELAY_TIMES(0x0A);
                    		       HT93LC46_WRITE_ONE_BYTE(0x2F, Taredata.Four_1byte[2]);
                    		       DELAY_TIMES(0x0A);
                    		       HT93LC46_WRITE_ONE_BYTE(0x30, Taredata.Four_1byte[3]);
                    		       DELAY_TIMES(0x0A);
            		       }
                             //禁止写
            		       HT93LC46_EWDS();
        	              DELAY_TIMES(0x0A);
                 }
             
         }
         CS5532_self_calibration_0ffset_flag=0;
         CS5532_self_calibration_gain_flag=0;
         CS5532_sys_calibration_0ffset_flag=0;
         CS5532_sys_calibration_gain_flag=0;
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -