,我用89C51和MT8880CE自动拨号,为什么不行呢 这是我用mt8880编的程序,请哪位大侠能够帮我看看程序有错没 5
#include<reg51.h>#include<absacc.h>#include<stdio.h>#include<intrins.h>#defineucharun...
#include <reg51.h>
#include <absacc.h>
#include <stdio.h>
#include < intrins.h >
#define uchar unsigned char
#define uint unsigned int
sbit rw_8880 =P3^6 ;
sbit cs_8880 =P3^7 ;
sbit rsi_8880 =P3^3 ;
sbit cp_8880 =P3^5 ;
sbit f2_8880 =P2^4 ;
sbit D0_8880=P0^0;
sbit D1_8880=P0^1;
sbit D2_8880=P0^2;
sbit D3_8880=P0^3;
void initsystem(void)
{
P0=P0&0x0f;
f2_8880=1;
}
void delay(count)
{
unsigned char i;
unsigned int j;
for(i=0;i<count;i++)
for(j=0;j<2500;j++)
;
}
//MT8880控制函数
void writecrab(uchar value_cra,value_crb)
{
cs_8880 =0;
cp_8880 =0;
rw_8880 =0;
rsi_8880 =1;
P0=value_cra; //写CRA
cp_8880=1;
_nop_();
_nop_();
cp_8880=0;
P0=value_crb; //写CRB
cp_8880=1;
_nop_();
_nop_();
cp_8880=0;
cs_8880=1;
}
//发送DTMF信号
void senddtmf(uchar dm)
{
cs_8880 =0;
cp_8880 =0;
rw_8880 =0;
rsi_8880=0;
P0=dm;
cp_8880=1;
delay(10);
cp_8880=0;
cs_8880=1;
}
//读MT8880状态寄存器
//输入参数 无
//输出
uchar read_8880status(void)
{
uchar status_dtmf;
cs_8880 =0;
cp_8880 =0;
rw_8880 =1;
rsi_8880 =1;
status_dtmf = P0 ;
cp_8880=1;
delay(10);
cp_8880=0;
cs_8880 =1;
return(status_dtmf);
}
//读MT8880数据寄存器
//输入参数 无
//输出
uchar read_8880data(void)
{
uchar data_dtmf;
cs_8880 =0;
cp_8880 =0;
rw_8880 =1;
rsi_8880 =0;
data_dtmf = P0 ;
cp_8880=1;
delay(10);
cp_8880=0;
cs_8880 =1;
return(data_dtmf);
}
void main(void)
{
initsystem( );
while(1)
{
writecrab(0x0d,0x00);
//read_8880status();
senddtmf(0x0c); //#
delay(20);
senddtmf(0x01);
delay(5);
senddtmf(0x05);
delay(5);
senddtmf(0x08);
delay(5);
senddtmf(0x05);
delay(5);
senddtmf(0x0a);
delay(5);
senddtmf(0x05);
delay(5);
senddtmf(0x07);
delay(5);
senddtmf(0x04);
delay(5);
senddtmf(0x0a);
delay(5);
senddtmf(0x06);
delay(5);
senddtmf(0x04);
delay(5);
}
} 展开
#include <absacc.h>
#include <stdio.h>
#include < intrins.h >
#define uchar unsigned char
#define uint unsigned int
sbit rw_8880 =P3^6 ;
sbit cs_8880 =P3^7 ;
sbit rsi_8880 =P3^3 ;
sbit cp_8880 =P3^5 ;
sbit f2_8880 =P2^4 ;
sbit D0_8880=P0^0;
sbit D1_8880=P0^1;
sbit D2_8880=P0^2;
sbit D3_8880=P0^3;
void initsystem(void)
{
P0=P0&0x0f;
f2_8880=1;
}
void delay(count)
{
unsigned char i;
unsigned int j;
for(i=0;i<count;i++)
for(j=0;j<2500;j++)
;
}
//MT8880控制函数
void writecrab(uchar value_cra,value_crb)
{
cs_8880 =0;
cp_8880 =0;
rw_8880 =0;
rsi_8880 =1;
P0=value_cra; //写CRA
cp_8880=1;
_nop_();
_nop_();
cp_8880=0;
P0=value_crb; //写CRB
cp_8880=1;
_nop_();
_nop_();
cp_8880=0;
cs_8880=1;
}
//发送DTMF信号
void senddtmf(uchar dm)
{
cs_8880 =0;
cp_8880 =0;
rw_8880 =0;
rsi_8880=0;
P0=dm;
cp_8880=1;
delay(10);
cp_8880=0;
cs_8880=1;
}
//读MT8880状态寄存器
//输入参数 无
//输出
uchar read_8880status(void)
{
uchar status_dtmf;
cs_8880 =0;
cp_8880 =0;
rw_8880 =1;
rsi_8880 =1;
status_dtmf = P0 ;
cp_8880=1;
delay(10);
cp_8880=0;
cs_8880 =1;
return(status_dtmf);
}
//读MT8880数据寄存器
//输入参数 无
//输出
uchar read_8880data(void)
{
uchar data_dtmf;
cs_8880 =0;
cp_8880 =0;
rw_8880 =1;
rsi_8880 =0;
data_dtmf = P0 ;
cp_8880=1;
delay(10);
cp_8880=0;
cs_8880 =1;
return(data_dtmf);
}
void main(void)
{
initsystem( );
while(1)
{
writecrab(0x0d,0x00);
//read_8880status();
senddtmf(0x0c); //#
delay(20);
senddtmf(0x01);
delay(5);
senddtmf(0x05);
delay(5);
senddtmf(0x08);
delay(5);
senddtmf(0x05);
delay(5);
senddtmf(0x0a);
delay(5);
senddtmf(0x05);
delay(5);
senddtmf(0x07);
delay(5);
senddtmf(0x04);
delay(5);
senddtmf(0x0a);
delay(5);
senddtmf(0x06);
delay(5);
senddtmf(0x04);
delay(5);
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询