SLAZ733B February   2020  – August 2021 MSP430FR6007

 

  1.   1
  2.   2
  3.   3
  4.   4
  5.   5
    1.     6
    2.     7
      1.      8
    3.     9
  6.   10
    1.     11
    2.     12
    3.     13
    4.     14
    5.     15
    6.     16
    7.     17
    8.     18
    9.     19
    10.     20
    11.     21
    12.     22
    13.     23
    14.     24
    15.     25
    16.     26
    17.     27
    18.     28
    19.     29
    20.     30
    21.     31
    22.     32
    23.     33
    24.     34
    25.     35
  7.   36

USCI52

USCI Module

Category

Functional

Function

Interrupt Flag polling can cause unrpedictable behavior if eUSCI is running with different clock then CPU

Description

If the interrupt flags e.g. UCAIFG of the eUSCI are polled via the CPU during a while loop or during the following assembly instruction the CPU behavior can become unpredictable when the corresponding interrupt flag is set asynchronously during the execution of the bit instruction. The corresponding CPU flags used by the conditional jump can become unstable causing unpredictable CPU execution.  

CHECK_FLAG
           BIT.W  #8,&UCAxIFG
           JEQ      CHECK_FLAG

Workaround

Buffer the interrupt flag which should be polled, to a CPU internal register e.g. R15 and use this register for the decision (bit + jeq).
The bit of interest remains stable during the CPU decision because the value is settled in the CPU internal register.
In C, declaring the buffer variable as volatile avoids compiler optimizations that may result in the assembly code above.

Workaround in C:
volatile unsigned short flag;
do
{
flag = UCA0IG;
}while ((flag & UCRXIFG) == 0x00);

Workaround in asm:
           PUSH    R15
loop:
           MOV.W  &UCAxIFG, R15    
           BIT.W    #8,R15
           JEQ       loop
           POP      R15