Regarding Pal EQADC

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

Regarding Pal EQADC

858 Views
Krishnayya29
Contributor I

Hi NXP,

i am working on  PAL EQADC of mpc5777c(416 pin).the example which is given by NXp for group conversion 0 is working fine. but when i want to improve this to further level i am facing below issues.

 

1.I increased the channels to 8 because of this callback function is not called as it do for 4 channels.

2.When i configure the group conversion 1 as 0 given by Nxp.it also not working as expected.

 

Please let me know how to configure these and use it efficiently. Thanks in advance for your time and patience.

Below is the code which i have modified.


/* Flag used to store if an ADC PAL conversion group has finished executing */
volatile bool groupConvDone = false;
volatile bool groupConvDone1 = false;

/* Flag used to store the offset of the most recent result in the result buffer */
volatile uint32_t resultLastOffset = 0;


void adc_pal1_callback00(const adc_callback_info_t * const callbackInfo, void * userData)
{
(void) userData;

groupConvDone = true;
resultLastOffset = callbackInfo->resultBufferTail;
}

void adc_pal1_callback01(const adc_callback_info_t * const callbackInfo, void * userData)
{
(void) userData;

groupConvDone1 = true;
resultLastOffset = callbackInfo->resultBufferTail;
}
/*
* Description: Convert a float to null terminated char array
*/
static void floatToStr (const float *srcValue, char *destStr, uint8_t maxLen);
/*!
\brief The main function for the project.
\details The startup initialization sequence is the following:
* - startup asm routine
* - main()
*/
int main(void)
{
/* Write your local variable definition here */
status_t status;
uint8_t selectedGroupIndex;
const uint16_t adcMax = ADC_RESOLUTION;


/* Buffer used to store processed data for serial communication */
char msg[255] =
{ 0, };

/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
#ifdef PEX_RTOS_INIT
PEX_RTOS_INIT(); /* Initialization of the selected RTOS. Macro is defined by the RTOS component. */
#endif
/*** End of Processor Expert internal initialization. ***/

/* Initialize and configure clocks
* - see clock manager component for details
*/
status = CLOCK_SYS_Init(g_clockManConfigsArr, CLOCK_MANAGER_CONFIG_CNT,
g_clockManCallbacksArr, CLOCK_MANAGER_CALLBACK_CNT);
DEV_ASSERT(status == STATUS_SUCCESS);
status = CLOCK_SYS_UpdateConfiguration(0U, CLOCK_MANAGER_POLICY_AGREEMENT);
DEV_ASSERT(status == STATUS_SUCCESS);

/* Initialize pins
* - See PinSettings component for more info
*/
PINS_DRV_Init(NUM_OF_CONFIGURED_PINS, g_pin_mux_InitConfigArr);

/* Initialize the ADC PAL
* - See ADC PAL component for the configuration details
*/
status = ADC_Init(&adc_pal1_instance, &adc_pal1_InitConfig0);
DEV_ASSERT(status == STATUS_SUCCESS);

selectedGroupIndex = 0u; /* Select the index of a SW triggered group of conversions (see ADC PAL component) */

/* Start the selected SW triggered group of conversions */
status = ADC_StartGroupConversion(&adc_pal1_instance, selectedGroupIndex);
DEV_ASSERT(status == STATUS_SUCCESS);
status = ADC_StartGroupConversion(&adc_pal1_instance, 1u);

/* Called only for demonstration purpose - it is not necessary and doesn't influence application functionality. */
status = ADC_StartGroupConversion(&adc_pal1_instance, 1u); /* Starting another SW triggered group while other is running will return BUSY. */
/* Do not place any breakpoints or run step-by-step between the start of the first conversion group
* at line ADC_StartGroupConversion(&adc_pal1_instance, selectedGroupIndex) and line with DEV_ASSERT(status == STATUS_BUSY).
* Otherwise the DEV_ASSERT will fail because of timing restrictions: previous conversion list finishes execution before the second call to
* ADC_StartGroupConversion() => will return different status than expected. */
DEV_ASSERT(status == STATUS_BUSY);

uint8_t iter = 0;
while(true)
{
/* Wait for group to finish */
if((groupConvDone == true))
{
/* Results are directly available in resultBuffer associated with the group at initialization */
/* NOTE: only the 3rd channel is connected to the potentiometer.
* The rest are added to the group for demonstration purposes but the results are not relevant */
resVolts[0] = ((float) adc_pal1_Results00[0] / adcMax) * VREF; /* Convert result to volts */
resVolts [1]= ((float) adc_pal1_Results00[1] / adcMax) * VREF; /* Convert result to volts */
resVolts [2]= ((float) adc_pal1_Results00[2] / adcMax) * VREF; /* Convert result to volts */
resVolts[3] = ((float) adc_pal1_Results00[3] / adcMax) * VREF; /* Convert result to volts */
resVolts [4]= ((float) adc_pal1_Results00[4] / adcMax) * VREF; /* Convert result to volts */
resVolts [5]= ((float) adc_pal1_Results00[5] / adcMax) * VREF; /* Convert result to volts */
resVolts [6]= ((float) adc_pal1_Results00[6] / adcMax) * VREF; /* Convert result to volts */
resVolts [7]= ((float) adc_pal1_Results00[7] / adcMax) * VREF; /* Convert result to volts */

resVolt = resVolts[0] + resVolts[1] + resVolts[2] ;
/* Convert value to string */
floatToStr(&resVolts, msg, 5);

/* Reset flag for group conversion status */
groupConvDone = false;

/* Restart the SW triggered group of conversions */
status = ADC_StartGroupConversion(&adc_pal1_instance, selectedGroupIndex); /* Restart can be avoided if SW triggered group is configured to run in continuous mode */

// DEV_ASSERT(status == STATUS_SUCCESS);
}
if((groupConvDone1 == true))
{
resVolts [8]= ((float) adc_pal1_Results01[0] / adcMax) * VREF; /* Convert result to volts */
resVolts [9]= ((float) adc_pal1_Results01[1] / adcMax) * VREF; /* Convert result to volts */
resVolts [10]= ((float) adc_pal1_Results01[2] / adcMax) * VREF; /* Convert result to volts */
resVolts [11]= ((float) adc_pal1_Results01[3] / adcMax) * VREF; /* Convert result to volts */
resVolts [12]= ((float) adc_pal1_Results01[4] / adcMax) * VREF; /* Convert result to volts */
resVolts [13]= ((float) adc_pal1_Results01[5] / adcMax) * VREF; /* Convert result to volts */
resVolts [14]= ((float) adc_pal1_Results01[6] / adcMax) * VREF; /* Convert result to volts */
resVolts [15]= ((float) adc_pal1_Results01[7] / adcMax) * VREF; /* Convert result to volts */
groupConvDone1 = false;
status = ADC_StartGroupConversion(&adc_pal1_instance, 1); /* Restart can be avoided if SW triggered group is configured to run in continuous mode */

}

}

status = ADC_Deinit(&adc_pal1_instance);
DEV_ASSERT(status == STATUS_SUCCESS);
/*** 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(;;) {
if(exit_code != 0) {
break;
}
}
return exit_code;
/*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/
} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/

Configured as Below in processor expert for group conversion 0 and 1.

Krishnayya29_1-1679326444430.png

Krishnayya29_2-1679326508858.png

 

Thanks,

Krishnayya

 

0 Kudos
Reply
6 Replies

831 Views
davidtosenovjan
NXP TechSupport
NXP TechSupport

Could you describe the issue more in detail? What exactly you are facing?

0 Kudos
Reply

828 Views
Krishnayya29
Contributor I

Hi David,

 

Thank you for your Response.

i am working on PAL Eqadc of MPC5777c.SDK example code which was given by NXP for pal Eqadc shows us   to work  with group conversion  0  of Eqadc 1 which involves  four channels.for this call back is working properly and conversions are also happening fine.Below are problems which i am facing.

1.When i increase the channels of group conversion  0  more than 4 ,call back happens only one time where as it should happen continuously. Please  let me know how to make this callback happen continuously.

2.Similar to group conversion  0 ,if i implement group conversion  1 its not working properly as group conversion  0.Please guide me how to make this group conversion  1 also  working as group conversion  0.

i have attached the complete Project folder for your reference.

Thank you,

Krishnayya

 

0 Kudos
Reply

802 Views
Krishnayya29
Contributor I
Hi David ,
Did you got any solution to this problem.Please let me know if you need any further details about this.
0 Kudos
Reply

749 Views
davidtosenovjan
NXP TechSupport
NXP TechSupport

I tested it finding that eQADC module is facing RFIFO overflow and CFIFO underflow. I am not sure why it happens. Generally it happens when conversion trigger is asserted and there is no commands if the CFIFO or RFIFO is full of un-drained results.

If is possible that under SDK environment re-triggering (in continuous mode automatically) happen too fast. Also DMA controller should have priority over CPU.

0 Kudos
Reply

822 Views
davidtosenovjan
NXP TechSupport
NXP TechSupport

Which version of S32DS and SDK you are using? I cannot import this archive to S32DS 2.1.

0 Kudos
Reply

819 Views
Krishnayya29
Contributor I

Hi david,

i am using S32DS 2.1 Power architecture .and sdk version is 3.0.3(S32_SDK_S32PA_RTM_3.0.3).

 

Thanks,

Krishnayya

0 Kudos
Reply