89S52 控制 LCD显示、时钟、温度、串口通讯 都搞定了,就是TEA5767没搞定,怎么设置都
LCD显示、时钟、温度、串口通讯 都搞定了,就是TEA5767没搞定,怎么设置都是出噪音!请高手指导下。
TEA5767是89S52用iic协议控制的。
已经搞定, 等整理好上程序 其中有关 IIC 和 TEA5767 的代码如下
/*************************************************************************/
void iic_start()//开始信号
{
/*
SDA=1;
delay(20);// old: delay()
SCL=1;
delay(20);// old: delay()
SDA=0;
delay(20);// old: delay()
*/
SDA = 1;
SCL = 1;
delayNOP();
SDA = 0;
delayNOP();
SCL = 0;
}
void iic_stop() //停止
{
/*
SDA=0;
delay(20);// old: delay()
SCL=1;
delay(20);// old: delay()
SDA=1;
delay(20);// old: delay()
*/
SDA = 0;
delayNOP();
SCL = 1;
delayNOP();
SDA = 1;
}
void iic_respons()//应答
{
uchar i;
SCL=1;
delay(20);// old: delay()
while((SDA==1)&&(i<250))i++;
SCL=0;
delay(20);// old: delay()
}
void iic_init()
{
SDA=1;
delay(20);// old: delay()
SCL=1;
delay(20);// old: delay()
}
void wr1(void)//写数据1
{
SDA=1;
delay(20);//old:delaym(20)
SCL=1;
delay(20);//old:delaym(20)
SCL=0;
delay(20);//old:delaym(20)
SDA=0;
delay(20);//old:delaym(20)
}
void wr0()//写数据0
{
SDA=0;
delay(20);//old:delaym(20)
SCL=1;
delay(20);//old:delaym(20)
SCL=0;
delay(20);//old:delaym(20)
}
void iic_write_byte(uchar byt) //写一个字节的数据到总线上
{
uchar temp=0x00;
uchar count;
for(count=0;count<8;count++)
{
if((byt<<count)&0x80)
wr1();
else
wr0();
}
}
/*
void iic_write_byte(uchar date)
{
uchar i,temp;
temp=date;
for(i=0;i<8;i++)
{
temp=temp<<1;
SCL=0;
delay(20);// old: delay()
SDA=CY;
delay(20);// old: delay()
SCL=1;
delay(20);// old: delay()
}
SCL=0;
delay(20);// old: delay()
SDA=1;
delay(20);// old: delay()
}
*/
/*******************************************
函数名称: TEA5767_writeB
功 能: 向TEA5767写入电阻值数据
参 数: c1为0x20时5767正常工作,为0x26时静音
返回值: success--数据成功标志(为TRUE时写入成功,为FALSE时失败)
/********************************************/
void TEA5767_writeB(uchar a1,uchar b1,uchar c1)
{
//uchar aa;
send_char('1'); //调试信息
iic_start(); //产生START信号
send_char('2'); //调试信息
iic_respons(); //等待START信号发送完毕
//if(TestACK()!=START) //检查是否是START信号发送完毕状态
send_char('3'); //调试信息
iic_write_byte(0xc0); //发送从器件地址
send_char('4'); //调试信息
iic_respons(); //等待发送完毕
//if(TestACK()!=MT_SLA_ACK); //检查是否是从器件地址发送完毕状态
iic_write_byte(a1); //发送TEA5767的数据
iic_respons(); //等待发送完毕
iic_write_byte(b1); //发送TEA5767的数据
iic_respons(); //等待发送完毕
iic_write_byte(c1); //发送TEA5767的数据
iic_respons(); //等待发送完毕
iic_write_byte(0x11); //发送TEA5767的数据
iic_respons(); //等待发送完毕
iic_write_byte(0x00); //发送TEA5767的数据
iic_respons(); //等待发送完毕
//if(TestACK()!=MT_DATA_ACK); //检查是否是数据发送完毕
send_char('o'); //调试信息
iic_stop(); //对TEA5767的一次操作完毕,发送STOP信号
send_char('v'); //调试信息
delayms(10); //等待发送完毕
// }
}
/*************************************************************************/
void tea5767se() //设置收音功能
{
/*
0x2f,0x5c,0x20); //99.1 (hlsi=1)
0x29,0xd4,0x20); //87.5 (hlsi=1)
0x2d,0x7a,0x20); //95.1 (hlsi=1)
frequency:90.9pll(hlsi=1):0x2b 0x73
frequency:93.4pll(hlsi=1):0x2c 0xa4
frequency:99.0pll(hlsi=1):0x2f 0x50
frequency:101.7pll(hlsi=1):0x30 0x9a
frequency:103.7pll(hlsi=1):0x31 0x8e
frequency:99.1pll(hlsi=0):0x2f 0x25
frequency:87.5pll(hlsi=0):0x29 0x9d
frequency:95.1pll(hlsi=0):0x2d 0x3d
frequency:90.9pll(hlsi=0):0x2b 0x3c
frequency:93.4pll(hlsi=0):0x2c 0x6d
frequency:99.0pll(hlsi=0):0x2f 0x19
frequency:101.7pll(hlsi=0):0x30 0x63
frequency:103.7pll(hlsi=0):0x31 0x57
*/
// TEA5767_writeB(0x2f,0x5c,0x20); //99.1中国之声
// 103.7 是我们这里本地信号最好的FM电台
TEA5767_writeB(0x31,0x8e,0x20); //103.7 pll(hlsi=1)
// TEA5767_writeB(0x31,0x57,0x20); //103.7 pll(hlsi=0)
} 已经搞定,哈哈 你好~~我也遇到了一样的问题,怎么弄都是输出沙沙声~请问是什么原因呢? 能不能发布一下图及源码,期待中。。。。。。。 看看你用的是什么电源,纹波多大,建议避免使用开关电源,改用线性电源,即可得到清晰音质。 应该是iic没有设置好。这个问题我也出现过。我的毕业设计就涉及这个。当时就出现楼主这事。现在想来晕 mark lz 可以分析一下当时的原因 ?
页:
[1]