?? ads1210c.c
字號:
//****************************************************
//* The ADS1210 program(c and asm)version 1.0 *
//*By Li Huailiang 2007.11.12 , All is debuged right *
//****************************************************
//sampling 1000 group data,error is less than 255(low 8 bits)
//sample frequency is 19.5k,dectaition rate is 1952,all is smallest
//--------------------------------------------------------------
#pragma REGPARMS
#include<c8051f020.h>
#include<intrins.h>
#include<absacc.h>
#include<math.h>
#include<stdio.h>
#include<stdlib.h>
#include"ads1210h.h"
#define uchar unsigned char
#define uint unsigned int
//--------------------------------------------------------------
uchar xdata RESULT[3000];
//--------------------------------------------------------------
void Oscillator_Init()
{
int i = 0;
OSCXCN = 0x67;
for (i = 0; i < 3000; i++); // Wait 1ms for initialization
while ((OSCXCN & 0x80) == 0);
OSCICN = 0x0C;
}
//--------------------------------------------------------------
void PORT_Init(void)
{
XBR0 = 0x04; //Enable UART0 P0.0=TXD0 P0.1=RXD0
XBR1 = 0x88;
XBR2 = 0x42;
//P0MDOUT |= 0xFD;
//P1MDOUT |= 0x40;
//P2MDOUT = 0x08;
//P1MDIN |= 0xFF;
EMI0CF |= 0x32; //use the internal XRAM only
}
//--------------------------------------------------------------
void WDT()
{
EA=0;
WDTCN = 0xde; // disable watchdog timer
WDTCN = 0xad;
EA=1;
}
//-----------------------------------------------------------------------------
// Configure the UART0 using Timer1, for <baudrate> and 8-N-1.
void UART0_Init(void)
{
SCON0=0x50; //選擇串口方式1,波特率9600bps
TMOD = 0x20;
TH1 = 0xfd;
TL1 = 0xfd;
EA=1;
ES0=1; //UART0中斷開啟
TR1=1;
}
void delay()
{
uint j,k;
for(j=0;j<10;j++)
for(k=0;k<100;k++);
}
//-------------------------------------------------------------------------
void main()
{
unsigned long data i;
WDT();
Oscillator_Init();
PORT_Init();
ADS1210();
delay();
UART0_Init();
for(i=0;i<3000;i++)
{
ES0=0;
SBUF0=RESULT[i];
while(!TI0);
TI0=0;
}
while(1);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -