Reading ADC value debugging

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hi,

Trying to read ADC values, utilizing the debug function.  But it seems , that I cannot use the add watch button, to read the value from the variable.

I am using PSoC 5LP CY8C5888LT*LP097.

The Code:

include "project.h"

int main(void)

{

    // CyGlobalIntEnable; /* Enable global interrupts. */

    IDAC8_1_Start();

    IDAC8_1_SetPolarity(IDAC8_1_SINK);

    ADC_DelSig_1_Start();

    ADC_DelSig_1_StartConvert();

int8 output;

    /* Place your initialization/startup code here (e.g. MyInst_Start()) */

    for(;;)

    {

      if(ADC_DelSig_1_IsEndConversion(ADC_DelSig_1_RETURN_STATUS))

    {

        output = ADC_DelSig_1_GetResult8();

    }

  //IDAC8_1_SetValue(75);

        /* Place your application code here. */

    }

}

0 Likes
1 Solution

You need to just declare the variable above the main()

Eg:

int8 output;

main()

{

Your application

}

Regards,

Bragadeesh

Regards,
Bragadeesh

View solution in original post

0 Likes
7 Replies
BragadeeshV
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hi Tamas,

Declare the variable 'output' as a global variable.

Regards,

Bragadeesh

Regards,
Bragadeesh
Anonymous
Not applicable

Hi Bragadeesh,

How should I do that?

0 Likes

You need to just declare the variable above the main()

Eg:

int8 output;

main()

{

Your application

}

Regards,

Bragadeesh

Regards,
Bragadeesh
0 Likes
Anonymous
Not applicable

Hi again,

I can now add the watchpoint. But unfortunately it does not show the correct input values - from the voltage supply.   From the watch point  I get a value of -37, the reference supply from the psoc is 4.7V.

Below ADC configuration.

pastedImage_0.png

0 Likes

Hi Tamas,

If you are not expecting any signed numbers for the variable (negative values), declare it as unsigned integer.

Eg: uint8 output

Regards,

Bragadeesh

Regards,
Bragadeesh
Anonymous
Not applicable

Hi Bragadeesh,

Better results now. Though, at 1V i am getting a value of 214 ((4.7V/1023)*214 = 0.98V) and at 4V I am getting 96 ((4.7V/1023)*96 = 0.45V). I have no idea why - is because i am using ADC_DelSig_1_GetResult32() at a 10 bit ADC?

0 Likes
Anonymous
Not applicable

I found the mistake, I was using uint8. 

0 Likes