Hello all,
I'm using CCS V5.5 and C/C++ compiler V4.2.4.
For my code I need to develop a little function for I2C access, but it is just for the example, an abstract below:
HWREG16(EUSCI_B0_BASE + OFS_UCBxCTLW1) |= UCSWRST; // Enable SW reset HWREG16(EUSCI_B0_BASE + OFS_UCBxTBCNT) = byteCount; HWREG16(EUSCI_B0_BASE + OFS_UCBxCTLW1) &= ~UCSWRST; // Clear SW reset, resume operation HWREG16(EUSCI_B0_BASE + OFS_UCBxIE) = UCNACKIE; HWREG16(EUSCI_B0_BASE + OFS_UCBxIE) = UCTXIE0; // Enable TX ready interrupt HWREG16(EUSCI_B0_BASE + OFS_UCBxCTLW0) |= UCTR; // I2C TX HWREG16(EUSCI_B0_BASE + OFS_UCBxCTLW0) |= UCTXSTT; // start condition
At the beginning, I wrote simply for example
UCB0CTLW1 |= UCSWRST; // Enable SW reset
But I never had the interrupt (nor Start bit on I2C). I tried a formalism like this:
HWREG16(UCB0CTLW1) |= UCSWRST; // Enable SW reset
Same problem, moreover the code generated in the last two cases was in extended mode (MSP430X) and may be two time heavier than my first example.
In the debugger all was OK, and I discovered that
HWREG16(EUSCI_B0_BASE + OFS_UCBxCTLW0) |= UCTXSTT; // start condition
works perfectly. If I change back this line and only this line, the interrupt failed again.
I have not really the time to investigate as I am really busy and I have a workaround, but do you have any clue about this? I gave a look on HWREG16() and SFR_16BIT(), I can understand that the generated assembly code is more heavier, but not why the code is not functional...
Best regards