ADC_LDD with PE issue

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

ADC_LDD with PE issue

865 Views
dhruvonline
Contributor III

Hi,

 

I am trying to measure the multiple ADC Channels(Single Ended & Differential) using ADC_LDD component. I am unable to get the result any of ADC Channels as expected. Can someone please suggest the measurement or the modifications in the attached code.

 

When i create the multiple channels in the Sample group setting, it is giving the error "Only 1 samples are supported with this hardware. But Channels count is 8 in the ADC properties.

 

I have tried using ADC0_CreateSampleGroup function also. But i am not able to get the actual results.

 

Here is the code attached. Please suggest.

 

Regards,

Druv 

Original Attachment has been moved to: ADC_Test.rar

Labels (1)
0 Kudos
4 Replies

639 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi Dhruv,

You can add 'Sample group list' and then set the the 'Channel index'.

Please refer the image below:

SelectSampleGroup.png

/* ###################################################################
**     Filename    : main.c
**     Project     : K22_ADC_TEST
**     Processor   : MK22FX512VLQ12
**     Version     : Driver 01.01
**     Compiler    : GNU C Compiler
**     Date/Time   : 2017-05-13, 18:06, # CodeGen: 0
**     Abstract    :
**         Main module.
**         This module contains user's application code.
**     Settings    :
**     Contents    :
**         No public methods
**
** ###################################################################*/
/*!
** @file main.c
** @version 01.01
** @brief
**         Main module.
**         This module contains user's application code.
*/         
/*!
**  @addtogroup main_module main module documentation
**  @{
*/         
/* MODULE main */


/* Including needed modules to compile this module/procedure */
#include "Cpu.h"
#include "Events.h"
#include "ADC0.h"
/* Including shared modules, which are used for whole project */
#include "PE_Types.h"
#include "PE_Error.h"
#include "PE_Const.h"
#include "IO_Map.h"

/* User includes (#include below this line is not maintained by Processor Expert) */

#define SAMPLE_GROUP_SIZE 8U
AD1_TResultData MeasuredValues[SAMPLE_GROUP_SIZE];
LDD_TDeviceData *MyADCPtr;
LDD_TError Error;

/*lint -save  -e970 Disable MISRA rule (6.3) checking. */
int main(void)
/*lint -restore Enable MISRA rule (6.3) checking. */
{
  /* Write your local variable definition here */

  /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
  PE_low_level_init();
  /*** End of Processor Expert internal initialization.                    ***/

  /* Write your code here */
  MyADCPtr = ADC0_Init((LDD_TUserData *)NULL);
  if(Error != 0)
  {
     // SS_ERROR=0x71;
  }
  while(1)
  {
      Error = ADC0_SelectSampleGroup(MyADCPtr, 0U);
      Error =  ADC0_StartSingleMeasurement(MyADCPtr);
      if (Error)
      {
          //SS_ERROR=0x71;
      }
      while (!ADC0_GetMeasurementCompleteStatus(MyADCPtr)) {};
      Error = ADC0_GetMeasuredValues(MyADCPtr, (LDD_TData *)MeasuredValues);
      if ( Error )
            {
                //SS_ERROR=0x71;
            }
  }
 
  /* For example: for(;;) { } */

  /*** Don't write any code pass this line, or it will be deleted during code generation. ***/
  /*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/
  #ifdef PEX_RTOS_START
    PEX_RTOS_START();                  /* Startup of the selected RTOS. Macro is defined by the RTOS component. */
  #endif
  /*** End of RTOS startup code.  ***/
  /*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/
  for(;;){}
  /*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/
} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/

/* END main */
/*!
** @}
*/
/*
** ###################################################################
**
**     This file was created by Processor Expert 10.3 [05.09]
**     for the Freescale Kinetis series of microcontrollers.
**
** ###################################################################
*/

Best Regards,

Robin

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

639 Views
dhruvonline
Contributor III

Hi Robin,

Thanks for the reply.

When i increase the sample list as per the channels used in the same group, it is giving the error. Here is the screen shot. Is it required to create one 8 groups for each channel. What is the measurement sequence.  I have to read the all the 8 channels measurements at a time. Could you please suggest the modifications in the code shared.

Regard,

Druv

pastedImage_1.png

0 Kudos

639 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Please test the attached project.

K22_ADC_TEST_CW10.7.png

/* User includes (#include below this line is not maintained by Processor Expert) */
#define SAMPLE_GROUP_SIZE 8U
LDD_TDeviceData *MyADCPtr;
LDD_TError Error;
signed int val[SAMPLE_GROUP_SIZE];

/*lint -save  -e970 Disable MISRA rule (6.3) checking. */
int main(void)
/*lint -restore Enable MISRA rule (6.3) checking. */
{
  /* Write your local variable definition here */
uint32 i=0;
  /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
  PE_low_level_init();
  /*** End of Processor Expert internal initialization.                    ***/
  /* Write your code here */
  /* For example: for(;;) { } */
  MyADCPtr = ADC0_Init((LDD_TUserData *)NULL);
  for(i=0;i<SAMPLE_GROUP_SIZE;i++)
  {
      Error = ADC0_SelectSampleGroup(MyADCPtr, i);
      Error =  ADC0_StartSingleMeasurement(MyADCPtr);
      while (!ADC0_GetMeasurementCompleteStatus(MyADCPtr)) {};
      Error = ADC0_GetMeasuredValues(MyADCPtr, &val[i]);
  }
  /*** Don't write any code pass this line, or it will be deleted during code generation. ***/
  /*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/
  #ifdef PEX_RTOS_START
    PEX_RTOS_START();                  /* Startup of the selected RTOS. Macro is defined by the RTOS component. */
  #endif
  /*** End of RTOS startup code.  ***/
  /*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/
  for(;;){}
  /*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/
} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/

639 Views
dhruvonline
Contributor III

Hi Robin,

Thanks for your code. It is working. I have tested the same logic with interrupt yesterday as per your suggestions. It is working as expected. But i have to reduce the conversion time by using DMA and PDB. I have tried by enabling the PDB component. But it is going for only one time to trigger the ADC. Could you please suggest the best way to get the samples quickly. Could you please send the reference code with PDB and DMA.

One again thanks for your support.

Regds,

Druv

0 Kudos