ARM板自身的四通道ADC采集的声音波形怎么会这样?

W__day 2015-12-09 03:22:56
用TQ2440开发板ADC做声音采集,AD转换频率是0.5MHz,AD转换时间是10us,采样频率是25KHz,采样点数是1024。采集数据写入文件,之后用Matlab画出采样点数和数值的波形,采集数据代码如下:
(在上层应用ioctl()控制ADC通道切换,四通道引脚悬空或接地或接3.3V时数据均能够正常显示,但是在接入麦克风之后出现波形如图所示那样,跪求大神指导)

#define DEVICE_NAME "/dev/sample"
#define COUNT 1024
int main ()
{
FILE *fp0, *fp1, *fp2, *fp3;
int count = 0;
int fd, ret, value;
char buffer[30];
float temp;
char channel;
// unsigned long arg = 0x63;

fd = open(DEVICE_NAME, 0);
fp0 = fopen("sample1.txt", "w");
fp1 = fopen("sample2.txt", "w");
fp2 = fopen("sample3.txt", "w");
fp3 = fopen("sample4.txt", "w");
if(fp0 == NULL || fp1 == NULL || fp2 == NULL || fp3 == NULL)
{
printf("Open file error!\n");
exit(1);
}

printf("open fd = %d\n", fd);
if(fd < 0)
{
perror("Open ADC Device Failed!\n");
exit(1);
}

while(1)
{
if(count < COUNT)
{
count++;
for(channel = 0; channel < 4; channel++)
{
ioctl(fd, channel, 1);
memset(buffer, 0, 30);
ret = read(fd, buffer, sizeof(buffer) - 1);

if(ret > 0)
{
buffer[ret] = '\0';
sscanf(buffer, "%d\n", &value);
temp =((float)value*3.3)/1024.0;
switch(channel)
{
case 0: fprintf(fp0, "%f\n", temp);
break;
case 1: fprintf(fp1, "%f\n", temp);
break;
case 2: fprintf(fp2, "%f\n", temp);
break;
case 3: fprintf(fp3, "%f\n", temp);
break;
}
// printf("ADC AIN[%d]:voltage:%4.2f Value: %d\n", channel, temp, value);
}
else
{
perror("read ADC device!\n");
exit(1);
}
}
}
else
{
printf("The count of number is OK!\n");
break;
}
// sleep(1);
}
fclose(fp0);
fclose(fp1);
fclose(fp2);
fclose(fp3);
close(fd);
return 0;
}
...全文
197 点赞 收藏 1
写回复
1 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
W__day 2015-12-09
怎么没有图片??
回复
相关推荐
发帖
驱动开发/核心开发
创建于2007-09-28

2.1w+

社区成员

硬件/嵌入开发 驱动开发/核心开发
申请成为版主
帖子事件
创建了帖子
2015-12-09 03:22
社区公告
暂无公告