Unexplainable behaviour of ADCs on HC908JL16

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Unexplainable behaviour of ADCs on HC908JL16

311件の閲覧回数
champion_7891
Contributor I

Hello!

 

 

I am having a really wierd problem with the ADCs of MC68HC908JL16. The odd numbered ADCs will work, the even numbered wont. The ADC is called as:

 

unsigned short int GetADCValue(unsigned char ADCChannelNumber)

{

ADCLK=0x10;

ADCSC=ADCChannelNumber;

 while(1)  {

 if (ADCSC&0x80==0x80)

  break;

 } 

return (unsigned short int) ADRL;
}    

so i initialize in the 8 bit 1 sample mode....the odd adcs will work, but if i use an even numbered ADC like 0,2,4,6 etc. it will not work. Actually, the condition (ADCSC&0x80==0x80) is never met for some reason. The odd channels do work confirmed. I checked this in hardware not software by displaying the ADC's value on an LCD.

 

Any help in this regard will be highly appreciated!

ラベル(1)
0 件の賞賛
1 返信

199件の閲覧回数
bigmac
Specialist III

Hello,

 

You do not mention the crystal or bus frequency you are using.  With your ADIV setting, the bus frequency must fall within the limits 1-2 MHz (or crystal 4-8MHz).

 

You do not mention what you actually observe for the even numbered channels?  Are all ADC inputs configured as inputs, with pullups disabled?  You might also see what result you get with the bandgap reference channel (when properly enabled in the configuration), as this is also an even numbered channel.

 

Even though you may not observe the COCO bit set during debug, it must become set for your wait loop to exit.  If the loop does not exit, COP reset would occur (assuming this is enabled).  More traditionally, the wait loop could be written:

 

while (!(ADCSC & 0x80));  // Wait until COCO bit is set

.

Regards,

Mac

 

0 件の賞賛