PDA

View Full Version : XMC4500 Hexagon-Kit: HMI + ADC don't work together sometimes



MTR
Sep 16th, 2013, 03:34 AM
Hello forum,

that's my first post, so I hope I follow all rules and the things mentioned in the FAQ.

I have a problem using the ADC of the XMC4500 in combination with the OLED-Display:

My project bases on the ADCSYNC001 example project and I added the OLED functions. I want to display the value of the potentiometer at channel 1 of the ADC. All the values are saved in an array and the sum and average are calculated from channel 1.

It works fine but as I added some code (in my opinion completely independent from the rest of the ADC/GUI-Code, e.g. x=5; ) the display shows only a static value and the array contains only this one value although I changed the position of the potentiometer. No errors occured.

When I uncomment this line, the display shows the actual value with changes again.

Did anyone have a similar problem?

Thanks for help and tell me if I did something wrong about posting a thread.

Thanks
MTR

erni
Sep 16th, 2013, 10:30 AM
Hello MTR, I had some problems with the display but nothing like you said.
I my case was an old version of the clock App. I upgraded and solved.
regards
Ernesto

Jackson
Sep 16th, 2013, 11:43 PM
Hi MTR,

Mind to show some of your code snippet? especially the part where you display the value.
And also provide some details of your ADC configuration.
Thank you.

MTR
Sep 17th, 2013, 01:00 AM
Hi,

thanks a lot for the replies! I haven't changed the clock app but it is outdatet, so maybe that helps.

I hope it is ok to post the code here:

CODE:

#include <DAVE3.h> //Declarations from DAVE3 Code Generation
#include "GUI.h"
#include "math.h"

int einlesen (void);
void delay (unsigned int i);
float sortieren();
/* To store the conversion result */
uint16_t Result[3];
static uint16_t count, count1, valid; //counts
uint32_t sum, sum1, sum2;
float avg, avg1;
uint16_t Array[1500] [4]; //array to store results
uint16_t Sort[1500][5];

int main(void)
{
// status_t status; // Declaration of return variable for DAVE3 APIs

DAVE_Init(); // Initialization of DAVE Apps
GUI_Init(); // Initialization GUI

ADC002_InitializeQueue(&ADC002_Handle0);

GUI_SetBkColor(GUI_WHITE); //Background
GUI_Clear(); //clear all
GUI_SetFont(&GUI_Font24B_1);
GUI_SetColor(GUI_BLACK);
GUI_DispStringHCenterAt("Count Valid", 80, 10);
GUI_SetColor(GUI_BLACK);
GUI_DispStringHCenterAt("Avg Result", 80, 50);

sum2=0;

einlesen();

sortieren();




while(1)
{

}
return 0;
}

void delay (unsigned int i) //delay
{
while(i!=0)
{
i--;
}
}

int einlesen (void)
{
for(count=1; count<1501; ++count) //Count Anzahl Messungen
{
ADCSYNC001_GetResult(&ADCSYNC001_Handle0, &ADCSYNC001_MSYNCA_Handle0, &Result[0]);
ADCSYNC001_GetResult(&ADCSYNC001_Handle0, &ADCSYNC001_MSYNCA_SA_Handle0, &Result[1]);
ADCSYNC001_GetResult(&ADCSYNC001_Handle0, &ADCSYNC001_MSYNCA_SB_Handle0, &Result[2]);
ADCSYNC001_ClearResultEvtFlag(&ADCSYNC001_Handle0, &ADCSYNC001_MSYNCA_Handle0);

Array[count][1]=Result[0];
Array[count][0]=count;
Array[count][2]=Result[1];
Array[count][3]=Result[2];

sum=sum+Array[count][1];
avg=sum/(count);

GUI_SetFont(&GUI_Font24B_1);
GUI_SetColor(GUI_BLUE);
GUI_DispDecAt(count, 20, 30, 4); //Ausgabe Messung-Nr
GUI_SetColor(GUI_RED);
GUI_DispDecAt(Result[0], 90, 75, 4); //Ausgabe des letzten Resultats
GUI_DispDecAt(avg, 20, 75, 4);
GUI_DispDecAt(sum, 20, 100, 10);
delay(12000); //Verzögerung

}
return(0);
}


float sortieren()
{
for (count1=1; count1<1501; count1++)
{
if((1000<Array[count1][1]) && (Array[count1][1]<3000))
{
valid=valid+1;
Sort[count1][0]=valid;
Sort[count1][1]=Array[count1][0];
Sort[count1][2]=Array[count1][1];
Sort[count1][3]=Array[count1][2];
Sort[count1][4]=Array[count1][3];

sum1=sum1+Sort[count1][2];
avg1=sum1/valid;


}
}

GUI_SetFont(&GUI_Font24B_1);
GUI_SetColor(GUI_BLUE);
GUI_DispDecAt(valid, 90, 30, 4); //Ausgabe Messung-Nr
GUI_ClearRect(0, 50, 160, 70);
GUI_SetColor(GUI_BLACK);
GUI_DispStringHCenterAt("Avg Avg1", 80, 50);
GUI_SetColor(GUI_RED);
GUI_DispDecAt(avg1, 90, 75, 4); //Ausgabe des letzten Resultats
// GUI_DispDecAt(avg, 20, 75, 4);
GUI_ClearRect(0, 100, 160, 120);

return(0);
}

CODE END



The line with sum2=0; ist not necessary and should have no effect but it makes the ADC to give only one value. When I uncomment this line, the display shows the actual value again.

I have not changed anything in the ADC configuration. I just added the GUI to the example project ADCSYNC001_Example 1.

I add a screenshot of the S/W App Connectivity View.

373
Thanks for help again.
MTR

MTR
Sep 19th, 2013, 12:33 AM
Hi,

I want to update this thread a little bit, because I found a solution for my problem.

The problem in my case seems to be at the Master Channel, because as I added a third slave channel, the conversion works fine! No problems displaying the values and I have not found code that breaks the program yet.


A funny thing right now is the delay function. Although it should increment from only 100 now it takes as long as it took with 10000... Any idea whats the issue with that?

Thanks for your help!
MTR