This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

explanation about these three line of code



i have these three line of code for msp430 device which is the program for displaying clock. any body who can help about this

  BTCTL = 7;                                                                           // Configure BT interrupt rate

  IE2 |= BTIE;                                     // Enable BT interrupt

   _BIS_SR(GIE);// global enable interrupt

i would like to know the function of each line

  • What specific device part number are you using?

    What software release did you pull these excerpt from?  Please cite your source.

  • Princess John said:
     BTCTL = 7;                                                                           // Configure BT interrupt rate

    This is a module configuration. I don't know BTCTL (which device are you using?), which likely is the/a control register of the BT module (sounds not familiar) but it sets it to a value. And according to the comment it is a setting for the interrupt rate of this module.

    Princess John said:
    IE2 |= BTIE;                                     // Enable BT interrupt

    This line enables the interrupt for the BT module, by settign the associated bit in the global Interrupt Enable register #2. If this bit is not set, no interrupts will occur when the BT module issues an interrupt request.

    Princess John said:
      _BIS_SR(GIE);// global enable interrupt

    This sets the GIE (Global Interrupt Enable) bit in the status register. If this bit is not set (which it isn't after a reset), no interrupts are accepted at all, independent of their source and individual configuration.

  • one more questions,

    if somewhere I can find the definition of  "_BIS_SR()" function.

    For example, I have some sample code like this : "_BIS_SR(LPM0_bits + GIE)";

    I curious to know how " _BIS_SR()" function woks with LPM0 module and GIE

  • It is important to know what toolchain you are using.  The documentation for that toochain will tell you how this macro is defined.

    For Code Composer Studio, _BIS_SR() is defined in a header file called in430.h which is found in the CCS installation directory in <CCS_INSTALL_DIR>\ccsv4\msp430\include

    This macro is defined as :

    #define _BIS_SR(x)                      _bis_SR_register(x)

    The C Compiler User's Guide for CCS, document number SLAU132, indicates _bis_SR_register(unsigned short mask) is an instrinsic which maps to the assembly instruction: BIS mask, SR

    This assembly instruction is described in the MSP430 Family User's Guide in the Instruction Set section, as performing a bit set of a register, which in this case are the bits defined in "mask" on the Status Register, SR.

  • BrandonAzbell said:
    _bis_SR_register(unsigned short mask) is an instrinsic which maps to the assembly instruction: BIS mask, SR

    Small correction:

    BIS #mask, SR

    :)

**Attention** This is a public forum