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

Register is not updated.....

Hi

I have an error that shows its ugly head now and then....
The µC I'm using is C8051F122.

When I debug I can locate the problem, but the bug does not show the same place in code all times.

What I see now is that when stepping over the following line:

SMB0CN = 0x44;

The register SMB0CN actually is set to 0xC4. This sets the BUSY bit in the register.

It can be resolved by removing the µC supply, but a RESET won't do. But after some time the problem shows again.....

Does anyone have an idea????

Best Regards....

Parents
  • The compiler can decide to remove variables that are not used. And it can decide to store a variable (all the time or sometimes) in a register. And the variables may not live through the full function call.

    Regarding I2C - you should check the state of the data line to see if any external device is driving the line. There are a number of articles you can Google for that describes how you can switch from I2C to GPIO and pin-toggle the clock line until you get the external device into a state where you can switch back to I2C and send a new start condition.

    Especially if I2C communication is used to equipment on a different PCB, you need to handle situations where a spurious pulse may lock up the transfer.

Reply
  • The compiler can decide to remove variables that are not used. And it can decide to store a variable (all the time or sometimes) in a register. And the variables may not live through the full function call.

    Regarding I2C - you should check the state of the data line to see if any external device is driving the line. There are a number of articles you can Google for that describes how you can switch from I2C to GPIO and pin-toggle the clock line until you get the external device into a state where you can switch back to I2C and send a new start condition.

    Especially if I2C communication is used to equipment on a different PCB, you need to handle situations where a spurious pulse may lock up the transfer.

Children
No data