Clarity on ADC of IMXRT1021

cancel
Showing results for 
Search instead for 
Did you mean: 

Clarity on ADC of IMXRT1021

398 Views
narenchandra401
Contributor III

Hi , we are using imxrt1020 EVK 

With the ADC part there are two ADC ports ADC1,ADC2 each having 16 channels 0-15 

In the data sheet there are registers like ADCx_HC0-8 and Data registers R0-R7 , what are these 8 registers meant for.  

I am confused. There are 16 channels and 8 data registers ? 

In the example algorithm provided by NXP , what does Channel Index mean ? 

If some one gives some clarification it will be helpful

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

269 Views
victorjimenez
NXP TechSupport
NXP TechSupport

Hello, 

In the data sheet there are registers like ADCx_HC0-8 and Data registers R0-R7 , what are these 8 registers meant for.  

Please refer to section 60.8.2 and 60.8.4 of the reference manual. 

I am confused. There are 16 channels and 8 data registers ? 

Even each ADC module contains 16 input channels, the maximum configuration ADC channels are 8. This is the reason why you only have 8 HC and R registers. 

In the example algorithm provided by NXP, what does Channel Index mean? 

The channel index is the input channel that you would like to use as an input for the ADC conversion. The allowed range is 0-31. 


Have a great day,
Victor

-------------------------------------------------------------------------------
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.
-------------------------------------------------------------------------------

269 Views
narenchandra401
Contributor III

Hi Victor

Just look at the below code and guide me where it went wrong 

// Declaration

void ADC_Initialisation(ADC_Type *base);
float Read_ADC(ADC_Type *base,uint32_t Channel);

void ADC_Initialisation(ADC_Type *base)
{
   adc_config_t adcConfigStrcut;

  ADC_GetDefaultConfig(&adcConfigStrcut);
  ADC_Init(base, &adcConfigStrcut);

   #if !(defined(FSL_FEATURE_ADC_SUPPORT_HARDWARE_TRIGGER_REMOVE) && FSL_FEATURE_ADC_SUPPORT_HARDWARE_TRIGGER_REMOVE)
   ADC_EnableHardwareTrigger(base, false);
   #endif


   if (kStatus_Success == ADC_DoAutoCalibration(base))
   {
   // PRINTF("ADC_DoAutoCalibration() Done.\r\n");
   }
   else
   {
   // PRINTF("ADC_DoAutoCalibration() Failed.\r\n");
   }

}

float Read_ADC(ADC_Type *base,uint32_t channelGroup)
{
   adcChannelConfigStruct.channelNumber = channelGroup;
   adcChannelConfigStruct.enableInterruptOnConversionCompleted = false;
   ADC_SetChannelConfig(base, channelGroup, &adcChannelConfigStruct);

   while (0U == ADC_GetChannelStatusFlags(base,channelGroup))
{
}
ADC_val = ADC_GetChannelConversionValue(base, channelGroup) ;

val = (( ADC_val * 3.3 )/4096 );
return val;
}

// Function calls

ADC_Initialisation(ADC1);

result = Read_ADC(ADC1,0U);   // ADC1 - Channel 0 works fine

if i use this 

result = Read_ADC(ADC1,10U);  //ADC1- channel 10 it goes and stops in the below function

void __assertion_failed(char *failedExpr)
{
PRINTF("ASSERT ERROR \" %s \n", failedExpr);
for (;;)
{
__BKPT(0);
}
}

please guide me on where it went wrong 

0 Kudos

269 Views
mitterha
Senior Contributor I

Hello Naren chandra,

maybe these posts help you to understand the ADC + ADC-ETC modules.

Are there bugs in ADC_ETC and ADC driver? 

Understanding ADC + ADC-ETC 

https://community.nxp.com/thread/523907 

Kind regards,

Stefan

269 Views
victorjimenez
NXP TechSupport
NXP TechSupport

Hello Naren chandra, 

What is the problem that you are facing? I highly recommend you to refer to the ADC examples that we provide within the SDK, you can use these projects as a base to see what configurations or steps you are missing on your application. 

Regards, 

Victor 

269 Views
narenchandra401
Contributor III

Thanks Victor , that will help 

0 Kudos