当前位置:网站首页>VS1003调试例程
VS1003调试例程
2022-07-28 11:40:00 【yi_tianchou】
开发工具 IAR
芯片:MSP430F5438
音频模块:VS1003B/VS1053
首先拿到之后,就像这到网上找一个别人做好的驱动直接用,(拿来主义)
找了一天无果,能找到的只是片段,或者芯片型号不对,中间也看了n多的文章介绍VS1003调试例程的,也看了几个驱动.
大概了解.代码不多.不是很复杂.
好
既然网上没有可以,那就拿别人的开始移植.一顿查VS手册,看别人项目的注释,开发完了,测试完全没声音,什么正玄波,什么MP3 ,毛都没一根....
我勒个乖乖.
开始分析
首先 VS1003的几个引脚,是否接错,前后查了几遍,甚至怀疑是不是DREQ 需要上拉电阻.
中间还找了STM的一个开发板,使用ST的工程验证了一下,STM板子上是可以工作的,和 DREQ 有没有上拉电阻无关
然后开始怀疑 波特率的问题,把MPS430的手册拿出来USCI从头到尾查了一遍,VS1003上说明

vs上电默认倍频是1.0x vs的板子上接晶振是 12.88Mhz的,那么算完应该是不大于3M. 好了
开始调SPI的速率,调整到3M,没声音.
不再怀疑代码问题了,开始怀疑人生了
代码再次从头到尾看一遍,没问题,然后对照 stm32的驱动,发现 st的SPI速率调的很低.开始慢慢的降低速率,实际情况是SPI在操作 SCI的时候不能超过 400K.很关键,因为超过了400K,主机发送的数据,从机是无法接收的.此乃问题所在
奇迹出现了,可以正常播放 正玄波了.开心啊.但是开心的没5分钟.发现可以播放正玄波,但是播放MP3文件,兹的一下 DERQ就不在拉高了.
难道速度太快没办法播放完.
调整不论是 频率调高调低,始终只能sin测试,而不能播放MP3文件.然后尝试读取寄存器数据,发现竟然读取不到.
然后找了示波器,对 CS DSC SCLK MISO SIMO 进行测量,发现 SOMI的确数据不对,好先不管了,既然我能写进去,那么应该是正常的,再次翻阅VS的手册.一个细节之前忽略了.:


SDI工作的时候 CS其实是为高的 也就是说 在发送MP3数据的时候应该是把DSC拉低 CS拉高,(其实有点违背SPI cs片选的)
这点把自己坑惨了,期间怀疑是SMCLK和MCLK问题,修改把DCS和CS控制好,
再次测试,MP3可以正常播放了.此前仍然使用的是 400K以下的速率,发现声音不流畅,尝试将spi的速率调高,前提是需要使用SCI 将vs1003的03寄存器倍频到3倍.到此mp3播放流程.


