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.

Interfacing with MSP430F1122 & want to learn CCS v6 C programming

Other Parts Discussed in Thread: MSP430F1122, MSP-TS430PW28, CCSTUDIO

I am working on MSP430F1122 micro-controller.

I have kit MSP-TS430PW28, by using this kit I have done successfully done LED Blinking program.

Now, I want to learn C programming for same processor.

Right now i am using CCS version 6.

I found example programs for ADC, like

ADC10CTL0 = SREF_1 + ADC10SHT_2 + REFON + ADC10ON + ADC10IE;

 __enable_interrupt();                     // Enable interrupts.

 TACCR0 = 30;                              // Delay to allow Ref to settle

 TACCTL0 |= CCIE;                          // Compare-mode interrupt.

 TACTL = TASSEL_2 | MC_1;                  // TACLK = SMCLK, Up mode.

I understood above as the comments are written,

But what are the defaults values in registers and I want list of whole registers & their default value.

Suggest me pdf or any other reference so that I can learn C programming by myself.

  • Hi,

    please refer to the MSP430x1xx Family User's Guide: http://www.ti.com/lit/ug/slau049f/slau049f.pdf

    ADC10 is described in chapter 18. The register default value for ADC10 can be found in Table 18−3."ADC10 Registers"

  • For information on special function registers you can look at the MSP430x1xx Family User's Guide. That includes details of the default values.

    You might also need to reference the datasheet for the specific chip you're working on (eg MSP430F1122 Datasheet)

    It's also a good idea to look at the MSP430 Optimizing C/C++ Compiler User's Guide, as that describes intrinsic functions such as  __enable_interrupt() and __delay_cycles().

  • I have this pdf.

    Any other reference particular for C programming,

    For example :

    ADC10CTL0 = SREF_1 + ADC10SHT_2 + REFON + ADC10ON + ADC10IE;

    I aware about ADC10CTL0 register and its 16-bit configuration.

    But how I understood this assigning,

    As SREF_1 , REFON etc are bits and this  ADC10CTL0 register is of 2 bytes.

    So what should I understand meaning of SREF_1 ?

    I am aware about SREFx Bits,

    15-13
                           Select reference
                            000          VR+ = VCC and VR− = VSS
                            001          VR+ = VREF+ and VR− = VSS
                            010          VR+ = VeREF+ and VR− = VSS
                            011          VR+ = VeREF+ and VR− = VSS
                            100          VR+ = VCC and VR− = VREF−/ VeREF−
                            101          VR+ = VREF+ and VR− = VREF−/ VeREF−
                            110          VR+ = VeREF+ and VR− = VREF−/ VeREF−
                            111          VR+ = VeREF+ and VR− = VREF−/ VeREF−

    Does SREF_1 means   001          VR+ = VREF+ and VR− = VSS selection ?

    Similarly 

    __enable_interrupt();                     // Enable interrupts.

    Above line shows it enables interruput.

    But how I find this function ? 

  • Hi,

    you can do a right click on the register or bit fields name and click "Open Declaration". This will bring you to the declaration in the header file. e.g. for SREF_1:

    #define SREF_1                 (1*0x2000u)    /* VR+ = VREF+ and VR- = AVSS */
    

    The __enable_interrupt() function is one of the so-called intrinsic functions of CCSTUDIO compiler, and it is documented in this document: http://www.ti.com/lit/ug/slau132i/slau132i.pdf - chapter 6.7.1 "MSP430 Intrinsics"

  • Thank You,

    Now by using open declaration it is easy to understand.

    #define ADC10SHT_0             (0*0x800u)     /* 4 x ADC10CLKs */

    For above definition suffix "u" indicates what ?

    Does it means unsigned integer ?

  • Below is the code I have written for EDGE DETECTION OF POSITIVE TO NEGATIVE.

    At the time of debug it shows error : 

    MSP430: GEL: Encountered a problem loading file: C:\Users\admin\Desktop\New folder (2) 111\ZERO CROSS DETECTION\Debug\ZERO CROSS DETECTION.out Could not open file

    How to find what error is occured, why it shows error ? 

    #include <msp430.h>


    int main(void)

    {

    WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer

    P1DIR |= 0x01; 
    P2DIR &= 0x00; // P2.0 as input port
    P2IES |= 0x01; // P2.0 port will detect pos to neg edge

    for (;;)
    {
    volatile unsigned int i;
    if (P2IFG == 1 )
    {
    P1OUT = 0x01; // P1.0 on for a while

    i = 500; // Delay
    do (i--);
    while (i != 0);


    }
    else
    {
    P1OUT = 0x00; // P1.0 off

    }

    return 0;
    }

  • I solve this problem by disabling anti-virus.

**Attention** This is a public forum