Discussion Forum

Code works after giving a debug statement

Next Thread | Thread List | Previous Thread Start a Thread | Settings

DetailsMessage
Read-Only
Author
Guruprasad K
Posted
22-Jan-2003 06:05 GMT
Toolset
C51
New! Code works after giving a debug statement
Hi,

I have experienced a strange problem. When a particular variable is initailised to a particular value, sometimes it never works. But if a debug statement is put before the initialisation statement, it starts to work.

This problem need not be only during initiasation but this can happen anywhere( i.e... before calling a function or initialising the structure variables etc..). Strange thing is that after removing the debug statement and recompiling, The code works properly.

Sometimes it need not be only debug statement, a "delay" or "wait" can also work wonders.

We are using C51 compiler - ver 3.20. Pls let me know if there is any solution for this. Thanks in advance.

Guruprasad K

Read-Only
Author
erik malund
Posted
22-Jan-2003 16:12 GMT
Toolset
C51
New! RE: Code works after giving a debug statement
When a particular variable .. , a "delay" or "wait" can also work wonders.
sounds a lot like either a timping problem or a variable accessed botd from interrupt and main.

Please elaborate.

Erik
Read-Only
Author
Versus Employee
Posted
22-Jan-2003 16:29 GMT
Toolset
C51
New! RE: Code works after giving a debug statement
When faced with these sort of problems, my first reaction is to suspect the optimiser.

Try:

- Looking at the object code generated, does it look right.

- Turning down the level of optimisation and see if the code starts to work.

Read-Only
Author
erik malund
Posted
22-Jan-2003 16:43 GMT
Toolset
C51
New! RE: Code works after giving a debug statement
Turning down the level of optimisation and see if the code starts to work

If the problem is timing or interrupt interaction, this might hide the problem, rather than fix it.

Erik

Next Thread | Thread List | Previous Thread Start a Thread | Settings