📄 8bit_adc_polled.c
字号:
#include <sn8p2758.h>
#include "adc_8bit.h"
unsigned int adc_buf;
void main (void)
{
FADENB=1; // Enable ADC circuit
delay(200); // Delay 100us
P4UR=0xfe; // Disable P4.0 pull-up resistor
P4M=0x00; // Set P40 as input pin
P4CON=0x01; // Set P40 as pure analog input
ADR=0x40; // To set 8-bit and Fcpu/1.
ADM=0x90; // Enable ADC and set AIN0 input
FADS=1; // To start conversion
while(FEOC==0) // Check EOC flag
NOP(1);
adc_buf=ADB; // To get ADC transform data
}
void delay (unsigned int i)
{
unsigned int j;
for (j=i;j>0;j--)
NOP(1);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -