xinnianchang:
楼主可以请教一下问题吗就是这个单片机的ADC的编程问题和外围连接问题我弄了一个这样的程序不过好像有误差挺大的,还有那个外部的连接问题怎样改加入我要测量超过5v的电压#include"Text2.h" //stc12c5a60s2头文件#defineucharunsignedchar#defineuintunsignedintunsignedchardata adc_dat=0x30;ucharge,shi,shifen,baifen,qianfen;floatvin,R;int vins;sbitdula=P3^6;ucharcodetable[]={0x40,0x79,0x24,0x30,0x19,0x12,0x02,0x78,0x00,0x10}; //有小数点的ucharcodetable1[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90}; //没小数点的voiddisplay(ucharshi,ucharge,ucharshifen,ucharbaifen,ucharqianfen);voiddelay(uintz) //延时子函数{ uintx,y; for(x=z;x>0;x--) for(y=110;y>0;y--);}voidmain(void){ unsignedlongi; unsignedcharstatus; ADC_CONTR|=0x80; //打开AD转换电源 for(i=0;i