#include<AT89X52.H>
#define uint unsigned int
#define uchar unsigned char
sbit CE = P2^6;
sbit CLK = P2^3;
sbit DATA = P2^4;
sbit DS_CE = P3^3;
void Dtmf_1(uchar Value);
void Delay(uint Value);
void DTMF_BH(uchar L,uchar *Value);
void main(void)
{
uchar HM[]={10,1,3,6,9,9,7,6,8,7,8,1,};
DS_CE = 0;//关掉DS1302,避免干扰;
DTMF_BH(12,HM);//拔手机号码
while(1);//结束
}
void DTMF_BH(uchar L,uchar *Value)
{
uchar i = 0;
CE = 1;
CE = 0;//打开HT9200A的控制端
for(i = 0; i<L;i++)
{
Dtmf_1(Value[i]); //拔号的时间0.5S
Delay(50000);
Delay(50000);
Dtmf_1(0x1F);
Delay(50000);
Delay(50000);
}
CE = 1;
}
void Dtmf_1(uchar Value)
{
uchar i = 0;
for(i = 0;i<5;i++)
{
DATA = Value & 0x01;
CLK = 1;
CLK = 0;
Value >>= 1;
}
DATA =1;
CLK = 1;
}
void Delay(uint Value)
{
while(-- Value);
}
|