any example code there for diffferential mode adc in frdm-k64?

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

any example code there for diffferential mode adc in frdm-k64?

2,144件の閲覧回数
vimalprasath
Contributor II

Hi ,

I'm using frdm-k64 board.i want to read adc input from ADC0_DM0/ADC1_DM3 pin.

is there any example code for the diffential mode analog reading?

Thanks

0 件の賞賛
返信
3 返答(返信)

1,932件の閲覧回数
nxf51211
NXP Employee
NXP Employee

Hi,

Unfortunately, there is no driver example for the K64 with ADC differential mode. However, you could use the SDK driver example called "adc16_interrupt" and modify it so it can have the differential mode; for that you just have to change the ADC0 channel to the one corresponding to the ADC0_DM0 & ADC0_DP0 (Channel 0):

#define DEMO_ADC16_USER_CHANNEL 0U /* ADC0_DM0 / DP0 */‍‍‍

Also, as Mark just said in his answer, you also have to set the ADC_SC1A_DIFF; for that, in the same driver example just set to true the "enableDifferentialConversion" from the channel configuration:

#if defined(FSL_FEATURE_ADC16_HAS_DIFF_MODE) && FSL_FEATURE_ADC16_HAS_DIFF_MODE
    adc16ChannelConfigStruct.enableDifferentialConversion = true;
#endif /* FSL_FEATURE_ADC16_HAS_DIFF_MODE */‍‍‍‍‍‍‍‍‍

In order to check if this works, check the ADC0_DM0 and ADC0_DP0 from the FRDM-K64:

pastedImage_2.png

I hope this information can help you.

Ricardo Delsordo

0 件の賞賛
返信

1,932件の閲覧回数
eliarad2
Contributor II

Hi 

Differential mode works from (1^N-1) /2 , means from minus to plus half range.

there should be a possibility to make it unsigned differential mode

Can some one tell how to do it in the sdk?

Thanks!

0 件の賞賛
返信

1,932件の閲覧回数
mjbcswitzerland
Specialist V

Hi

For differential mode you just need to set ADC_SC1A_DIFF in addition to the channel reference in ADCx_SC1A.

However differential input between ADC0_DM0 and ADC1_DM3 pin is not possible - it can only be between
ADC0_DM0 and ADC0_DP0
or
ADC1_DM3/ADC1_DP3

etc.

Regards

Mark

Complete Kinetis solutions, training and support: http://www.utasker.com/kinetis.html