|
其中AD2BUG用于对八路通道循环采样,结果放入长度为80的一个数组中,试验证明有效,AD2BUF_Single_Channel用于对同一条通道采样,结果同样存入数组,可是这时的采样值全部为零!请问什么地方出错。谢谢大家!
void AdcRead(u8 channel,u8 *adcvaule)
{
ADCON0 = (channel << 3) | 0x81; // enable ADC
// Delay(3);
Delay(30);
ADGO = 1;
while(ADGO); // wait for conversion complete
*adcvaule = ADRESH;
}
void AD2BUF(void)
{
u8 bufcount;
u8 *mid;
for(bufcount = 0; bufcount < 80; bufcount++) {
AdcRead(bufcount % 8, mid);
Receive_Buffer[bufcount] = *mid;
}
}
void AD2BUF_Single_Channel(u8 channel)
{
u8 bufcount;
u8 *mid;
for(bufcount = 0; bufcount < 80; bufcount++) {
AdcRead(channel, mid);
Receive_Buffer[bufcount] = *mid;
}
} |
|