void main(void)
{
unsigned int j=0;
P4^6=0;
CMOCR1=0;
CMPCR2=0;
PIS=0;
NIS=0;
CMPOE=0;
INVCMPO=0;
DISFLT=0;
CMPCR2|=(DISFLT&0x10);
PIE=1;
CMPEN=1;
EA=1;
while(1)
{
if((CMPCR1&0x01)==0)
{
P4^6=1;
}
}
}作者: wulin 时间: 2020-8-9 20:59
最好用有内置ADC的芯片,例如15WS404AS。非得用STC15W204S那只能模拟ADC功能,把下面程序的串口发送部分改成LED显示即可。
/*------------------------------------------------------------------*/
/* --- STC MCU International Limited -------------------------------*/
/* --- STC 1T Series MCU RC Demo -----------------------------------*/
/* --- Mobile: (86)13922805190 -------------------------------------*/
/* --- Fax: 86-755-82944243 ----------------------------------------*/
/* --- Tel: 86-755-82948412 ----------------------------------------*/
/* If you want to use the program or the program referenced in the */
/* article, please specify in which data and procedures from STC */
/*------------------------------------------------------------------*/