#341 add nop after eint in intrinsics enabling interrupts.

4.7.x_development
open
gcc (183)
5
2013-03-14
2013-01-07
Peter A. Bigot
No

Per argument at http://e2e.ti.com/support/microcontrollers/msp43016-bit_ultra-low_power_mcus/f/166/t/53319.aspx the __enable_interrupt() intrinsic should include a nop after the eint as well, at least on some CPU architectures.

Discussion

  • Peter A. Bigot
    Peter A. Bigot
    2013-03-14

    Further research indicates that TI's compiler tools have this fixed with code generation version 4.1.3 and beyond. Note that ccs-5.2.1 uses tool version 4.1.1.

    This problem has been reproduced in code that does the following when TA0
    has a pending interrupt at the point the interrupt is enabled.

    eint
    dint
    nop
    mov &TA0R, r15
    

    This code can be generated with something like:

    __enable_interrupt();
    while (1) {
      unsigned int t0, t1;
      __disable_interrupt();
      t0 = TA0R;
      t1 = TA0R;
      __enable_interrupt();
      printf("Time difference %u\n", t1-t0);
    }
    

    Inserting __nop() between the __enable_interrupt() and the while(1) fixes the bug. The bug is due to CPU42. msp430mcu does not currently provide MCU erratum information to the compiler, but doing so wouldn't help since TI's provided devices.csv does not include information about CPU42.