stc12c5a单片机ad口采样c程序怎么写
时间:10-02
整理:3721RD
点击:
看数据手册写出来显示在数码管上一直是00.00。快疯了,求助高手
#include<reg52.h>
#include<intrins.h>
sfr P1ASF =0x9D;
sfr ADC_CONTR =0xBC;
sfr ADC_RES =0xBD;
sfr ADC_RESL =0xBE;
sfr AUXR1 =0xA2;
typedef unsigned char uint8;
typedef unsigned int uint16;
sfr P4=0xc0;
void init()
{ ADC_RES=0;
ADC_RESL=0;
P1ASF =0x01;
ADC_CONTR =0xE8;
AUXR1 =0x04;
}
void main()
{
uint16 result;
uint8 c;
uint16 temp;
init();
while(1)
{
nops();
result=(ADC_RES<<8)|ADC_RESL;
bai=result/100;
shi=result%100/10+10;
ge=result%10;
disp_data(3,bai);
disp_data(2,shi);
disp_data(1,ge);
disp_data(0,0);
}
#include<reg52.h>
#include<intrins.h>
sfr P1ASF =0x9D;
sfr ADC_CONTR =0xBC;
sfr ADC_RES =0xBD;
sfr ADC_RESL =0xBE;
sfr AUXR1 =0xA2;
typedef unsigned char uint8;
typedef unsigned int uint16;
sfr P4=0xc0;
void init()
{ ADC_RES=0;
ADC_RESL=0;
P1ASF =0x01;
ADC_CONTR =0xE8;
AUXR1 =0x04;
}
void main()
{
uint16 result;
uint8 c;
uint16 temp;
init();
while(1)
{
nops();
result=(ADC_RES<<8)|ADC_RESL;
bai=result/100;
shi=result%100/10+10;
ge=result%10;
disp_data(3,bai);
disp_data(2,shi);
disp_data(1,ge);
disp_data(0,0);
}