整个的使用流程:
VS10XX_HardwareReset();//通过RES脚 重启vs1003
Mp3DeselectControl(); //拉高 CS脚
Mp3DeselectData();//拉高DCS脚
Mp3SelectData(); //打开数据片选,即开启SDI传 xDCS = 1,选择VS10XX的数据接口
SPI_Write_Byte(0xFF);
SPI_Write_Byte(0xFF);
SPI_Write_Byte(0xFF);
SPI_Write_Byte(0xFF);
Mp3DeselectData(); //关闭数据片选
VS_Write_Reg(0,0x08,0x04); //软件复位,向0号寄存器写入0x0804 SM_SDINEW为1 SM_RESET为1
VS_Write_Reg(3,0x98,0x00); //时钟设置,向3号寄存器写入0x9800 SC_MULT 为4 SC_ADD 为3 SC_FREQ为0
VS_Write_Reg(SPI_VOL ,0x30,0x30); //音量设置,向0B号寄存器 写入 左声道30 右声道30 ---0x00,0x00左右声道均最大音量
Mp3SelectData(); //打开数据片选,注意此时XCS(命令片选)为高电平,SDI有效
SPI_Write_Byte(0); //写入数据,这里写入4个0,是无关数据,用来启动数据传输
SPI_Write_Byte(0);
SPI_Write_Byte(0);
SPI_Write_Byte(0);
Mp3DeselectData(); //关闭数据片选,SDI无效
set_SPI_bps(5);//设置 高频速率
然后就可以测试 正玄波和 mp3播放了
/***********************************************************************
**********
28
** 函数名称 : void VS_SinTest(INT8U x).
** 功能描述 : 正弦测试函数 ,检查 vs1003是否正常 .
** 输入参数 : INT8U x 正弦波频率 .
** 输出参数 : None.
** 返回参数 : None.
***********************************************************************
***********/
void VS_SinTest(int x)
{
VS_Write_Reg(0x00,0x08,0x20);/* 启动测试,向 0 号寄存器写入 0x0820 SM_SDINEW 为 1 SM_TEST 为 1 */
while(!(P2IN&MP3_DREQ)); //VS1003的DREQ为高才能写入数据
Mp3SelectData(); //打开数据片选,即开启SDI传输
SPI_Write_Byte(0x53); /* 写入以下 8 个字节 ,进入正弦测试 */
SPI_Write_Byte(0xef);
SPI_Write_Byte(0x6e);
SPI_Write_Byte(x); /* 参数 x 用来调整正弦测试中正弦波的频率*/
SPI_Write_Byte(0);
SPI_Write_Byte(0);
SPI_Write_Byte(0);
SPI_Write_Byte(0);
VS_delay(60000); /* 这里延时一段时间 ,可以听到“正弦音”*/
VS_delay(60000);
VS_delay(60000);
VS_delay(60000);
VS_delay(60000);
VS_delay(60000);
SPI_Write_Byte(0x45); /* 写入以下 8 个字节 ,退出正弦测试 */
SPI_Write_Byte(0x78);
SPI_Write_Byte(0x69);
SPI_Write_Byte(0x74);
SPI_Write_Byte(0);
SPI_Write_Byte(0);
SPI_Write_Byte(0);
SPI_Write_Byte(0);
Mp3DeselectData(); //关闭数据片选
}
unsigned char VS10XX_SendMusicData( unsigned char *dat)
{
unsigned char i;
while(!(P2IN&MP3_DREQ));
set_SPI_bps(15);
Mp3SelectData(); //打开数据片选,即开启SDI传输
for(i=0; i<8; i++)
{
SPI_Write_Byte(dat[i]);
}
Mp3DeselectData(); //关闭数据片选
return 0;
}
end
https://wenku.baidu.com/view/fa1efcc990c69ec3d4bb756a.html
这个文章写的很好,调试思路比较清晰
边栏推荐
- Basic use of JSON server
- Laravel $object->updated_ At returns the carbon object. How to return the normal time format
- AsiaInfo technology released antdb7.0, a "Telecom grade" core transaction database, to help government and enterprises "trust" to create the future!
- 用C语言开发NES游戏(CC65)06、精灵
- 产学研用 共建开源人才生态 | 2022 开放原子全球开源峰会教育分论坛圆满召开
- Introduction to resttemplate
- Developing NES games (cc65) 05 and palette with C language
- 开源社区三十年 | 2022 开放原子全球开源峰会开源社区三十年专题活动圆满召开
- Let Arduino support nuvotom Xintang
- 金九银十 再不卷就来不及了
猜你喜欢

Jinshanyun rushes to the dual main listing of Hong Kong stocks: the annual revenue of 9billion is a project supported by Lei Jun

设计一个线程池

Come to tdengine Developer Conference and have an insight into the future trend of data technology development

GMT安装与使用

Open source database innovation in the era of digital economy | the 2022 open atom global open source summit database sub forum was successfully held
![[dark horse morning post] LETV 400 employees have no 996 and no internal papers; Witness history! 1 euro =1 US dollar; Stop immediately when these two interfaces appear on wechat; The crackdown on cou](/img/d7/4671b5a74317a8f87ffd36be2b34e1.jpg)
[dark horse morning post] LETV 400 employees have no 996 and no internal papers; Witness history! 1 euro =1 US dollar; Stop immediately when these two interfaces appear on wechat; The crackdown on cou

分布式定时器

Arduino Pro Mini atmega328p connect and light the first LED (at the same time, record the problem of burning failure stk500_recv)

Uninstall Navicat: genuine MySQL official client, really fragrant!

Kuzaobao: summary of Web3 encryption industry news on July 13
随机推荐
On Governance and innovation | the openanolis sub forum of the 2022 open atom global open source summit was successfully held
Tencent two sides: @bean and @component are used in the same class, what will happen?
聚变云原生,赋能新里程 | 2022 开放原子全球开源峰会云原生分论坛圆满召开
Laravel $object->updated_ At returns the carbon object. How to return the normal time format
新东方单季营收5.24亿美元同比降56.8% 学习中心减少925间
PHP ⽉ the simplest way to add and subtract ⽅
Open source database innovation in the era of digital economy | the 2022 open atom global open source summit database sub forum was successfully held
金山云冲刺港股拟双重主要上市:年营收90亿 为雷军力挺项目
分布式定时器
[try to hack] at, SC, PS command authorization
Fusion cloud native, enabling new mileage | 2022 open atom global open source summit cloud native sub forum successfully held
Developing NES games with C language (cc65) 10. Game cycle
Latex矩阵简单使用
Analysis of new retail e-commerce o2o model
Developing NES games with C language (cc65) 08. Background collision
【Try to Hack】udf提权
Live: never believe that suffering is worth it. Suffering is suffering
SQL注入 Less18(头部注入+报错注入)
软件架构师必需要了解的 saas 架构设计?
Foam exploded three times, why did Luo Yonghao put all his eggs in one basket to do ar?