frdmkl82z - adc16 issue wtih ADC0_SE4b/ADC0_SE5b

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

frdmkl82z - adc16 issue wtih ADC0_SE4b/ADC0_SE5b

892件の閲覧回数
shai_b
Senior Contributor II

Dear team,

I am working with frdmkl82z_adc16_polling example code and noticed that there is an issue working with some of the ADC ports for example if I am trying to use ADC0_SE4b/ ADC0_SE5b it a appears to be preconfigured to other pin but I did not see that in the code.

I have added the following PinMux to test the ADC

 

スポイラ

 /* PORTC2 (pin 57) is configured as ADC0_SE4b */
PORT_SetPinMux(PORTC, 2U, kPORT_PinDisabledOrAnalog);

/* PORTD1 (pin 74) is configured as ADC0_SE5b */
PORT_SetPinMux(PORTD, 1U, kPORT_PinDisabledOrAnalog);

/* PORTD6 (pin 79) is configured as ADC0_SE7b */
PORT_SetPinMux(PORTD, 6U, kPORT_PinDisabledOrAnalog);

/* PORTB0 (pin 43) is configured as ADC0_SE8 */
PORT_SetPinMux(PORTB, 0U, kPORT_PinDisabledOrAnalog);

/* PORTB1 (pin 44) is configured as ADC0_SE9 */
PORT_SetPinMux(PORTB, 1U, kPORT_PinDisabledOrAnalog);

 

and the main while code I added the following

 

スポイラ


while (1)
{
GETCHAR();

adc16ChannelConfigStruct.channelNumber = 9U;
ADC16_SetChannelConfig(DEMO_ADC16_BASE, DEMO_ADC16_CHANNEL_GROUP, &adc16ChannelConfigStruct);
while (0U == (kADC16_ChannelConversionDoneFlag &
ADC16_GetChannelStatusFlags(DEMO_ADC16_BASE, DEMO_ADC16_CHANNEL_GROUP)))
{
}
PRINTF("ADC0_SE9 ADC Value: %d\r\n", ADC16_GetChannelConversionValue(DEMO_ADC16_BASE, DEMO_ADC16_CHANNEL_GROUP));


adc16ChannelConfigStruct.channelNumber = 8U;
ADC16_SetChannelConfig(DEMO_ADC16_BASE, DEMO_ADC16_CHANNEL_GROUP, &adc16ChannelConfigStruct);
while (0U == (kADC16_ChannelConversionDoneFlag &
ADC16_GetChannelStatusFlags(DEMO_ADC16_BASE, DEMO_ADC16_CHANNEL_GROUP)))
{
}
PRINTF("ADC0_SE8 ADC Value: %d\r\n", ADC16_GetChannelConversionValue(DEMO_ADC16_BASE, DEMO_ADC16_CHANNEL_GROUP));

adc16ChannelConfigStruct.channelNumber = 7U;
ADC16_SetChannelConfig(DEMO_ADC16_BASE, DEMO_ADC16_CHANNEL_GROUP, &adc16ChannelConfigStruct);
while (0U == (kADC16_ChannelConversionDoneFlag &
ADC16_GetChannelStatusFlags(DEMO_ADC16_BASE, DEMO_ADC16_CHANNEL_GROUP)))
{
}
PRINTF("ADC0_SE7 ADC Value: %d\r\n", ADC16_GetChannelConversionValue(DEMO_ADC16_BASE, DEMO_ADC16_CHANNEL_GROUP));


adc16ChannelConfigStruct.channelNumber = 5U;
ADC16_SetChannelConfig(DEMO_ADC16_BASE, DEMO_ADC16_CHANNEL_GROUP, &adc16ChannelConfigStruct);
while (0U == (kADC16_ChannelConversionDoneFlag &
ADC16_GetChannelStatusFlags(DEMO_ADC16_BASE, DEMO_ADC16_CHANNEL_GROUP)))
{
}
PRINTF("ADC0_SE5 ADC Value: %d\r\n", ADC16_GetChannelConversionValue(DEMO_ADC16_BASE, DEMO_ADC16_CHANNEL_GROUP));

adc16ChannelConfigStruct.channelNumber = 4U;
ADC16_SetChannelConfig(DEMO_ADC16_BASE, DEMO_ADC16_CHANNEL_GROUP, &adc16ChannelConfigStruct);
while (0U == (kADC16_ChannelConversionDoneFlag &
ADC16_GetChannelStatusFlags(DEMO_ADC16_BASE, DEMO_ADC16_CHANNEL_GROUP)))
{
}
PRINTF("ADC0_SE4 ADC Value: %d\r\n", ADC16_GetChannelConversionValue(DEMO_ADC16_BASE, DEMO_ADC16_CHANNEL_GROUP));

 

}

 

It looks like all the Pins work fine excluding these ADC0_SE4b/ADC0_SE5b pins which show misreading results 

see below my Terminal polt:

ADC0_SE8 ADC Value: 1           (Low)
ADC0_SE7 ADC Value: 4094     (High)
ADC0_SE5 ADC Value: 3426     (Low)
ADC0_SE4 ADC Value: 2802     (Low)
ADC0_SE9 ADC Value: 4092     (High)

the ADC0_SE5 ADC and ADC0_SE4 ADC values should be low (0 or 1, like ADC0_SE8), could you please advise what am I doing wrong?

Wating for your kind feedback, Thanks a lot.

KR,

Shai

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

878件の閲覧回数
EdwinHz
NXP TechSupport
NXP TechSupport

Hello @shai_b,

Some sample pins share the same channel index as shown in Figure 39-1 of the KL82 Reference Manual. To select between channel A and channel B for said pins, you can use the following function:

void ADC16_SetChannelMuxMode(ADC_Type *base, adc16_channel_mux_mode_t mode)

 

Let me know if this helps,

Edwin.

0 件の賞賛
返信