Changing ADC Channel & Enabling PGA

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

Changing ADC Channel & Enabling PGA

574 Views
mnelson
Contributor I

Hi Everyone,

I'm using a MK10DX256 and have two questions related to enabling the PGA.

1) The Reference Manual states that to use the PGA, you must be on ADC channel DAD2 (ADCH = 00010). I've been hunting through processor expert and I have been unable to find where I can specify the actual channel used by the ADC component. When I dig through the generated code, the value I need changed exists in the AdcLdd1.c file in the ChannelToPin table. By default, it sets the ADCH to 0. I can manually change this to 2 (DAD2) but of course this gets overwritten every time I re-generate my code. Does anyone know how to set this value through PE?

I've tried setting it programmatically after the ADC is initialized, however the generated ISR always re-sets the value after every ISR call.

2. How do I enable the PGA through processor expert? From my looking, it doesn't look like PE supports this yet. I've been able to manually enable it, so it's not a huge issue problem (besides getting the channel set correctly).

Thanks!

1 Reply

311 Views
jch
NXP Employee
NXP Employee

Hi mnelson,

I answer the 2) question first cause it is necessary to initialized the PGA before the ADC starts measure. So to initialize the PGA please add to the project Init_PGA component and place it before ADC_LDD component to be sure that PGA will be initialize before ADC.

For 1) To select appropriate channel you have to use the CreateSampleGroup() or SelectSampleGroup() method. You can find more info on right click of the component-> Help on component -> Typical Usage page.

CreateSampleGroup() - is used for the runtime preparation of the sample group, while SelectSampleGroup() is used to select sample group from prepared in the Property tab ->Static sample group.

After that you can call one of the Start...Measurement() method e.g.: StartSingleMeasurement() method.

Good Luck

Jiri