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.

Program Counter getting lost

Other Parts Discussed in Thread: MSP430F5309

Hello,

I am currently using the MSP430F5309 with I2C and UART interrupts.  As a test of stability, I am sending in a stream of bytes from the PC, while running the code using IAR in debug mode, as well as monitoring the I2C communication lines using an oscilloscope.  When the stream of bytes is shorter, say <= 1000 bytes, there does not seem to be a problem.  However, when I increase this to 10000, after some time, the I2C communication stops and the program counter gets lost to location 010004 (hex), according to the Disassembly window.  I am not sure why this is the case.  I would appreciate any feedback.

Sincerely,

Mehdi

  • It is caused by bugs in your code. The PC did not get lost; you unintentionally caused the PC to become 0x10004. There are lots of ways to write code that gets stuck -- all the time or only under certain circumstances. That kind of code is very easy to write unintentionally. This is one of the challenges of writing programs. You are not alone.

  • Does the fact that the address is 0x10004 mean anything?  I thought the last interrupt vector was 0FFFEh, which is the reset vector.  

  • After a reset, PC is automatically loaded with the contents of 0FFEh-0FFFh (and the most significant 4-bit cleared). Usually, this is the first instruction of your code (if written in assembly code) or the first instruction of c-startup code (if written in c).

    Your code appears to work at that stage as you intended. It is at a much later stage that PC becomes 10004h. One possibility is that somehow PC becomes 10000h and the 4-byte contents at 10000h-10003h looks like a 4-byte instruction. CPU executed that instruction and becomes 10004h. But this is just one possibility amongst too many others and it does not explain why PC becomes 10000h to begin with. 

**Attention** This is a public forum