|
VS1003录音程序问题:指示灯没熄灭。
unsigned char RIFFHeader0[] = {
'R' , 'I' , 'F' , 'F' , // Chunk ID (RIFF)
0x70, 0x70, 0x70, 0x70, // Chunk payload size (calculate after rec!)
'W' , 'A' , 'V' , 'E' , // RIFF resource format type
'f' , 'm' , 't' , ' ' , // Chunk ID (fmt )
0x14, 0x00, 0x00, 0x00, // Chunk payload size (0x14 = 20 bytes)
0x11, 0x00, // Format Tag (IMA ADPCM)
0x01, 0x00, // Channels (1)
0x80, 0x3e, 0x00, 0x00, // Sample Rate, 0x3e80 = 16.0kHz
0xd7, 0x0f, 0x00, 0x00, // Average Bytes Per Second
0x00, 0x01, // Data Block Size (256 bytes)
0x04, 0x00, // ADPCM encoded bits per sample (4 bits)
0x02, 0x00, // Extra data (2 bytes)
0xf9, 0x01, // Samples per Block (505 samples)
'f' , 'a' , 'c' , 't' , // Chunk ID (fact)
0xc8, 0x01, 0x00, 0x00, // Chunk payload size (456 bytes (zeropad!))
0xff, 0xff, 0xff, 0xff // Number of Samples (calculate after rec!)
// Insert 448 zeroes here!
};
code unsigned char RIFFHeader504[] = {
'd' , 'a' , 't' , 'a' , // Chunk ID (data)
0x70, 0x70, 0x70, 0x70 // Chunk payload size (calculate after rec!)
};
void delayms(unsigned int z)
{
unsigned int t1,y;
for(t1=z;t1>0;t1--)
for(y=110;y>0;y--);
}
void main()
{
unsigned char *p;
unsigned int i;
unsigned int j;
unsigned char c = 0;
unsigned int tmp;
unsigned int r;
unsigned long FileSec=0;
unsigned long SEC_CAL=0;
// key=1;
delayms(10);
VS_Write_Reg(0x03,0x66,0x96);
VS_Write_Reg(0x0c,0x00,0x09);
VS_Write_Reg(0x0d,0x10,0x00);
VS_Write_Reg(0x00,0x18,0x04);
delayms(50);
VS_Write_Reg(0x03,0x66,0x96);
delayms(50);
for (i=0; i<56; i++)
{
buffer = RIFFHeader0;
}
for (i=52; i<504; i++)
{
buffer = 0;
}
for (i=504; i<512; i++)
{
buffer = RIFFHeader504[i-504];
}
led=0; //熄灯
if(f_open(&f1, "test.wav", FA_CREATE_ALWAYS | FA_WRITE))
{
while(1);
}
f_write(&f1, buffer,512, &r);
如果把熄灯那个语句放上一点就正常熄灯了,如下:
unsigned char RIFFHeader0[] = {
'R' , 'I' , 'F' , 'F' , // Chunk ID (RIFF)
0x70, 0x70, 0x70, 0x70, // Chunk payload size (calculate after rec!)
'W' , 'A' , 'V' , 'E' , // RIFF resource format type
'f' , 'm' , 't' , ' ' , // Chunk ID (fmt )
0x14, 0x00, 0x00, 0x00, // Chunk payload size (0x14 = 20 bytes)
0x11, 0x00, // Format Tag (IMA ADPCM)
0x01, 0x00, // Channels (1)
0x80, 0x3e, 0x00, 0x00, // Sample Rate, 0x3e80 = 16.0kHz
0xd7, 0x0f, 0x00, 0x00, // Average Bytes Per Second
0x00, 0x01, // Data Block Size (256 bytes)
0x04, 0x00, // ADPCM encoded bits per sample (4 bits)
0x02, 0x00, // Extra data (2 bytes)
0xf9, 0x01, // Samples per Block (505 samples)
'f' , 'a' , 'c' , 't' , // Chunk ID (fact)
0xc8, 0x01, 0x00, 0x00, // Chunk payload size (456 bytes (zeropad!))
0xff, 0xff, 0xff, 0xff // Number of Samples (calculate after rec!)
// Insert 448 zeroes here!
};
code unsigned char RIFFHeader504[] = {
'd' , 'a' , 't' , 'a' , // Chunk ID (data)
0x70, 0x70, 0x70, 0x70 // Chunk payload size (calculate after rec!)
};
void delayms(unsigned int z)
{
unsigned int t1,y;
for(t1=z;t1>0;t1--)
for(y=110;y>0;y--);
}
void main()
{
unsigned char *p;
unsigned int i;
unsigned int j;
unsigned char c = 0;
unsigned int tmp;
unsigned int r;
unsigned long FileSec=0;
unsigned long SEC_CAL=0;
// key=1;
delayms(10);
VS_Write_Reg(0x03,0x66,0x96);
VS_Write_Reg(0x0c,0x00,0x09);
VS_Write_Reg(0x0d,0x10,0x00);
VS_Write_Reg(0x00,0x18,0x04);
delayms(50);
VS_Write_Reg(0x03,0x66,0x96);
delayms(50);
for (i=0; i<56; i++)
{
buffer = RIFFHeader0;
}
for (i=52; i<504; i++)
{
buffer = 0;
}
led=0; //熄灯
for (i=504; i<512; i++)
{
buffer = RIFFHeader504[i-504];
}
if(f_open(&f1, "test.wav", FA_CREATE_ALWAYS | FA_WRITE))
{
while(1);
}
f_write(&f1, buffer,512, &r); |
阿莫论坛20周年了!感谢大家的支持与爱护!!
一只鸟敢站在脆弱的枝条上歇脚,它依仗的不是枝条不会断,而是自己有翅膀,会飞。
|