can not use clock block independently open an ADC clock

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

can not use clock block independently open an ADC clock

626 Views
ranhao
Contributor I

Can not use  MCUXpresso Config Tools V12.1 "clock" block independently open an ADC clock.

0 Kudos
3 Replies

614 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi @ranhao,

Could you help me provide more information to answer your case properly?

  1. What board or MCU are you using in your project? Is it custom?
  2. What are you referring to when saying "use clock block independently"?
  3. Are you utilizing an example and modifying it with Config Tools?

Best regards, Julian

0 Kudos

599 Views
ywjack
Contributor III

hello :NXP Employee

   

Spoiler
1.png2.png3.png

     I need to consult you about the configuration of ADC_ETC. Now I want to configure an ADC to detect the battery voltage. I use RT1176 microcontroller, and the pin I use is GPIO_AD_34(J16), which has many reuse functions. Now I use the route IOMUXC_GPIO_AD_34_XBAR1_INOUT18, and enable the related configuration, but I find that it is possible to enter ADC interrupt, but read the data is always 0, so I suspect that there is something wrong with my configuration, but I can't find it, you can help me to let me know where the configuration is wrong. Nearby will give me my ADC

Here is my code:

#define DEMO_ADC_BASE LPADC1
#define DEMO_ADC_USER_CHANNEL 0U
#define DEMO_ADC_USER_CMDID 1U
#define DEMO_ADC_CHANNEL_GROUP 0U

#define DEMO_ADC_ETC_BASE ADC_ETC
#define DEMO_ADC_ETC_TRIGGER_GROUP 3U
#define DEMO_ADC_ETC_CHANNEL 1U
#define DEMO_ADC_ETC_DONE0_Handler ADC_ETC_IRQ0_IRQHandler

void ADC_ETC_Configuration(void)
{
adc_etc_config_t adcEtcConfig;
adc_etc_trigger_config_t adcEtcTriggerConfig;
adc_etc_trigger_chain_config_t adcEtcTriggerChainConfig;

/* Initialize the ADC_ETC. */
ADC_ETC_GetDefaultConfig(&adcEtcConfig);
adcEtcConfig.XBARtriggerMask = 0x08U; /* Enable the external XBAR trigger3. */
ADC_ETC_Init(DEMO_ADC_ETC_BASE, &adcEtcConfig);

/* Set the external XBAR trigger0 configuration. */
adcEtcTriggerConfig.enableSyncMode = false;
adcEtcTriggerConfig.enableSWTriggerMode = true;
adcEtcTriggerConfig.triggerChainLength = 0U; /* Chain length 1. */
adcEtcTriggerConfig.triggerPriority = 0U;
adcEtcTriggerConfig.sampleIntervalDelay = 0U;
adcEtcTriggerConfig.initialDelay = 0U;
ADC_ETC_SetTriggerConfig(DEMO_ADC_ETC_BASE, DEMO_ADC_ETC_TRIGGER_GROUP, &adcEtcTriggerConfig);

/* Set the external XBAR trigger0 chain0 configuration. */
adcEtcTriggerChainConfig.enableB2BMode = false;
adcEtcTriggerChainConfig.ADCHCRegisterSelect = 1U << DEMO_ADC_CHANNEL_GROUP; /* Select ADC_HC0 register to trigger. */
adcEtcTriggerChainConfig.ADCChannelSelect = DEMO_ADC_ETC_CHANNEL; /* ADC_HC0 will be triggered to sample Corresponding channel. */
adcEtcTriggerChainConfig.InterruptEnable = kADC_ETC_Done0InterruptEnable; /* Enable the Done0 interrupt. */
#if defined(FSL_FEATURE_ADC_ETC_HAS_TRIGm_CHAIN_a_b_IEn_EN) && FSL_FEATURE_ADC_ETC_HAS_TRIGm_CHAIN_a_b_IEn_EN
adcEtcTriggerChainConfig.enableIrq = true; /* Enable the IRQ. */
#endif /* FSL_FEATURE_ADC_ETC_HAS_TRIGm_CHAIN_a_b_IEn_EN */
/* Configure the trigger group chain 0. */
ADC_ETC_SetTriggerChainConfig(DEMO_ADC_ETC_BASE, DEMO_ADC_ETC_TRIGGER_GROUP, 0U, &adcEtcTriggerChainConfig);
}

void LPADC_Configuration(void)
{
lpadc_config_t lpadcConfig;
lpadc_conv_command_config_t lpadcCommandConfig;
lpadc_conv_trigger_config_t lpadcTriggerConfig;

/* Initialize the ADC module. */
LPADC_GetDefaultConfig(&lpadcConfig);
LPADC_Init(DEMO_ADC_BASE, &lpadcConfig);

#if (defined(FSL_FEATURE_LPADC_HAS_CFG_CALOFS) && FSL_FEATURE_LPADC_HAS_CFG_CALOFS)
/* Do offset calibration. */
LPADC_DoOffsetCalibration(DEMO_ADC_BASE, SystemCoreClock);
#endif /* FSL_FEATURE_LPADC_HAS_CFG_CALOFS */

/* Set conversion CMD configuration. */
LPADC_GetDefaultConvCommandConfig(&lpadcCommandConfig);
lpadcCommandConfig.channelNumber = DEMO_ADC_USER_CHANNEL;
LPADC_SetConvCommandConfig(DEMO_ADC_BASE, DEMO_ADC_USER_CMDID, &lpadcCommandConfig);

/* Set trigger configuration. */
LPADC_GetDefaultConvTriggerConfig(&lpadcTriggerConfig);
lpadcTriggerConfig.targetCommandId = DEMO_ADC_USER_CMDID;
lpadcTriggerConfig.enableHardwareTrigger = true;
LPADC_SetConvTriggerConfig(DEMO_ADC_BASE, 0U, &lpadcTriggerConfig);
}

void DEMO_ADC_ETC_DONE0_Handler(void)
{
ADC_ETC_ClearInterruptStatusFlags(DEMO_ADC_ETC_BASE, kADC_ETC_Trg3TriggerSource, kADC_ETC_Done0StatusFlagMask);
g_AdcConversionDoneFlag = true;
/* Get result from the trigger source chain 0. */
g_AdcConversionValue = ADC_ETC_GetADCConversionValue(DEMO_ADC_ETC_BASE, DEMO_ADC_ETC_TRIGGER_GROUP, 1U);
__DSB();
}

 

while (1)
{

g_AdcConversionDoneFlag = false;
PRINTF("Press any key to get user channel's ADC value.\r\n");
GETCHAR();
ADC_ETC_DoSoftwareTrigger(DEMO_ADC_ETC_BASE, DEMO_ADC_ETC_TRIGGER_GROUP); /* Do software XBAR trigger3. */
while (!g_AdcConversionDoneFlag)
{
}
PRINTF("ADC conversion value is %d\r\n", g_AdcConversionValue);
}

 

0 Kudos

579 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi @ywjack,

From the code, it seems you are using the lpadc_etc_software_trigger_conv example, is this correct?

If it is so, please take a look into the "readme.txt" file under "doc" in Project Explorer tab on the left. Inside the file is the description of the example you want to run, and in this case, the Board settings indicate which instance and pin is used for measuring:

"Board settings

==============

ADC0_IN0 is ADC input. Please sample voltage by J9-10 pin."

 

Please test the example with this pin. If you have any doubts about anything else, do not hesitate to ask!

Best regards, Julian

0 Kudos