⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 This example program shows how to configure and use the A/D Converter of the following microcontroll
💻 C
字号:
#include<reg166.h>
#include <stdio.h>

#define VREF	5			/* Voltage Reference */

void main (void)
{

/* Set the serial port  */
  P3  |= 0x0400;
  DP3 |= 0x0400;              
  DP3 &= 0xF7FF;
  S0TIC = 0x80;
  S0RIC = 0x00;
  S0BG  = 0x40;
  S0CON = 0x8011;

  while(1);

/* ADC setup		    */
  ADCON |= 0x0080;     /*channel 0 continuous    */

/* Start conversion     */
  ADBSY = 1;

  printf ("ADC0 Count %4u = %01u.%04u Volts\r",
         (unsigned) ADDAT,
         (unsigned) (ADDAT * VREF) >> 10,                          /* Output Integer Portion */
         (unsigned) ((ADDAT * VREF * 10000UL) >> 10UL) % 10000);   /* Output Decimal Portion */            
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -