• Join
  • Sign In with my.TI Login
Texas Instruments
  • Products
  • Applications
  • Tools & Software
  • Support & Community
  • Sample & Buy
  • About TI
Sample & Purchase Cart Sample & Purchase Cart
  • Search
  • Advanced
TI E2E™ Community
  • Support Forums
  • Blogs
  • Groups
  • Videos
  • 简体中文
  • More ...
TI Home » TI E2E Community » Support Forums » Microcontrollers » MSP430™ Microcontrollers » MSP430 Ultra-Low Power 16-bit Microcontroller Forum » msp430g2231:HELP
Share
MSP430™ Microcontrollers
  • Forum
  • Announcements
  • E2E Wiki
Options
  • Subscribe via RSS
MSP430 Resources
  • MSP430 Product Folder
  • MSP-EXP430G2 - MSP430 LaunchPad Value Line Development kit
  • MSP430 Getting Started Guide
  • MSP430 Microcontroller Projects
  • More Resources >
  • Forums

    msp430g2231:HELP

    This question is not answered
    salony agarwal
    Posted by salony agarwal
    on Feb 14 2012 09:43 AM
    Intellectual455 points

    Hi

    I am working on msp430g2231 and I have very less knowledge about it.

    I have written a Code to test the working of ISR(interrupt sub routine)  of timer_a.

    But I think there is a problem and the program is unable to execute the sub routine.

    The idea is to blink an LED(P1.0) upon button press(P1.3).(Note: blinking is just to check whether the program is executing the ISR or not?)

    ----------------------------

    and 

    TACCTL0= CM_3 | CCIS_1 | SCS | CAP | CCIE;

    Please tell me  do we need to route the button with CCI0B externally or it is already routed???

    Please follow the code below and help.

    -----------------------------------------------------------------------------------------------------------------------------

    #include "msp430g2231.h"

    void main(void)
    {
    WDTCTL= WDTPW | WDTHOLD;
    P1OUT = 0;
    P1DIR = 0x01;
    P1SEL = BIT3;
    TACCTL0= CM_3 | CCIS_1 | SCS | CAP | CCIE;
    TACTL = TASSEL_2 | ID_3 | MC_2 | TACLR;
    for ( ;;)
    {
    __low_power_mode_3();
    }
    }

    # pragma vector = TIMERA0_VECTOR
    __interrupt void TIMERA0_ISR (void)
    {
    P1OUT=0x01;

    }


    MSP430
    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    All Replies
    • salony agarwal
      Posted by salony agarwal
      on Feb 27 2012 23:15 PM
      Intellectual455 points

      Hi Matthias

      Thanks a lot.

      I am not able to understand how this code works.P1.1 and P1.2 (TXD and RXD ) are not used anywhere except for PDIR.

      Please explain when and how will the interrupt generate ?

      Can you please tell how can I run this code on CCS(v4).

      Thanks

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Matthias Siegenthaler
      Posted by Matthias Siegenthaler
      on Feb 29 2012 16:58 PM
      Intellectual465 points

      Hello Salony

      The timer module can be programmed for a pin action to be executed when the compare value matches the free running counter. Have a look for the OUTMODx keyword in the manual.  Its amazing what can be done with the Ouput-Modes: Toggle, Set, Reset, and combinations of them 

      Your RX from the example works in a similar way: routed directly to the timer. So there is no code needed to treat them like IO-ports as it would  be needed for leds and buttons in general.

      I use CSS(5.1) and would recommend you to do the same. It's free too for your purposes. post your project and perhaps I can find some time at weekend to help you merging your code with UART-Example.

      Cheers, matthias

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Rame
      Posted by Rame
      on Mar 05 2012 06:13 AM
      Prodigy180 points

      Hi Salony,

      First, you need an application program running on your PC that will read

      the com port. You can create one or you can install a serial port reader application

      such as any of the following.

      http://www.serialporttool.com/CommPalInfo.htm

      http://www.232analyzer.com/232default.htm

      Since you will only need to send data , I have modified the code above and

      removed the "receive" actions. Try to download this into your MSP430G2231.

      It should send  "UART TEST OK" if the P1.3 button is pressed. 

      You were asking about CCSv4. I think there are plenty of tutorials

      available on how to use it. Personally , I would suggest you use

      IAR embedded workbench kickstart.

      Link : http://www.ti.com/tool/iar-kickstart

      //code

      #include "msp430g2231.h"

      //------------------------------------------------------------------------------
      // Hardware-related definitions
      //------------------------------------------------------------------------------
      #define UART_TXD 0x02 // TXD on P1.1 (Timer0_A.OUT0)

      //------------------------------------------------------------------------------
      // Conditions for 9600 Baud SW UART, SMCLK = 1MHz
      //------------------------------------------------------------------------------
      #define UART_TBIT_DIV_2 (1000000 / (9600 * 2))
      #define UART_TBIT (1000000 / 9600)

      //------------------------------------------------------------------------------
      // Global variables used for full-duplex UART communication
      //------------------------------------------------------------------------------
      unsigned int txData; // UART internal variable for TX

      //------------------------------------------------------------------------------
      // Function prototypes
      //------------------------------------------------------------------------------
      void TimerA_UART_init(void);
      void TimerA_UART_tx(unsigned char byte);
      void TimerA_UART_print(char *string);

      //------------------------------------------------------------------------------
      // main()
      //------------------------------------------------------------------------------
      void main(void)
      {
      WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer

      DCOCTL = 0x00; // Set DCOCLK to 1MHz
      BCSCTL1 = CALBC1_1MHZ;
      DCOCTL = CALDCO_1MHZ;

      P1OUT = 0x00; // Initialize all GPIO
      P1SEL = UART_TXD ; // Timer function for TXD/RXD pins
      P1REN=BIT3 //enable pull up resistor in case external resistor is not populated
      P1DIR |= 0x02
      P2OUT = 0x00;
      P2SEL = 0x00;
      P2DIR = 0xFF;

      __enable_interrupt();

      TimerA_UART_init(); // Start Timer_A UART
      TimerA_UART_print("G2xx1 TimerA UART\r\n");
      TimerA_UART_print("READY.\r\n");

      while(1)
      {
      while((BIT3&P1IN)==0)
      {
              TimerA_UART_print("UART TEST OK");
                      }
                 while((BIT3&P1IN)==0)
                     {                                                                                     //do nothing
      }

      }
      }




      //------------------------------------------------------------------------------
      // Function configures Timer_A for full-duplex UART operation
      //------------------------------------------------------------------------------
      void TimerA_UART_init(void)
      {
      TACCTL0 = OUT; // Set TXD Idle as Mark = '1'
      TACTL = TASSEL_2 + MC_2; // SMCLK, start in continuous mode
      }
      //------------------------------------------------------------------------------
      // Outputs one byte using the Timer_A UART
      //------------------------------------------------------------------------------
      void TimerA_UART_tx(unsigned char byte)
      {
      while (TACCTL0 & CCIE); // Ensure last char got TX'd
      TACCR0 = TAR; // Current state of TA counter
      TACCR0 += UART_TBIT; // One bit time till first bit
      TACCTL0 = OUTMOD0 + CCIE; // Set TXD on EQU0, Int
      txData = byte; // Load global variable
      txData |= 0x100; // Add mark stop bit to TXData
      txData <<= 1; // Add space start bit
      }

      //------------------------------------------------------------------------------
      // Prints a string over using the Timer_A UART
      //------------------------------------------------------------------------------
      void TimerA_UART_print(char *string)
      {
      while (*string) {
      TimerA_UART_tx(*string++);
      }
      }
      //------------------------------------------------------------------------------
      // Timer_A UART - Transmit Interrupt Handler
      //------------------------------------------------------------------------------
      #pragma vector = TIMERA0_VECTOR
      __interrupt void Timer_A0_ISR(void)
      {
      static unsigned char txBitCnt = 10;

      TACCR0 += UART_TBIT; // Add Offset to CCRx
      if (txBitCnt == 0) { // All bits TXed?
      TACCTL0 &= ~CCIE; // All bits TXed, disable interrupt
      txBitCnt = 10; // Re-load bit counter
      }
      else {
      if (txData & 0x01) {
      TACCTL0 &= ~OUTMOD2; // TX Mark '1'
      }
      else {
      TACCTL0 |= OUTMOD2; // TX Space '0'
      }
      txData >>= 1; // WHAT THIS SIGN INDICATES ">>=" ??
      txBitCnt--;
      }
      }
      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Jens-Michael Gross
      Posted by Jens-Michael Gross
      on Mar 05 2012 07:10 AM
      Guru140135 points

      That's C++ 101.

      It is the C++ short version for x = x>>1 and does a right-shift of the variable, dropping th ecurent BIT0 and making BIT1 the new BIT0 (and BIT2 to BIT1etc.).

      _____________________________________
      Before posting bug reports or ask for help, do at least quick scan over this article. It applies to any kind of problem reporting. On any forum. And/or look here.
      If you cannot discuss your problem in the public, feel free to start a private conversation: click on my name and then 'start conversation'. But please do so only if you really cannot do it in a public thread, as I usually read all threads. And I prefer to answer where others can profit from it (or contribute to it) too.

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • salony agarwal
      Posted by salony agarwal
      on Mar 12 2012 00:57 AM
      Intellectual455 points

      Hi Michael

      My program of SOFT-UART is running successfully.I am using putty for  the terminal display of the result.

      Can you please tell me how do i write a program on PC to modify the data received for example plotting of graph(for numerical values)?

      or is there any software which will do the work directly?

      In my actual program i need to get the PWM wave from an infrared sensor,convert the PWM output to respective temperature value and finally store the values and plot it against time.

      thanks

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • salony agarwal
      Posted by salony agarwal
      on Mar 12 2012 00:58 AM
      Intellectual455 points

      Hi Rame

      My program of SOFT-UART is running successfully.I am using putty for  the terminal display of the result.

      Can you please tell me how do i write a program on PC to modify the data received for example plotting of graph(for numerical values)?

      or is there any software which will do the work directly?

      In my actual program i need to get the PWM wave from an infrared sensor,convert the PWM output to respective temperature value and finally store the values and plot it against time.

      thanks

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Jens-Michael Gross
      Posted by Jens-Michael Gross
      on Mar 13 2012 10:48 AM
      Guru140135 points

      Take a look at this project.

      It receives commands from PC and sends answers (msotly ADC conversion results) to the PC, using a LaunchPad. Onteh PC side, the application has a simple Windows Forms UI (C#) for the controls and uses a free scope library for the plotting. However, it is not an x/y plot but rather a realtime display of incoming values.
      However, it is worth a look if you want to know how things like this can be done.

      Of course you can replace the calls to the library by your own line drawing functions.

      _____________________________________
      Before posting bug reports or ask for help, do at least quick scan over this article. It applies to any kind of problem reporting. On any forum. And/or look here.
      If you cannot discuss your problem in the public, feel free to start a private conversation: click on my name and then 'start conversation'. But please do so only if you really cannot do it in a public thread, as I usually read all threads. And I prefer to answer where others can profit from it (or contribute to it) too.

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    123
    TI E2E™ Community
    • Support Forums
    • Blogs
    • Videos
    • Groups
    • Site Support & Feedback
    • Settings
    TI E2E™ Community Groups
    • TI University Program
    • Make the Switch
    • Microcontroller Projects
    • Motor Drive & Control
    Other Communities
    • Deyisupport
    • Designsomething.org
    • beagleboard.org
    • TI on Element 14
    • TI on TechXchangeSM
    Other Technical & Support Resources
    • WEBENCH® Design Center
    • Product Information Centers
    • Technical Documents
    • TI Design Network
    • TI Technical Articles
    • TI Training

    All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.

    Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms of Use of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms of Use of this site. TI, its suppliers and providers of content reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

    Follow Us Texas Instruments on Facebook Texas Instruments on Twitter Texas Instruments on LinkedIn Texas Instruments on Google+
    TI Worldwide | Contact Us | my.TI Login | Site Map | Corporate Citizenship | mobile m.ti.com (Mobile Version)

    TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs and
    embedded processors, along with software, tools and the industry’s largest sales/support staff.

    © Copyright 1995-2013 Texas Instruments Incorporated. All rights reserved.
    Trademarks | Privacy Policy | Terms of Use