📄 adc.c
字号:
#include <string.h>
#include "..\inc\44b.h"
#include "..\inc\44blib.h"
#include "..\inc\adc.h"
extern volatile int flag;
void Test_Adc(void)
{
int i;
float d;
rADCPSR=20;
rADCCON=ADCCON_SLEEP;
Uart_Printf("\n Print any key to stop!!\n\n");
Delay(10000);
for(i=1;i<=3;i++)
{
// if (Uart_GetKey()!=0)
// {
// flag=0;
// return;
// }
// else
d=GetADresult(i)*2.5/1024;
Uart_Printf("a%d=%f\n",i,d);
Delay(10000);
}
}
//读取某路模拟量函数:
int GetADresult(int channel)
{
rADCCON=(channel<<2)|ADCCON_ENABLE_START;//which channel A/D conversion starts
Delay(10);
while(!(rADCCON&ADCCON_FLAG));//check Flag bit,if end return ,else wait
return rADCDAT;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -