SCREA 发表于 2013-9-18 11:30:17

vs1003正弦测试问题

VS1003正弦音测试
void VS_SinTest(unsigned char x)
{            
      VS_WriteReg(0x00,0x0820);//启动测试,向0号寄存器写入0x0820   SM_SDINEW为1   SM_TEST为1
      while(VS_DREQ==0);         //等待DREQ变为高电平
      //VS_XDCS=0;                            //打开数据片选 SDI有效
      VS_SelectData()      ;
      VS_WriteByte(0x53);                //写入以下8个字节,进入正弦测试
      VS_WriteByte(0xef);
      VS_WriteByte(0x6e);
      VS_WriteByte(x);                  //参数x用来调整正弦测试中正弦波的频率   FsIdx (b7~b5):采样率表索引   S (b4~b0):正弦波的跃速   频率F=Fs X S / 128
      VS_WriteByte(0);                   //比如x=126 (0b 011 11110) FsIdx=011=3   Fs=22050Hz   S=11110=30    F=22050Hz X 30 /128 =5168 Hz
      VS_WriteByte(0);
      VS_WriteByte(0);
      VS_WriteByte(0);
      Delay_ms(500);                        //这里延时一段时间,为了听到“正弦音”
      VS_WriteByte(0x45);                //写入以下8个字节,退出正弦测试
      VS_WriteByte(0x78);
      VS_WriteByte(0x69);
      VS_WriteByte(0x74);
      VS_WriteByte(0);
      VS_WriteByte(0);
      VS_WriteByte(0);                           
      VS_WriteByte(0);
      //VS_XDCS=1;                            //关闭数据片选 ,SDI无效
      VS_DeselectData();========================================
问 1:这段代码执行耳机就能听到正弦声音?

qq2355355257 发表于 2013-9-18 15:11:06





你参考下Datasheet
页: [1]
查看完整版本: vs1003正弦测试问题