kl25z

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

kl25z

1,477件の閲覧回数
yihanjiang
Contributor I

I am using FRDM-KL25Z development board. I found to read multi channel ADC, I have to read it twice to get the correct data. Seems like the result register didn't get updated for the first read. The issues cannot be exposed when reading single channel.

Here is the example,

     ADC0_SC1A = ADC_SC1_ADCH(8);

     rd1 = ADC0_RA;

     while (ADC0_SC2 & ADC_SC2_ADACT_MASK);

     while(!(ADC0_SC1A & ADC_SC1_COCO_MASK));

     ADC0_SC1A = ADC_SC1_ADCH(8);

     rd1 = ADC0_RA;

     while (ADC0_SC2 & ADC_SC2_ADACT_MASK);

     while(!(ADC0_SC1A & ADC_SC1_COCO_MASK));

I have to do the same algorithm twice. Anybody else got the same issue?

Did I miss anything here?

Btw, I am using Keil uVision as IDE. Thanks.

タグ(1)
0 件の賞賛
返信
2 返答(返信)

1,278件の閲覧回数
yihanjiang
Contributor I

Thanks Hui_Ma, that solves the problem.

0 件の賞賛
返信

1,278件の閲覧回数
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi

When you write ADC channel number to ADC0_SC1A register, there doesn't need to read ADC0_RA register following.

The COCO field in ADCx_SC1n register is the only bit that you have to check if the conversion is complete in polling mode.

You could polling that COCO bit until it is set. Then you could read ADC0_RA register to get the conversion number.

Then you could write ADC channel number to ADC0_SC1A register again to start next round ADC conversion.


Wish it helps.

Have a great day,
Ma Hui
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------