This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430G2553 I2C Assembly Problem

Hi,

Today' tried to write an assembly code for I2C master which sends a 2-byte data from an array when button is pressed. I was sure that everything is correct, but it was not working. Then i wrote it in C coding and looked at dis-assembly.  I realized that there were "push R15" and "pop R15" at the beginning and the end of the transmit interrupt service routine. I added them in my code and everything is perfect now. However the problem is that i do not use R15 in my code at all  and i cannot understand why R15 is so important. Is it used especially as a part of I2C communication?

Regards,

Deniz.

  • The compiler pushes and pops R15 because it uses R15 inside the ISR. Since the ISR is interrupting teh main code flow at any point, it has to save every register it clobbers inside the ISR and restore it before exit.

    I don't know why pushing and popping R15 solved the problem for you if your whole code doesn't use R15 at all (in C, this register is usually holding function prameters and function return values)

    Only your code would tell.

**Attention** This is a public forum