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.

CCS/MSP430FR5739: MSP430FR5739 header file

Part Number: MSP430FR5739

Tool/software: Code Composer Studio

Hello,
I'm new in MSP430 programming area. In my code I'm trying to work with IO registers as a bit field variables, but
it seems like CCS does not recognize it. My code has following definitions:

#include <msp430.h>

#define _MSP430FR5739_

#define LED1 P1OUT_bit.P1OUT_0

.......

The CCS compiler prints out the following message:

Error: #20 identifier "P1OUT_bit.P1OUT_0" is undefined.


It looks like there is still missing a header file that include definitions for all registers for specific devices.
I'll be thankfull for help with this issue.

Sincerely,
Lavi

  • Hello Lavi,

    The format you have chosen to use is not typical of MSP430. Our header files define bits as BIT0, BIT1, BIT2, etc. So if you wanted to output high on P1.0 you would write:

    P1OUT |= BIT0;

    While outputting low would be:

    P1OUT &= ~BIT0;

    You can then setup #defines for LED on/off using the above.

    #define LED1_ON (P1OUT |= BIT0)
    #define LED1_OFF (P1OUT &= ~BIT0)
  • Hi Jace H,
    Thanks for your response.

    Is masking method you have described the preferable way of registers’ bits referencing?

    From my experience with PIC microcontrollers it is much more convenient to deal with registers as a bit fields variables. Thus you can get access directly to the specified register bit instead of explicitly masking it.

    Microchip is providing a header files that includes all necessary definitions. Does TI provide similar support libraries?
  • Hello Lavi,

    All of MSP43s register definitions and support is contained within the header files included with MSP430 support packages for your IDE. MSP430 formats its register access differently than PIC micros.  Masking each register with the  bit fields you want is the method used for MSP430. I have already shown you an example of how to do Pin registers. These are done with BITx masks ; however, peripheral or core registers actually have the bit field description as part of the mask. For example, a Timer Control register can be addressed as follows:

      TB0CTL = TBSSEL_2 + MC_1;                 // SMCLK, UP mode
      TB0CTL = TBSSEL__SMCLK + MC__UP;          // SMCLK, UP mode

    As you can see, this can be done in two ways. One way actually places the number into the bit field, while the other allows a coder to see which option they are actually selecting in the register. Both of these resolve to the same thing though. If you are using CCS, when you start typing in an option (such as 'MC_' ), you can then enter CTL+SPACE for CCS to give you auto-fill options.