AD、蜂鸣器、时钟芯片(国外英文资料).docVIP

  • 39
  • 0
  • 约1.17万字
  • 约 33页
  • 2017-07-05 发布于河南
  • 举报

AD、蜂鸣器、时钟芯片(国外英文资料).doc

AD、蜂鸣器、时钟芯片(国外英文资料)

AD、蜂鸣器、时钟芯片 / / definition and AD conversion of special function registers //ADCON conversion control register The //ADDATAH conversion result register is 8 bits high The //ADDATAL conversion result register is 8 bits low //P1 port function selection P1CONL=0xB6 //P1.3 output, P1.2AD input, P1.1 external input interrupt, P1.0 output P1CONH=**101010 //**=00 input, **=10 output P1_INT=0x? / / there are problems Int GetAD () //AD function { Unsigned char AD_finish=0; / / AD conversion storage mark Int AD_result; / / define a variable to store the AD conversion results //ADC_DATAH=0; //AD data register high 8 bit clear //ADC_DATAL=0xFB; //AD data register low, 2 bit clear Delayms (1); / / the input voltage reaches a stable delay ADCON=0x23; / select the P1.2 channel, the AD flag, =0, fxx/8 (50uS complete conversion), and start the AD conversion While (AD_finish==0) / / wait for the end of the AD conversion { AD_finish= (ADCON0x08); / / ADC_FLAG bit is set to 1 queries } AD_result=ADDATAH*4+ (ADDATAL0x03); / / read the AD conversion results, because the ADC_DATAH stored in the high accuracy of 8 digits in 10, ADC_DATAL in the low two AD data storage / low 2, when converted to decimal number, need to be left in the ADC_DATA shift 2, i.e. by 4 ADC_DATAL low two ADCON=0xf7; / / remove marks the end of conversion Return AD_result; / / return results to the function } Char Continue_heating / / set as a global variable, and then continue to complete the key processing by the change of his assignment, to judge the continue heating to 92 degrees, the 1 said to be heated, repeat / / button for 3 seconds to return to normal, the variable is set to 0 Uchar checking / / set as a global variable, its value by the timer interrupt every time plus 1 to 100, 0, AD for interval extraction results on Middle_variable, so the current Comparison of AD and Middle_variable / / results, if it is equal, said electric heating has been extremely bad, unable to work. Uchar NTC_checking / /

文档评论(0)

1亿VIP精品文档

相关文档