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

📄 ad.h

📁 基于51单片机的心电监护仪程序
💻 H
字号:
#ifndef __AD_H__
#define __AD_H__
byte send_byte (byte a)
{
	byte ii,mask=0x80,t,rb;	
		for(ii=0;ii<8;ii++)
		{
			SCLK=0;
			t=a&mask;
			DIN=(t==0)? 0:1;	    //send bit
			SCLK=1;
			rb=(DOUT==1)? rb|mask:rb&(~mask);	//receive bit
			SCLK=0;
			mask >>= 1;
		}
	return (rb);
}

/********************************/
byte AD_conversion ()
{
    byte RB0,RB1,RB2,result;
    AD_CS=0;
    RB0=send_byte(AD_contr);	    //start the AD conversion
	
    AD_CS=1;
    while (SSTRB==0)	{}	        //wait for the end of converstion
    AD_CS=0;
	
    RB1=send_byte(0x00);	
    RB2=send_byte(0x00);
    AD_CS=1;
    result=(RB1<<2)|(RB2>>6);	    //get the AD result
    return (result);
}

#endif

⌨️ 快捷键说明

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