PIC单片机采样MAX11210程序

这是PIC单片机采样MAX的ADC芯片MAX11210


/**************************************************************************************
The Crystal oscillator is 12M
The filter data is between 0 and 20
Close GIE before Writing the eeprom
remark:need about 1 second to initialize
**************************************************************************************/

//************************************************************************************
//include file
#include <pic16f1936.h>
//__CONFIG (FOSC_HS & PROTECT & PWRTEN & BOREN & WDTDIS);
//__CONFIG1 (FOSC_HS & WDTE_OFF & PWRTE_OFF & MCLRE_ON & CP_OFF & BOREN_OFF);

//*************************************************************************************
#define nop() asm("nop")
#define uchar unsigned char
#define uint unsigned int
#define CS RC1
#define SCK RC3
#define SDI RC4
#define SDO RC5
#define RDY RB0
#define Dir_485 RB1
#define Led_Ad RB5

//**************************************************************************************
//define the constant
const float FullWeight=10000.0; //the full weight
const float ZeroWeight=0.0; //the zero weight
const uchar MaxFilterCount=60; //the maxmum filter count which you can set
const uchar MinFilterCount=3; //the minmum filter count which you can set
const uchar ADC_ConMode=0x00; //0x00:single mode,0x01:continue mode
const uchar RxbufCount=15; //the rxbuff arry count
const unsigned CmdDelCount=100; //the delay of command
//**************************************************************************************
//define the constant of 485 command
/* const uchar M1=0x7C; //the Xor value between 4D and 31
const uchar CL=0x0F; //the Xor value between 4c and 4C
const uchar A_Wenhao=0x7E; //the Xor value between 41 and 4F
const uchar ZA=0x07; //the Xor value between 46 and 41
const uchar FA=0x1B; //the Xor value between 5A and 41
const uchar Axx=0x41; //the writing filter
const uchar TP01=0x05; //the Xor value of TP01
const uchar PCJG=0x1E; //the Xor value of P"CJG"
*/
#define Head_Data 0xE1 //the head of comunicate datas
#define End_Data 0xEF //the end of comunicate datas
//**************************************************************************************
//START MODE B5 Rs3 RS2 RS1 RS0 w/R
//1 1 0 0 0 1 1 0
#define CMD1_R_STAT1 0xC1 //read STAT1
#define CMD1_R_CTRL1 0xC3 //read CTRL1
#define CMD1_W_CTRL1 0xC2 //write CTRL1
#define CMD1_R_CTRL2 0xC5 //read CTRL2
#define CMD1_W_CTRL2 0xC4 //write CTRL2
#define CMD1_R_CTRL3 0xC7 //read CTRL3
#define CMD1_W_CTRL3 0xC6 //write CTRL3
#define CMD1_R_DATA 0xC9 //read CTRL3

//************************************************************************************
//define the operating command
#define CMD_SlefCali 0x90 //Self_Calibration Cycle
#define CMD_Conv 0x87 //Convert 480sps

//**************************************************************************************
// set the Register
//CTRL1 for continue

你可能喜欢

  • PIC单片机C语言编程实例
  • 单片机程序
  • MAX7219
  • 典型电路
  • 单片机串口通信程序

PIC单片机采样MAX11210程序相关文档

最新文档

返回顶部