This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

strange behavior with unsigned long variables

I'm using the cygnal F124 chip. now my program is 33K in size and my ram memory isa bout 7.2K. I use the uart0 to print some information and one LCD, last week my unsigned long variable changed without writting in them.. I use this variables as counters these counters are updated every one second but after 3 o4 seconds this variables change from 200 to 156234324 or another big number!!!!!

I want to know what is the problem here.. these variables are globla! and I only updated by 2 or 3 functions

Another thing is can someone tell me how to optimize the code using the keil compiler. I want to know which pragma function should I have to use to get better performance and dont have this kind of errors

Parents
  • The usual reasons for variables taking on unexpected values include:

    1) Uninitialised pointers
    2) Overwriting array boundaries.
    3) ISR and main program modifying a multibyte variable simultaneously.

    "I want to know which pragma function should I have to use to get better performance"

    You can select the optimisation level through the Options for Target C51 tab. I'd recommend level nine.

    "and dont have this kind of errors"

    It's much more likely that your program contains the errors rather than the optimiser. Changing optimisation level may make the problem appear to come and go, but that doesn't mean the problem lies with the optimiser.

    Stefan

Reply
  • The usual reasons for variables taking on unexpected values include:

    1) Uninitialised pointers
    2) Overwriting array boundaries.
    3) ISR and main program modifying a multibyte variable simultaneously.

    "I want to know which pragma function should I have to use to get better performance"

    You can select the optimisation level through the Options for Target C51 tab. I'd recommend level nine.

    "and dont have this kind of errors"

    It's much more likely that your program contains the errors rather than the optimiser. Changing optimisation level may make the problem appear to come and go, but that doesn't mean the problem lies with the optimiser.

    Stefan

Children