?? max196.c
字號:
#include<reg51.h>
#include "MAX196.h"
//短延時函數:nNop()
void nNop(uchar x)
{
for(;x>0;x--);
}
//長延時函數:LongDelay()
void LongDelay(uint i)
{
uint j;
for(;i>0;i--)
{ for(j=4000;j>0;j--);}
}
//指定通道指定方式采樣函數:nSample()
uint nSample(uchar ch, uchar rng, uchar clk, uchar acqmod)
{
uchar CMod1,CMod2;
uint temp;
uint temp1,temp2;
CMod1 = ((ch&0x07) | ((rng<<3)&0x18) | ((INACQ<<5)&0x20) | ((clk<<6)&0xc0)) & 0xff;
CMod2 = ((ch&0x07) | ((rng<<3)&0x18) | ((EXACQ<<5)&0x20) | ((clk<<6)&0xc0)) & 0xff;
if(acqmod==0) //內部控制模式
{
SetPinData_L(0);
SetCS(0);
SetWR(1);
SetRD(1);
// nNop(1);
PinData_L = CMod1;
SetWR(0);
nNop(1);
SetWR(1);
while(PinINT != 0);
SetPinData_L(1);
SetRD(0);
// nNop(1);
temp1 = PinData_L;
temp2 = PinData_H;
temp = (temp1 | (temp2 << 8)) & 0xfff;
}
else if(acqmod==1) //外部控制模式
{
SetPinData_L(0);
SetCS(0);
SetWR(1);
SetRD(1);
// nNop(1);
PinData_L = CMod2;
SetWR(0);
nNop(1);
SetWR(1);
nNop(1);
// nNop(1);
PinData_L = CMod1;
SetWR(0);
nNop(1);
SetWR(1);
while(PinINT != 0);
SetPinData_L(1);
SetRD(0);
// nNop(1);
temp1 = PinData_L;
temp2 = PinData_H;
temp = (temp1 | (temp2 << 8)) & 0xfff;
}
return(temp);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -