SLAZ237O October 2012 – May 2021 MSP430F47196
USCI Module
Functional
Timing of USCI I2C interrupts may cause device reset due to automatic clear of an IFG.
When certain USCI I2C interrupt flags (IFG) are set and an automatic flag-clearing event on the I2C bus occurs, it results in an errant ISR call to the reset vector. This will only happen when the IFG is cleared within a critical time window (~6 CPU clock cycles) after a USCI interrupt request occurs and before the interrupt servicing is initiated. The affected interrupts are UCBxTXIFG, UCSTPIFG, UCSTTIFG and UCNACKIFG.
The automatic flag-clearing scenarios are described in the following situations:
(1) A pending UCBxTXIFG interrupt request is cleared on the falling SCL clock edge following a NACK.
(2) A pending UCSTPIFG, UCSTTIFG, or UCNACKIFG interrupt request is cleared by a following Start condition.
(1) Polling the affected flags instead of enabling the interrupts.
or
(2) Ensuring the above mentioned flag-clearing events occur after a time delay of 6 CPU clock cycles has elapsed since the interrupt request occurred and was accepted.
or
(3) At program start, check any applicable enabled IE bits such as UCBxTXIE, UCBxRXIE, UCSTTIE, UCSTPIE or UCNACKIE for a reset (A PUC will clear all of the IE bits of interest). If no PUC occurred then the device ran into the above mentioned errant condition and the program counter will need to be restored using an RETI instruction.
; ------- Workaround (3) example for TXIFG ------------
Note: For assembly code use code snippet shown below and insert prior to user code
main
bit.b #UCBxTXIE ,&IE2 ; if TXIE is set, errant call occurred
jz start_normal ; if not start main program
reti ; else return from interrupt call
start_normal
... ; Application code continues
Note: For C code the workaround will need to be executed prior to the CSTARTUP routine. The steps for modifying the CSTARTUP routine are IDE dependent.
Examples for Code Composer and IAR Embedded Workbench are shown below.
IAR Embedded Workbench:
1) The file cstartup.s43 is found at: ...\IAR Systems\< Current Embedded Workbench Version >\430\src\lib\430
2) Create a local copy of this file and link it to the project. Do not rename the file.
3) In the copy insert the following code prior to stack pointer initialization as shown:
#define IE2 (0x0001)
BIT.B #0x08,&IE2 ; if TXIE is set, errant call occurred
JZ Start_Normal ; if not start main program
RETI ; else return from interrupt call
// Initialize SP to point to the top of the stack.
Start_Normal
MOV #SFE(CSTACK), SP
// Ensure that main is called.
Code Composer:
1) The file boot.c is found at ...\Texas Instruments\< Current Code Composer Version > \tools\compiler\MSP430\lib\rtssrc.zip
2) Extract the file from rtssrc.zip and create a local copy. Link the copy to the project. Do not rename this file.
3) In the copy insert the following code prior to stack pointer initialization as shown:
__asm("\t BIT.B\t #0x08,&0x0001"); // if TXIE is set, errant call occurred
__asm("\t JZ\t Start_Normal"); // if not start main program
__asm("\t RETI"); // else return from interrupt call
__asm("Start_Normal");
/*------------------------------------------------------------------ */
/* Initialize stack pointer. Stack grows toward lower memory. */
/*-------------------------------------------------------------------*/
Insert the code here:
/**********************************************************/
/* C_INT00() - C ENVIRONMENT ENTRY POINT */
/**********************************************************/
#pragma CLINK(_c_int00)
extern void __interrupt _c_int00()
{
//
STACK_INIT();