Hello. I'm having a bit of trouble with my programming. I'm giving a signal to my board and it will detect and display the maximum and minimum point of the signal wave.
However, I'm not really sure if I wrote my codes correctly.
Also, I'm getting this error :
"operator requires a pointer and an integer as operands"

Here's a part of my codes.

``````ADCON0 = ADC_SINE;
while (ADCON0bits.DONE);             //Terminates the A/D conversion when all the signal are converted

for(j=0;j<i;j++)
{
{
}
}
for(k=0;k<i;k++)
{
{
}
}

CurPosLCD(0x10);
Out_LCD(ROM_TYPE "MIN= ");
Out_Dec_LCD(min);
CurPosLCD(0x20);
Out_LCD(ROM_TYPE "MAX= ");
Out_Dec_LCD(max);
Delay_sec(1);``````

I hope someone could help me out here.

Thank You.

Note: I posted this exact post on a wrong section of the forum.

2
Contributors
2
Replies
4
Views
7 Years
Discussion Span

Two things:

1) Your logic for max is reversed. Use > max, not < max.

``````min=adc_result[0];
for(j=0;j<i;j++)
{
{
}
}
for(k=0;k<i;k++)
{
if(adc_result[k]<max)   //change the < to >
{
}
}``````

and

2) You only need one for loop for this, you can do two tests in
one for loop, no problem.

``````ADCON0 = ADC_SINE;
while (ADCON0bits.DONE);             //Terminates the A/D conversion when all the signal are converted

for(j=0;j<i;j++)
{
{
}
{
}
}
CurPosLCD(0x10);
Out_LCD(ROM_TYPE "MIN= ");
Out_Dec_LCD(min);
CurPosLCD(0x20);
Out_LCD(ROM_TYPE "MAX= ");
Out_Dec_LCD(max);
Delay_sec(1);``````

The rest of your code pertains to the board you're working with. You'll have
to refer to it's reference material for any other errors it's giving you. Line #4 looks dodgy, but I'm not familiar with your board.

``````if(adc_result[j]>max)