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.

Begginer in microcontroller field

Other Parts Discussed in Thread: MSP-TS430RSB40, MSP430F5529, ENERGYTRACE, MSP-FET, MSPWARE, MSP430WARE

Hi'

I'm using a MSP430F5131IDA microcontroller and CCS for the IDE.

i need to generate a one pulse per second from port 2 pin 4 (P2.4). how do i do that using the CCS program ? and what devices do i need in order to download the program to the microcontroller?

p.s.

Where can i get full information on how to program the microcontroller using CCS?

thanks in advance.

  • Hi Omer,

    I'd recommend using the MSP-TS430RSB40 target development board - it has a socket that allows you to easily connect to and program the microcontroller without soldering or designing a custom board just for programming.

    The MSP-FET debugger can be used with the target board and eventually your custom board (assuming that you include the JTAG interface/circuitry in your design, use the correct header, etc.). It also supports the widest range of MSP43x devices and other helpful features, such as EnergyTrace technology. You could also use the eZ-FET Lite emulator on the MSP430F5529 LaunchPad, which supports all MSP430 devices (as shown in Table 1 in the MSP Debuggers User's Guide) but only supports 2-wire JTAG (versus support for both 2-wire and 4-wire JTAG by the MSP-FET) and doesn't support EnergyTrace technology.

    For getting started with CCS, take a look at the CCS Fundamentals Workshop wiki page. There's a presentation that walks you through how to use a code example. Another good resource is the Code Composer Studio v6.1 for MSP430 User's Guide. I would also suggest downloading MSP430Ware - it can be downloaded manually or installed through the CCS App Center (search for "MSPWare"). I typically go to MSPWare in CCS to find an applicable code example (see screenshot below).

    For your software application, take a look at the "MSP430F51x2_ta0_04.c" code example. It toggles an LED (P1.0) at 0.5 Hz. You would need to change the output pin and change the toggle rate. I've included it below for your reference (can also be found in MSPWare).

    /* --COPYRIGHT--,BSD_EX
     * Copyright (c) 2012, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     *
     *******************************************************************************
     * 
     *                       MSP430 CODE EXAMPLE DISCLAIMER
     *
     * MSP430 code examples are self-contained low-level programs that typically
     * demonstrate a single peripheral function or device feature in a highly
     * concise manner. For this the code may rely on the device's power-on default
     * register values and settings such as the clock configuration and care must
     * be taken when combining code from several examples to avoid potential side
     * effects. Also see www.ti.com/grace for a GUI- and www.ti.com/msp430ware
     * for an API functional library-approach to peripheral configuration.
     *
     * --/COPYRIGHT--*/
    //******************************************************************************
    //  MSP430F51x2 Demo - Timer0_A3, Toggle P1.0, Overflow ISR, 32kHz ACLK
    //
    //  Description: Toggle P1.0 using software and the Timer0_A overflow ISR.
    //  In this example an ISR triggers when TA overflows. Inside the ISR P1.0
    //  is toggled. Toggle rate is around 0.5Hz. Proper use of the TAIV interrupt
    //  vector generator is demonstrated.
    //  ACLK = TACLK = LFXT1 = 32768Hz, MCLK = SMCLK = default DCO ~1.045MHz
    //
    //                MSP430F51x2
    //             -----------------
    //         /|\|              XIN|-
    //          | |                 | 32kHz
    //          --|RST          XOUT|-
    //            |                 |
    //            |             P1.0|-->LED
    //
    //  B. Nisarga
    //  Texas Instruments Inc.
    //  Dec 2009
    //  Built with CCS v4 and IAR Embedded Workbench Version: 4.21
    //******************************************************************************
    #include <msp430.h>
    
    int main(void)
    {
      WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
      P1DIR |= BIT0;                            // P1.0 output
      PJSEL |= BIT4+BIT5;                       // Port select XT1
    
      UCSCTL6 &= ~(XT1OFF);                     // XT1 On
      UCSCTL6 |= XCAP_3;                        // Internal load cap
      UCSCTL3 = 0;                              // FLL Reference Clock = XT1
    
      // Loop until XT1 & DCO stabilizes - In this case loop until XT1 and DCo settle
      do
      {
        UCSCTL7 &= ~(XT1LFOFFG + XT1HFOFFG + DCOFFG);
                                                // Clear XT1,DCO fault flags
        SFRIFG1 &= ~OFIFG;                      // Clear fault flags
      }while (SFRIFG1&OFIFG);                   // Test oscillator fault flag  
      UCSCTL6 &= ~(XT1DRIVE_3);                 // Xtal is now stable, reduce drive strength
      UCSCTL4 |= SELA_0;                        // ACLK = LFTX1 (by default)
    
      // Configure TA0
      TA0CTL = TASSEL_1 + MC_2 + TACLR + TAIE;  // ACLK, contmode, clear TAR
                                                // enable interrupt
    
      __bis_SR_register(LPM3_bits + GIE);       // Enter LPM3, enable interrupts
      __no_operation();                         // For debugger
    }
    
    // Timer0_A3 Interrupt Vector (TAIV) handler
    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector=TIMER0_A1_VECTOR
    __interrupt void TIMER0_A1_ISR(void)
    #elif defined(__GNUC__)
    void __attribute__ ((interrupt(TIMER0_A1_VECTOR))) TIMER0_A1_ISR (void)
    #else
    #error Compiler not supported!
    #endif
    {
      switch(__even_in_range(TA0IV,14))
      {
        case  0: break;                          // No interrupt
        case  2: break;                          // CCR1 not used
        case  4: break;                          // CCR2 not used
        case  6: break;                          // reserved
        case  8: break;                          // reserved
        case 10: break;                          // reserved
        case 12: break;                          // reserved
        case 14: P1OUT ^= BIT0;                  // overflow
                 break;
        default: break; 
      }
    }
    
    

    Hope this helps!

    Regards,

    James

    MSP Customer Applications

**Attention** This is a public forum