optimisation settings causing odd behaviour

Hi,

I've recently been experiencing some concern regarding the behaviour of a program, for which the optimiser, when set to favour size [OPTIMIZE (6, SIZE)], occasionally leads to the contents of a global variable getting trashed/overwritten. If the optimisation settings are altered to favour speed, this no longer happens.

It appears not to be an issue with specific XDATA address (where the variable resides), since changing the variables location doesn't prevent this from happening.

The variable in question is only ever modified via a single increment within a timer interrupt function.

Has anyone else experienced anything like this?

IDE: uV2
Compiler: V6.23a
Link/Loc: V4.23

Thanks for any illumination...

David

Parents
  • OK- Found it! The problem was traced to two interrupt routines with different priorities both using the same register bank. One of the interrupt routines is responsible for the modification of the variable in question, so when this is pre-empted by the second higher priority interrupt, the contents of the common register bank get modified, with obvious consequences for the lower priority isr's data.

    Re-evaluating the isr priorities / register banks in order to safeguard against this has eliminated the problem.

    Just thought I'd let you all know, in case anyone experiences this sort of thing for themselves...

Reply
  • OK- Found it! The problem was traced to two interrupt routines with different priorities both using the same register bank. One of the interrupt routines is responsible for the modification of the variable in question, so when this is pre-empted by the second higher priority interrupt, the contents of the common register bank get modified, with obvious consequences for the lower priority isr's data.

    Re-evaluating the isr priorities / register banks in order to safeguard against this has eliminated the problem.

    Just thought I'd let you all know, in case anyone experiences this sort of thing for themselves...

Children
More questions in this forum