I am having some very odd problems that have only recently started appearing while running code in an MSP430G2553.
Basically what I am seeing are instances where variables and bits are not getting set while the device is running, but when I am debugging, if I break the execution prior to the assignment statement(s) and continue by single-stepping or continuing to run, it will correctly assign the bits.
For instance, I have a routine that re-enables an interrupt by setting the P2IE.BIT7 = 1, then sets a flag variable to state that the interrupt is enabled. I noticed during execution that it would never enter the interrupt. It was executing the routine, because I could see that the flag variable was getting set, but looking at the registers in the CCS after a halt, the P2IE.BIT7 bit was still 0. I've checked that no other functions are clearing that bit.
The interesting thing is, if I break the program right before it executes that routine, and then continue, or even single-step, it WILL set the bit.
Another example from the same program. In a SPI routine, using the USCI_B interface, I have a routine where the MSP430 is gathering data from a sensor and then writing that sensor data to an external EEPROM. Previously it was working fine. I later noticed that the firmware was getting stuck checking a status bit in the EEPROM. The procedure, in accordance with the data sheet, was to put it into write mode by setting the status register, writing to it, disable write, and check the status register bit for a write-in-progress before continuing. When I ran the program from debug and paused it, it was clearly 'stuck' in that routine, constantly checking the status register. I put a logic analyzer on the SPI bus, and it was working correctly, showing a RDSR followed by the status register state on the MISO. The SR value on the bus was 0x02, and WIP was bit 0, indicating that the write was complete. When I paused the debugger, the temp variable reading the data out of the status register was 0xFF.
I know the SPI config is correct because I can see it directly on the logic analyzer. Here's the kicker - if I break the debugger just before it reads the status register, it will correctly read a value of 0x02 whether I continue or single-step, and the program will proceed.
The way I solved it was by putting an extra dummy 0x00 write to the SPI bus before reading the UCB0RXBUF, I assure you, I am checking the TXIFG and RXIFG, and UCBUSY. This does not appear to be a SPI timing issue.
I am suspecting that something is wrong with the chip, or the compiled code, etc. It seems to me that neither of these things should be happening. The fact that they don't happen when I am debugging indicates to me that it may not be related directly to the firmware.
What could cause these issues? Any help would be appreciated.