我今天一直在研究这个代码类,并向你保证我已经经历了很多次。出于某种原因,每当我设置断点来确定“channelsel”的值时,我得到的都是“0”。我从来没有得到 1、2、3 或 4(我的 MAXCHANNELS 是 5)。
我正在使用:P18F45K22 微控制器和 mplab c18。
请看下面的代码,提前谢谢
int channelsel = 0;
for (channelsel = 0; channelsel < MAXCHANNELS; channelsel++)
{
switch(channelsel)
{
case 0:
SetChanADC(ADC_CH0);
break;
case 1:
SetChanADC(ADC_CH1);
break;
case 2:
SetChanADC(ADC_CH2);
break;
case 3:
SetChanADC(ADC_CH3);
break;
case 4:
SetChanADC(ADC_CH4);
break;
default:
SetChanADC(ADC_CH0);
break;
}
ConvertADC();
while(BusyADC() == TRUE) Delay1TCY();
sampledValue = ReadADC();
setCurrentTemperatureForChannel(channelsel, sampledValue);
sprintf (buf, "current Temp of channel %i is %x \n\r", channelsel, sampledValue);
puts1USART(buf);
Delay10KTCYx(10);
}