普中科技F28335开发板的TLV320AIC23 芯片初始化
本帖最后由 准音频算法工程师 于 2024-8-25 11:31 编辑<p>我不懂这段商家提供的代码:</p>
<p>void main()</p>
<p>{<br />
AIC23Write(0x00,0x00);<br />
Delay(100);<br />
AIC23Write(0x02,0x00);<br />
Delay(100);<br />
AIC23Write(0x04,0x7f);<br />
Delay(100);<br />
AIC23Write(0x06,0x7f);<br />
Delay(100);<br />
AIC23Write(0x08,0x14);<br />
Delay(100);<br />
AIC23Write(0x0A,0x00);<br />
Delay(100);<br />
AIC23Write(0x0C,0x00);<br />
Delay(100);<br />
AIC23Write(0x0E,0x43);<br />
Delay(100);<br />
AIC23Write(0x10,0x23);<br />
Delay(100);<br />
AIC23Write(0x12,0x01);<br />
Delay(100); //AIC23Init<br />
}</p>
<p> </p>
<p>Uint16 AIC23Write(int Address,int Data)<br />
{</p>
<p><br />
if (I2caRegs.I2CMDR.bit.STP == 1)<br />
{<br />
return I2C_STP_NOT_READY_ERROR;<br />
}</p>
<p> // Setup slave address<br />
I2caRegs.I2CSAR = 0x1A;</p>
<p> // Check if bus busy<br />
if (I2caRegs.I2CSTR.bit.BB == 1)<br />
{<br />
return I2C_BUS_BUSY_ERROR;<br />
}</p>
<p> // Setup number of bytes to send<br />
// MsgBuffer + Address<br />
I2caRegs.I2CCNT = 2;<br />
I2caRegs.I2CDXR = Address;<br />
I2caRegs.I2CDXR = Data;<br />
// Send start as master transmitter<br />
I2caRegs.I2CMDR.all = 0x6E20;<br />
return I2C_SUCCESS;</p>
<p>}</p>
<p><br />
根据注释,应该就是TLV320AIC23 芯片的初始化代码,但是我不是很能理解其中的含义。对照芯片资料的寄存器映射,发现不能和代码一一对应。比如AIC23Write(0x0A,0x00); 0x0A对应的二进制是1010,并不能在寄存器映射中找到这样的地址。<br />
噢噢,我明白了。地址只有7位,是我输入16进制转2进制的高七位。原来如此,这下代码能和寄存器地址一一对应了。</p>
<p> </p>
<p> </p>
<p><font face="微软雅黑"><font style="overflow-wrap:break-word; font-size:16px; color:#333333; font-family:微软雅黑; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#ffffff; text-decoration-style:initial; text-decoration-color:initial"><font style="overflow-wrap:break-word; font-size:18px"> AIC23Write(0x00,0x1f);//左声道输入音量</font></font></font><br style="overflow-wrap:break-word; color:#333333; font-family:微软雅黑; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#ffffff; text-decoration-style:initial; text-decoration-color:initial" />
<font face="微软雅黑"><font style="overflow-wrap:break-word; font-size:16px; color:#333333; font-family:微软雅黑; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#ffffff; text-decoration-style:initial; text-decoration-color:initial"><font style="overflow-wrap:break-word; font-size:18px"> Delay(100);</font></font></font><br style="overflow-wrap:break-word; color:#333333; font-family:微软雅黑; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#ffffff; text-decoration-style:initial; text-decoration-color:initial" />
<font face="微软雅黑"><font style="overflow-wrap:break-word; font-size:16px; color:#333333; font-family:微软雅黑; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#ffffff; text-decoration-style:initial; text-decoration-color:initial"><font style="overflow-wrap:break-word; font-size:18px"> AIC23Write(0x02,0x1f);//右声道输入音量</font></font></font><br style="overflow-wrap:break-word; color:#333333; font-family:微软雅黑; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#ffffff; text-decoration-style:initial; text-decoration-color:initial" />
<font face="微软雅黑"><font style="overflow-wrap:break-word; font-size:16px; color:#333333; font-family:微软雅黑; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#ffffff; text-decoration-style:initial; text-decoration-color:initial"><font style="overflow-wrap:break-word; font-size:18px"> Delay(100);</font></font></font><br style="overflow-wrap:break-word; color:#333333; font-family:微软雅黑; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#ffffff; text-decoration-style:initial; text-decoration-color:initial" />
<font face="微软雅黑"><font style="overflow-wrap:break-word; font-size:16px; color:#333333; font-family:微软雅黑; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#ffffff; text-decoration-style:initial; text-decoration-color:initial"><font style="overflow-wrap:break-word; font-size:18px"> AIC23Write(0x04,0xBf);//左声道输出音量</font></font></font><br style="overflow-wrap:break-word; color:#333333; font-family:微软雅黑; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#ffffff; text-decoration-style:initial; text-decoration-color:initial" />
<font face="微软雅黑"><font style="overflow-wrap:break-word; font-size:16px; color:#333333; font-family:微软雅黑; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#ffffff; text-decoration-style:initial; text-decoration-color:initial"><font style="overflow-wrap:break-word; font-size:18px"> Delay(100);</font></font></font><br style="overflow-wrap:break-word; color:#333333; font-family:微软雅黑; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#ffffff; text-decoration-style:initial; text-decoration-color:initial" />
<font face="微软雅黑"><font style="overflow-wrap:break-word; font-size:16px; color:#333333; font-family:微软雅黑; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#ffffff; text-decoration-style:initial; text-decoration-color:initial"><font style="overflow-wrap:break-word; font-size:18px"> AIC23Write(0x06,0xBf);//右声道输出音量</font></font></font><br style="overflow-wrap:break-word; color:#333333; font-family:微软雅黑; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#ffffff; text-decoration-style:initial; text-decoration-color:initial" />
<font face="微软雅黑"><font style="overflow-wrap:break-word; font-size:16px; color:#333333; font-family:微软雅黑; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#ffffff; text-decoration-style:initial; text-decoration-color:initial"><font style="overflow-wrap:break-word; font-size:18px"> Delay(100);</font></font></font><br style="overflow-wrap:break-word; color:#333333; font-family:微软雅黑; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#ffffff; text-decoration-style:initial; text-decoration-color:initial" />
<font face="微软雅黑"><font style="overflow-wrap:break-word; font-size:16px; color:#333333; font-family:微软雅黑; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#ffffff; text-decoration-style:initial; text-decoration-color:initial"><font style="overflow-wrap:break-word; font-size:18px"> AIC23Write(0x08,0x12);//DAC选择,lin输入//AIC23Write(0x08,0x14);//DAC选择,MIC输入</font></font></font><br style="overflow-wrap:break-word; color:#333333; font-family:微软雅黑; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#ffffff; text-decoration-style:initial; text-decoration-color:initial" />
<font face="微软雅黑"><font style="overflow-wrap:break-word; font-size:16px; color:#333333; font-family:微软雅黑; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#ffffff; text-decoration-style:initial; text-decoration-color:initial"><font style="overflow-wrap:break-word; font-size:18px"> Delay(100);</font></font></font><br style="overflow-wrap:break-word; color:#333333; font-family:微软雅黑; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#ffffff; text-decoration-style:initial; text-decoration-color:initial" />
<font face="微软雅黑"><font style="overflow-wrap:break-word; font-size:16px; color:#333333; font-family:微软雅黑; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#ffffff; text-decoration-style:initial; text-decoration-color:initial"><font style="overflow-wrap:break-word; font-size:18px"> AIC23Write(0x0A,0x00);</font></font></font><br style="overflow-wrap:break-word; color:#333333; font-family:微软雅黑; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#ffffff; text-decoration-style:initial; text-decoration-color:initial" />
<font face="微软雅黑"><font style="overflow-wrap:break-word; font-size:16px; color:#333333; font-family:微软雅黑; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#ffffff; text-decoration-style:initial; text-decoration-color:initial"><font style="overflow-wrap:break-word; font-size:18px"> Delay(100);</font></font></font><br style="overflow-wrap:break-word; color:#333333; font-family:微软雅黑; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#ffffff; text-decoration-style:initial; text-decoration-color:initial" />
<font face="微软雅黑"><font style="overflow-wrap:break-word; font-size:16px; color:#333333; font-family:微软雅黑; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#ffffff; text-decoration-style:initial; text-decoration-color:initial"><font style="overflow-wrap:break-word; font-size:18px"> AIC23Write(0x0C,0x00);</font></font></font><br style="overflow-wrap:break-word; color:#333333; font-family:微软雅黑; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#ffffff; text-decoration-style:initial; text-decoration-color:initial" />
<font face="微软雅黑"><font style="overflow-wrap:break-word; font-size:16px; color:#333333; font-family:微软雅黑; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#ffffff; text-decoration-style:initial; text-decoration-color:initial"><font style="overflow-wrap:break-word; font-size:18px"> Delay(100);</font></font></font><br style="overflow-wrap:break-word; color:#333333; font-family:微软雅黑; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#ffffff; text-decoration-style:initial; text-decoration-color:initial" />
<font face="微软雅黑"><font style="overflow-wrap:break-word; font-size:16px; color:#333333; font-family:微软雅黑; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#ffffff; text-decoration-style:initial; text-decoration-color:initial"><font style="overflow-wrap:break-word; font-size:18px"> AIC23Write(0x0E,0x43);//AIC23Write(0x0E,0x43);//数字音频接口格式控制,AIC23主模式,dsp初始化,转换比特值设定00即:16bit--》96dB</font></font></font><br style="overflow-wrap:break-word; color:#333333; font-family:微软雅黑; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#ffffff; text-decoration-style:initial; text-decoration-color:initial" />
<font face="微软雅黑"><font style="overflow-wrap:break-word; font-size:16px; color:#333333; font-family:微软雅黑; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#ffffff; text-decoration-style:initial; text-decoration-color:initial"><font style="overflow-wrap:break-word; font-size:18px"> Delay(100);</font></font></font><br style="overflow-wrap:break-word; color:#333333; font-family:微软雅黑; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#ffffff; text-decoration-style:initial; text-decoration-color:initial" />
<font face="微软雅黑"><font style="overflow-wrap:break-word; font-size:16px; color:#333333; font-family:微软雅黑; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#ffffff; text-decoration-style:initial; text-decoration-color:initial"><font style="overflow-wrap:break-word; font-size:18px"> AIC23Write(0x10,0x23);//AIC23Write(0x10,0x23);//设置采样率为16khz;USB模式下时钟为12mhz,采样率为12/272=44.1Khz</font></font></font><br style="overflow-wrap:break-word; color:#333333; font-family:微软雅黑; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#ffffff; text-decoration-style:initial; text-decoration-color:initial" />
<font face="微软雅黑"><font style="overflow-wrap:break-word; font-size:16px; color:#333333; font-family:微软雅黑; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#ffffff; text-decoration-style:initial; text-decoration-color:initial"><font style="overflow-wrap:break-word; font-size:18px"> Delay(100);</font></font></font><br style="overflow-wrap:break-word; color:#333333; font-family:微软雅黑; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#ffffff; text-decoration-style:initial; text-decoration-color:initial" />
<font face="微软雅黑"><font style="overflow-wrap:break-word; font-size:16px; color:#333333; font-family:微软雅黑; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#ffffff; text-decoration-style:initial; text-decoration-color:initial"><font style="overflow-wrap:break-word; font-size:18px"> AIC23Write(0x12,0x01);//激活标志</font></font></font><br style="overflow-wrap:break-word; color:#333333; font-family:微软雅黑; font-size:16px; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#ffffff; text-decoration-style:initial; text-decoration-color:initial" />
<font face="微软雅黑"><font style="overflow-wrap:break-word; font-size:16px; color:#333333; font-family:微软雅黑; font-style:normal; font-variant-ligatures:normal; font-weight:400; text-align:start; white-space:normal; background-color:#ffffff; text-decoration-style:initial; text-decoration-color:initial"><font style="overflow-wrap:break-word; font-size:18px"> Delay(100); //AIC23Init</font></font></font></p>
<p>你找找有没有官方的例程吧。。</p>
tagetage 发表于 2024-8-25 10:24
你找找有没有官方的例程吧。。
<p>我去官网找了,好像没有例程<img height="53" src="https://bbs.eeworld.com.cn/static/editor/plugins/hkemoji/sticker/facebook/sad.gif" width="54" /></p>
tagetage 发表于 2024-8-25 10:17
AIC23Write(0x00,0x1f);//左声道输入音量
&n ...
<p>AIC23Write(0x02,0x1f);//右声道输入音量<br />
右声道输入音量对应的地址不是0x01么?</p>
tagetage 发表于 2024-8-25 10:17
AIC23Write(0x00,0x1f);//左声道输入音量
&n ...
<p>噢噢,我明白了。地址只有7位,是我输入16进制转2进制的高七位。原来如此,这下我能理解代码是什么意思了,谢谢你</p>
准音频算法工程师 发表于 2024-8-25 10:32
AIC23Write(0x02,0x1f);//右声道输入音量
右声道输入音量对应的地址不是0x01么?
<p>噢噢,我明白了。地址只有7位,是我输入16进制转2进制的高七位。原来如此,这下我能理解代码是什么意思了,谢谢你</p>
<p>噢噢,我明白了。地址只有7位,是我输入16进制转2进制的高七位。原来如此,这下我能理解代码是什么意思了。</p>
页:
[1]