MC9S08PA's ADC of channel register setting

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MC9S08PA's ADC of channel register setting

1,066 Views
Kris_Ke
Contributor III

Dear 

I use CodeWarrior 11.1. I am a bit confused about the PE setting of IO_MAP.h of ADC channel.

The IO_Map.h show the ADCH0 is 0x01U, ADCH1 is 0x02U and so forth.

1.png

But the MC9S08PA4 Reference Manual, Rev. 6, show the AD0 of ADCH is 0, AD1 of ADCH is 1 and so forth.

if I want to get ADC value of AD0, how can I get it?

Is it use below 

ADC_SC1 = ADC_SC1_ADCH0_MASK;

or 

ADC_SC1=ADC_SC1_ADCH_BITNUM;

Kris

Labels (1)
Tags (5)
0 Kudos
4 Replies

971 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Kris,

They are not  contradictory.

"#define ADC_SC1_ADCH0_MASK              0x01U " in the IO_Map.h just some Macros.

The Table9-2 shows how to set ADCH bits when config Input channel.

"if I want to get ADC value of AD0, how can I get it?"

-> I guess you meaning how to select AD0, the answer is

ADC_SC1 = 0x00; ( haven't consider other bits of ADCSC1 Register, only ADCH)

I recommend you refer to the demo code under "Help on Component" of ADC component :

pastedImage_1.png

Have a great day,
TIC

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

971 Views
Kris_Ke
Contributor III

Dear Alice Yang

-> I guess you meaning how to select AD0, the answer is

-> ADC_SC1 = 0x00; ( haven't consider other bits of ADCSC1 Register, only ADCH)

So I can't use ADC_SC1 = ADC_SC1_ADCH0_MASK, because it mean ADC_SC1 = 0x1?

Kris

0 Kudos

971 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Yes.


Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

971 Views
Kris_Ke
Contributor III

Dear Alice

Got it.

So that is my doubt, I know the  ADC_SC1_ADCH0_MASK just is Macros.

And tthe name of the definition will make people misunderstand.

ADCH0 is mean 0x1 for ADCH channel number 1.

ADCH1 is mean 0x2 for ADCH channel number 2.

Kris

0 Kudos