?? call147.c
字號(hào):
/****************************************************************/
/* 這是調(diào)用MAX147的匯編程序(M147B.ASM)的C51程序。 */
/* 文件名CALL147.C。 */
/* 功能:本程序主要是讀出MAX147芯片輸入通道CH0,CH1,...,CH7的模數(shù)*/
/* 轉(zhuǎn)換值,轉(zhuǎn)換值依次放在數(shù)組mid1[8]中,轉(zhuǎn)換值的標(biāo)度變換值放在*/
/* 浮點(diǎn)數(shù)組volt[8]中。MAX147芯片的8個(gè)通道可編程為單極性/雙極 */
/* 性和差動(dòng)/單端工作,這里采用單端\單極性輸入。MAX147有內(nèi)部時(shí) */
/* 鐘和外部時(shí)鐘兩種工作模式,這里采用內(nèi)部時(shí)鐘模式。 */
/****************************************************************/
#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
void timedelay(uint timess);
void delay1(uint x);
extern uint chai; //把全局變量chai聲明為外部變量
extern uint a_func(uchar); //把a(bǔ)_func 聲明為外部函數(shù)
uint idata mid1[8];
float idata volt[8];
uchar i;
void timedelay(uint timess) //延時(shí)程序
{
uint tj;
for (tj=timess;tj>0;tj--){;}
}
void delay1(uint x) //延時(shí)程序
{
uchar tw;
while (x-->0){
for (tw=0;tw<125;tw++){;}
}
}
void main() //主程序
{
SP=0xcf;
timedelay(10000);
delay1(1000);
EA=0;
chai=a_func(0x8e); // 讀出MAX147芯片輸入通道CH0的AD轉(zhuǎn)換值
mid1[0]=chai; // 把它放入數(shù)組mid1中。
chai=a_func(0xce); // 讀出MAX147芯片輸入通道CH1的AD轉(zhuǎn)換值
mid1[1]=chai; // 把它放入數(shù)組mid1中。
chai=a_func(0x9e);
mid1[2]=chai;
chai=a_func(0xde);
mid1[3]=chai;
chai=a_func(0xae);
mid1[4]=chai;
chai=a_func(0xee);
mid1[5]=chai;
chai=a_func(0xbe);
mid1[6]=chai;
chai=a_func(0xfe);
mid1[7]=chai;
for (i=0;i<8;i++){
volt[i]=(mid1[i]/4096.0)*5.0; // 標(biāo)度變換。
}
while(1);
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -