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

Unable to modify a variable....

Hi

I'm having a strange problem that is periodically. By debugging I've located the problem. The setup is as follows:

- MCU = C8051F122, codebanking is used, The .M51 file has been looked through and no memory leaks is present.

1. at startup I call a config function that setup the registers.

2. the system clock is initially set to 24.5 MHz

3. The I2C controller is initialised in a function that is located in bank 1.

In the function that initialises the I2C three global variables (that are declared in bank 0) are set to 0x00 (Note that the variables are declared as extern in the file in bank 1). But here the problem arises. The variables does not update which cause the SMB0CR register to be set to an undesirable value.

The problem doesn't not arise all the time. As an example I've downloaded the same OMF file to 20 MCU's and 1 of them had the problem. Now when downloading a diffrent OMF file to the MCU and then redownloading the OMF file that earlier caused the problem, the problem dissappears.

Does anyone know how to solve the problem, or maybe does anyone have any suggestions?

I've tried to lower the optimization level without any luck.