这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » 嵌入式开发 » STM32 » 【请教贴】关于vs1003音频模块的问题求教

共4条 1/1 1 跳转至

【请教贴】关于vs1003音频模块的问题求教

菜鸟
2015-06-03 18:31:49     打赏

在做完音频模块的正弦测试和ram测试之后,开始添加音频文件,但是播放出来的一直是嘟嘟的声音,就像坏掉的磁带,求教各位这是怎么回事,都调三天三夜了

部分代码如下:

main函数部分代码:

VS_SPI_Init(16);
while(1){
if((VS_DREQ==1)&(i<800)){
for(n=0;n<32;n++){
VS_XDCS=0;
VS_ReadWriteByte(MusicData[i]);
VS_XDCS=1;
i++;
}
}
if(i==800){
i=0;
}

}

vs1003的初始化函数:

uint16_t VS_Init(void)
{
SPI_InitTypeDef  SPI_InitStructure;
RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI2, ENABLE);

  SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex; //SPI2ÉèÖÃΪÁ½ÏßÈ«Ë«¹¤
  SPI_InitStructure.SPI_Mode = SPI_Mode_Master;                     //ÉèÖÃSPI2ΪÖ÷ģʽ
  SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;                  //SPI·¢ËͽÓÊÕ8λ֡½á¹¹
  SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low;             //´®ÐÐʱÖÓÔÚ²»²Ù×÷ʱ£¬Ê±ÖÓΪµÍµçƽ
  SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge;                 //µÚ¶þ¸öʱÖÓÑØ¿ªÊ¼²ÉÑùÊý¾Ý
  SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;                 //NSSÐźÅÓÉÈí¼þ£¨Ê¹ÓÃSSI룩¹ÜÀí
  SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; //Êý¾Ý´«Êä´ÓMSBλ¿ªÊ¼
  SPI_InitStructure.SPI_CRCPolynomial = 7;     //CRCÖµ¼ÆËãµÄ¶àÏîʽ
SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_128;
SPI_Init(SPI2, &SPI_InitStructure);
  SPI_Cmd(SPI2, ENABLE);

VS_XRST=1;
VS_XCS=1;
VS_XDCS=1;

VS_XRST=0;
delay_ms(SystemCoreClock,500);
VS_XRST=1;
while(VS_DREQ==1);

VS_XCS=0;
VS_ReadWriteByte(0x02);
VS_ReadWriteByte(0x00);
VS_ReadWriteByte(0x00);
VS_ReadWriteByte(0x04);
VS_XCS=1;
while(VS_DREQ==1) return 1;
delay_ms(SystemCoreClock,500);

VS_XCS=0;
VS_ReadWriteByte(0x02);
VS_ReadWriteByte(0x05);
VS_ReadWriteByte(0xbb);
VS_ReadWriteByte(0x81);
VS_XCS=1;
while(VS_DREQ==1) return 1;
delay_ms(SystemCoreClock,500);

VS_XCS=0;
VS_ReadWriteByte(0x02);
VS_ReadWriteByte(0x02);
VS_ReadWriteByte(0x00);
VS_ReadWriteByte(0x55);
VS_XCS=1;
while(VS_DREQ==1) return 1;
delay_ms(SystemCoreClock,500);

VS_XCS=0;
VS_ReadWriteByte(0x02);
VS_ReadWriteByte(0x0b);
VS_ReadWriteByte(0x20);
VS_ReadWriteByte(0x20);
VS_XCS=1;
while(VS_DREQ==1) return 1;
delay_ms(SystemCoreClock,500);

if((VS_ReadReg(0x0b))!=((uint16_t)0x2020)) return 1;

VS_ReadWriteByte(0xff);
VS_ReadWriteByte(0xff);
VS_ReadWriteByte(0xff);
VS_ReadWriteByte(0xff);
return 0;
}


vs1003的调速函数:

uint16_t VS_SPI_Init(uint16_t speed)
{
uint16_t tmp;
SPI_InitTypeDef  SPI_InitStructure;
RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI2, ENABLE);

  SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex; //SPI2ÉèÖÃΪÁ½ÏßÈ«Ë«¹¤
  SPI_InitStructure.SPI_Mode = SPI_Mode_Master;                     //ÉèÖÃSPI2ΪÖ÷ģʽ
  SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;                  //SPI·¢ËͽÓÊÕ8λ֡½á¹¹
  SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low;             //´®ÐÐʱÖÓÔÚ²»²Ù×÷ʱ£¬Ê±ÖÓΪ¸ßµçƽ
  SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge;                 //µÚ¶þ¸öʱÖÓÑØ¿ªÊ¼²ÉÑùÊý¾Ý
  SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;                 //NSSÐźÅÓÉÈí¼þ£¨Ê¹ÓÃSSI룩¹ÜÀí
  SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; //Êý¾Ý´«Êä´ÓMSBλ¿ªÊ¼
  SPI_InitStructure.SPI_CRCPolynomial = 7;     //CRCÖµ¼ÆËãµÄ¶àÏîʽ
//ÉèÖò¨ÌØÂÊÔ¤·ÖƵµÄÖµ
  switch(speed)
  {
    case 2:
      tmp = SPI_BaudRatePrescaler_2;break;
    case 4:
      tmp = SPI_BaudRatePrescaler_4;break;
    case 8:
      tmp = SPI_BaudRatePrescaler_8;break;
    case 16:
      tmp = SPI_BaudRatePrescaler_16;break;
    case 32:
      tmp = SPI_BaudRatePrescaler_32;break;
    case 64:
      tmp = SPI_BaudRatePrescaler_64;break;
    case 128:
      tmp = SPI_BaudRatePrescaler_128;break;
    case 256:
      tmp = SPI_BaudRatePrescaler_256;break;
    default:
return 1;
  }
SPI_InitStructure.SPI_BaudRatePrescaler = tmp;
SPI_Init(SPI2, &SPI_InitStructure);
  SPI_Cmd(SPI2, ENABLE);
return 0;
}




关键词: stm32     vs1003模块     音频    

菜鸟
2015-06-03 20:13:57     打赏
2楼
大神们,给点建议吧

院士
2015-06-03 22:58:16     打赏
3楼

没有使用过这个芯片。不清楚如何使用。

友情帮顶吧


院士
2015-06-04 09:25:13     打赏
4楼
等大神儿给你看看

共4条 1/1 1 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]