几天了,HT9200还是打不出电话。
附上程序。大家能帮我看看么?
CPU:ATMEGA48V
CRYSTAL:4MHz
uint8 numbers[20]={9,1,3,5,3,2,0,4,1,4,0,4,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20};
unsigned char table_dtmf[] = {0x0a,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0d,0x0e,0x0f,0x00,0x0b,0x0c};
// 0 1 2 3 4 5 6 7 8 9 A B C D * #
//==============================================================================
//延时10ms
void delay10ms(unsigned char s)
{
unsigned int i;
while(s--)
{
for(i=0;i<5600;i++);
}
}
//==============================================================================
//发送一个字节
//用视波器测得时钟频率:116.279K
void send_byte(unsigned char num)
{
//将num的低5位发送出去,先发低,后发高
unsigned char i;
for(i=0;i<5;i++)
{
HT9200_CLK_HIG; //下降沿发送数据
if(num&0x01)
{
HT9200_DATA_HIG;
}
else
{
HT9200_DATA_LOW;
}
__delay_cycles(10); //delay 2.5us
HT9200_CLK_LOW; //发送数据
__delay_cycles(10); //delay 2.5us
num>>=1;
}
HT9200_CLK_HIG;
delay10ms(1); //延时让DTMF发出号码
}
//==============================================================================
//拨号
void dial(uint8 *ip)
{
CLI();
unsigned char num;
HT9200_CLK_HIG;
HT9200_CS_LOW;
delay10ms(1); //延时10ms,以使其起振
while((*ip!=0x20))
{
num = *ip++;
send_byte(table_dtmf[num]);
}
send_byte(0xff);
delay10ms(6); //延时60ms,发送DTMF
HT9200_CS_HIG;
HT9200_CLK_HIG;
SEI();
}
//==============================================================================
void main()
{
init_devices();
ANSWER_TEL;
dial(numbers);
while(1)
{
;
}
} |