• 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 » MSP430G2553 Timer İnterrupts
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 >
  • MSP430G2553 Timer İnterrupts

    MSP430G2553 Timer İnterrupts

    This question is not answered
    Arda Akalın
    Posted by Arda Akalın
    on Apr 11 2012 15:27 PM
    Prodigy10 points
    here is my code i have two timer interrupts but both of them doesnt work please help me
    
    
    
    
    #include <msp430g2553.h>
    #include <stdbool.h>
    #include <in430.h>
    #define pompa BIT6
    #define BUTTON BIT3
    int sicaklik=0;
    int second=0;
    int minute=0;
    int hour=0;
    int nem=0;
    int count=0;
    int sicaklikonlar;
    int sicaklikbirler;
    int nemyuzler;
    int nemonlar;
    int nembirler;
    int rs232gidenfonk;
    int rs232giden;
    bool rs232gonderilecek=0;
    int rs232bit=0;
    int temp();
    int humidity();
    int rs232gonder(int);
    void main(void)
    {
    WDTCTL = WDTPW|WDTHOLD;
    P1DIR=0x22;
    P1OUT=0x02;
    TACCTL0=CCIE;
    TACCR0=0xFFFF;
    TACCTL0=TASSEL_2|ID_3|MC_3|TACLR;
    _enable_interrupt();
    for(;;){
    if(minute%2){
    sicaklik=temp();
    sicaklikonlar=sicaklik/10+48;
    sicaklikbirler=sicaklik%10+48;
    }
    if(count==1){
    nem=humidity();
    nemyuzler=nem/100;
    nemonlar=nem/10+48;
    nembirler=nem%10+48;
    }
    rs232gonder(nemyuzler);
    }
    }
    #pragma vector = TIMER0_A0_VECTOR
    __interrupt void TA0_ISR(void)
    {
    second++;
    if(second>=60){
    second=0;
    minute++;
    if(minute>=60){
    minute=0;
    hour++;
    if(hour==6){
    second=0;
    minute=0;
    hour=0;
    }
    }
    }
    }
    int temp(){
    int T;
    int temperature;
    ADC10CTL0 = SREF_1|ADC10SHT_3|REFON|ADC10ON;
    ADC10CTL1 = INCH_10|ADC10DIV_3;
    ADC10CTL0|=ENC|ADC10SC;
    temperature=ADC10MEM;
    T=((temperature - 673) * 423) / 1024;
    count=1;
    return T;
    }
    int humidity(){
    int b;
    int M;
    ADC10CTL0=SREF_1|ADC10SHT_3|REFON|ADC10ON;
    ADC10CTL1=INCH_0|ADC10DIV_3;
    ADC10CTL0|=ENC|ADC10SC;
    M = ADC10MEM*2500 /2^12;
    b = 11.9 * 10E-4 * M - 0.401;
    count=0;
    return b;
    }
    int rs232gonder(int rs232gidenfonk)
    {
    if(rs232gonderilecek==0)
    {
    rs232giden=rs232gidenfonk;
    rs232giden=rs232giden << 1;
    rs232giden+=512;
    rs232gonderilecek=1;
    TACCTL1=CCIE;
    TACCR0=108;
    TACCTL1=TASSEL_2|ID_0|MC_1|TACLR;
    _enable_interrupt();
    }

    }
    #pragma vector = TIMER0_A1_VECTOR
    __interrupt void TA1_ISR (void)
    {
    if(rs232gonderilecek==1)
    {
    if(rs232bit < 10)
    {
    P1OUT=rs232giden&BIT0;
    rs232giden=rs232giden>>1;
    }
    else
    {
    TACCTL1= MC_0;
    rs232gonderilecek=0;
    }
    }
    rs232bit++;
    }
    msp430g2553 timers
    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    All Replies
    • Suresh Doraiswamy
      Posted by Suresh Doraiswamy
      on Oct 15 2012 05:02 AM
      Prodigy20 points

      Hi Arda,

      I got both timers working.  Try these - maybe something very small.

      1.  Please clear the IFG flag :    TACCTL1 &= ~CCIFG;   // clear interrupt register  :  in TA1 ISR.

      2.  Reload TACCR1 in the TA1 ISR before exiting.

      3.  During initialization load TACCR1 with a value and enable the TA1 Interrupt :   TACCTL1 = CCIE;

      Best Wishes,

      Suresh

       

       

      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 Oct 16 2012 07:38 AM
      Guru140085 points

      Arda Akalın
      TACCTL1= MC_0;

      This one is wrong. MCx isn't part of TACCTL1. It is part of TACTL (mode control).

      However, your code unintendedly dows the right thing: it clears BIT0 (CCIFG) from TACCTL1, which needs to be done for any tierm interrupt except CCR0 (which has its own vector and auto-clears on ISR start). But it also disables TACCR1 interrupt (clears CCIE bit) and so the TACCR1 interrupt is called only once.

      TACCR0 interrupt is called frequently,

      In RS232gonder() you do the same thing: TACCTL1 = TASSEL_2... which is wrong too. It should read TACTL=TASSEL_2...

      However, stopping the timer and restarting/resetting it, means that you won't get your TACCR0 interrupt at regular intervals. I think there is a logical error in the base concept of your code.

      Anothe rone: every variable that is use din both, main code and interrupt code, should be declared volatile to tell the compiler that it may change 'magically' during main code execution or may be required to be written immediately. Else code optimization may lead to changes being ignored until next function return.

      _____________________________________
      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.
    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