📄 ad.bak
字号:
//******************************************************
// Filename : AllSerial.c
// Abstract : This file implements main function.
//
// Device : uPD78F0396
// CreateTime: 2006/11/01
// Author :
//******************************************************
#include "UsrComm.h"
#include "AD.h"
void AD_Init(void)
{
ADPC = 0x06; //enable P26,p27 analoy input besides Comm digtal I/0
PM2 = 0xD0; //p27.p26 input mode
ADS = 0;
ADM = 0x00; //fPRS/12 2.7V<=AVref<=5.5V
}
//=====================================
void AD_Start( void )
{
int delay = 200;
SetIORBit(ADM, 0x01); /* comparator operation */
while(delay--);
SetIORBit(ADM, 0x80);
}
//=====================================
void AD_Read( USHORT* buffer )
{
if(ADIF == 0) //finish convert
*buffer = (USHORT)( ADCR >> 6 );
}
//=====================================
void AD_Stop( void )
{
ClrIORBit(ADM, 0x01);
ClrIORBit(ADM, 0x80); // stop AD conversion
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -