mega128采样数量的问题
mega128 adc1采样,使用内部ram,部分程序如下:void main(void)
{
unsigned char *adc_str="2.031 \n\n";
//unsigned int Result;
unsigned int adc;
unsigned int adc2;
unsigned char i;
unsigned char j;
unsigned int text=0;
CLI();
InitIO();
Com_init();
SEI();
adc_init();
while(1)
{
text=get_adc();
if(text>200)
{
for(i=0;i<380;i++)
{
adc=get_adc();//读取转换结果
}
for(j=0;j<380;j++)
{
adc2=get_adc();
}
for(i=0;i<380;i++)
{
adc=adc*0.45/1.024*10;
adc_str=(unsigned int)adc/1000+0x30;
adc_str=((unsigned int)adc%1000)/100+0x30;
adc_str=((unsigned int)adc%100)/10+0x30;
adc_str=(unsigned int)adc%10+0x30;
Com_putstring (adc_str,7,&RTbuf_UART0);
}
for(j=0;j<380;j++)
{
adc2=adc2*0.45/1.024*10;
adc_str=(unsigned int)adc2/1000+0x30;
adc_str=((unsigned int)adc2%1000)/100+0x30;
adc_str=((unsigned int)adc2%100)/10+0x30;
adc_str=(unsigned int)adc2%10+0x30;
Com_putstring (adc_str,7,&RTbuf_UART0);
}
text=0;
}
}
}
测试结果如图
请问,为什么采样的数目与我设置的差距这么打呢? unsigned char i;
unsigned char j;
char 改为int lcw_swust 发表于 2013-1-25 10:50 static/image/common/back.gif
unsigned char i;
unsigned char j;
char 改为int
多谢仁兄
页:
[1]