Variables lose value over time

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

cross mob
Anonymous
Not applicable

I found an interesting issue in PSOC5 (059 kit) and I'd like to share it.

So I was using a variable array for the gain of my ADC channels (8 places). I was confused about the code and did not define them as "const" just normal "double".

What happened was that after 10-12 hours of continuous running, the ADC result started giving garbage values. After much troubleshooting, I realized that the Gain[ADC_Channel] value had changed for some reason. When I used a "# define" macro to assign the gains, everything ran beautifully.

For now I have used 8 different Gain macros and coded the lines manually. However this is tedious and prone to errors.

Any ideas on what is wrong and how to fix it? Will "CYCODE" help here.

I speculate that the variable value is being loaded on to some registers while programming and maybe the register cells are only powered during a write operation. So since there is no write operation for hours together, the registers lose the value over time.

Hope this helps someone else as well.

0 Likes
1 Solution

A breakpoint uses the attached debugger/programmer to halt the executing code either on a specified line (Line Breakpoint) or when a variable is written or read (Data Breakpoint).  There are also address breakpoints and Function breakpoints (to break at specified addresses in code or upon entry to functions respectively).

This can be very helpful for tracking down something in code that's misbehaving.

For line breakpoints, simply right click the line you want to break on in your code and choose "Insert Breakpoint".  The line will be marked with a red circle.  When debugging the code will halt on that line and you can look at the state of your variables and registers at that point.

For a data breakpoint, in creator, go to Debug>New Breakpoint>Variable Watchpoint.

You can then type in which variable you want to break on, and if you want to break when it's read/written/accessed.

View solution in original post

3 Replies
Vasanth
Moderator
Moderator
Moderator
250 sign-ins 500 solutions authored First question asked

Hi,

Could you please keep a breakpoint on write on those variables and see if you could see the point at which it is getting updated ?

Best Regards,
VRS

0 Likes
Anonymous
Not applicable

By "Breakpoint" do you mean an "if" code of some type or is it a feature in PSOC Creator?

Sorry for my lack of knowledge.

0 Likes

A breakpoint uses the attached debugger/programmer to halt the executing code either on a specified line (Line Breakpoint) or when a variable is written or read (Data Breakpoint).  There are also address breakpoints and Function breakpoints (to break at specified addresses in code or upon entry to functions respectively).

This can be very helpful for tracking down something in code that's misbehaving.

For line breakpoints, simply right click the line you want to break on in your code and choose "Insert Breakpoint".  The line will be marked with a red circle.  When debugging the code will halt on that line and you can look at the state of your variables and registers at that point.

For a data breakpoint, in creator, go to Debug>New Breakpoint>Variable Watchpoint.

You can then type in which variable you want to break on, and if you want to break when it's read/written/accessed.