Help needed on Processor Expert Coding on ADC_LDD KE06Z

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

Help needed on Processor Expert Coding on ADC_LDD KE06Z

649 Views
eyeow84
Contributor III

I am using FRDM-KE06Z (MKE06Z128VLK4) to measure the temperature (analog input) and display output at hyper terminal with time stamp. I am using CW 10.6 Processor Expert (PE) to generate code for RTC, ConsoleIO and ADC. I have selected the required components from the components library and configured them in component inspector. I don't have major problem on RTC and Console coding since I  can manage to printf the time stamp at the hyper terminal based on internal RTC clocking from controller. My major problem is I cannot get ADC input readings correctly and to display the raw hex value at hyper terminal.

172227_172227.jpgADC_LDD component inspector.jpg 172228_172228.jpgoutput at hyperterminal.jpg

I have attached screen shot of ADC_LDD configuration, main.c code and hyper terminal output.

I follow the typical usage code that can be found at the Help on Component > Component ADC_LDD > Typical Usage.

I suspect the program  stuck at before this line:

 

 

....
while (!AD1_GetMeasurementCompleteStatus(MyADCPtr)) {}; /* Wait for conversion completeness */
Error = AD1_GetMeasuredValues(MyADCPtr, (LDD_TData *)MeasuredValues); /* Read measured values */
i++;
printf("MyADCPtr:0x%x 0x%x MeasuredValues:0x%x 0x%x [%d]\n",MyADCPtr,&MyADCPtr,MeasuredValues, &MeasuredValues, i);
Wait_ms(12000);
}

 

May I know what is the problem? and what is the suggestion to fix it? Thank you in advance.

 

P/S: Before using PE for code generation. I had tried on the ADC_poll_demo sample code from FRDM-KEXX Driver Library Package and it works fine to read and show the raw hex value of each analog channel. I would expect to get the similar kind of raw hex value from the code generated from PE.

Original Attachment has been moved to: main.c.zip

Labels (1)
0 Kudos
1 Reply

415 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Eyeow,

I think is some error in the generate code of PE.

For the function of "AD1_GetMeasurementCompleteStatus()":

bool AD1_GetMeasurementCompleteStatus(LDD_TDeviceData *DeviceDataPtr)
{
  uint8_t Status;
  AD1_TDeviceDataPtr DeviceDataPrv = (AD1_TDeviceDataPtr)DeviceDataPtr;
  Status = DeviceDataPrv->CompleteStatus; /* Save flag for return */
  DeviceDataPrv->CompleteStatus = FALSE; /* Clear measurement complete status flag */
  return (bool)((Status)? TRUE : FALSE); /* Return saved status */
}‍‍‍‍‍‍‍‍

it have not really check the Conversion Complete Flag ADC_SCA -> COCO .

In fact , you can check this flag have been set to "1" :

pastedImage_1.png

So the workaround is change this function , to check the flag of COCO . The detail code please refer to the generated code of KL or K series .

For example create a project about MKL25, then add ADC_LDD component , check the function of "AD1_GetMeasurementCompleteStatus()":

pastedImage_2.png

Also the function of "AD1_GetMeasuredValues" .

Hope it helps


Have a great day,
Alice Yang

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

0 Kudos