欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

標題: 一個簡單的C8051f單片機ADC應用程序和測試 [打印本頁]

作者: oldspring    時間: 2018-10-20 14:32
標題: 一個簡單的C8051f單片機ADC應用程序和測試
以下是一個簡單的8051單片機ADC應用程序和測試:

  1. unsigned int adc_result;
  2. char txt[6];

  3. void main() {

  4.   WDTCN    = 0xDE;                   // Sequence for
  5.   WDTCN    = 0xAD;                   //   disabling the watchdog timer
  6.   OSCICN   = 0x83;                   // Enable internal oscillator (24.5MHz divided by 1)
  7.   P0MDOUT |= 0x01;                   // Configure P0.0 (TX) pin as push-pull

  8.   UART2_Init(4800);                  // Initialize UART2
  9.   Delay_100ms();

  10.   P1MDIN.B2 = 0;                     // Configure P1.2 as Analog Input
  11.   ADC2_Init();                       // Initialize ADC2 module

  12.   while (1) {
  13.     adc_result = ADC2_Get_Sample(2); // Read AIN2.2 (P1.2) analog input
  14.     WordToStr(adc_result, txt);      // convert result to string
  15.     UART2_Write_Text(txt);           // send string to UART
  16.     UART2_Write(13);UART2_Write(10); // send new line (CR+LF)
  17.     Delay_ms(500);
  18.   }
  19. }
復制代碼
相關信息:http://www.raoushi.com/bbs/dpj-136722-1.html








歡迎光臨 (http://www.raoushi.com/bbs/) Powered by Discuz! X3.1