• 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 » timer A for microseconds.
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 >
  • timer A for microseconds.

    timer A for microseconds.

    This question is not answered
    felipe paulo
    Posted by felipe paulo
    on Jun 14 2012 11:38 AM
    Intellectual400 points

    I need a timer_A generating interrupting each 130 microseconds, but look like that he hangs in the loop. Well, if i elevate the interval the software does what i want. Enter in interrup, add a value in queue type FIFO, exits, remove and shows this value. If i put interval in microseconds he hangs. How i can have this interval working?

    i am using msp430g2553

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    All Replies
    • old_cow_yellow
      Posted by old_cow_yellow
      on Jun 14 2012 12:17 PM
      Guru26615 points

      felipe paulo
      ...  Enter in interrup, add a value in queue type FIFO, exits, remove and shows this value...

      If the above takes more than 130 microseconds, then the next interrupts will be requested before the previous one is handled. Interrupt will pile up or mess-up. Stack and FIFO might overflow.

      How fast is the CPU running? How much can it do within 130 microsecond?

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • felipe paulo
      Posted by felipe paulo
      on Jun 14 2012 12:28 PM
      Intellectual400 points

      CPU running 1MHz.

      in interrupting he gets a sample of ADC,  add in FIFO and verify if the loop was run 128 times

      the timer are as configured:

        CCTL0 = CCIE;
        CCR0 = 130;
        TACTL = TASSEL_2 + MC_1;   

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • old_cow_yellow
      Posted by old_cow_yellow
      on Jun 14 2012 12:40 PM
      Guru26615 points

      felipe paulo
      ... in interrupting he gets a sample of ADC,  add in FIFO and verify if the loop was run 128 times ...

      That probably will take more then 130 MCLK.

      Try set MCLK to 8 MHz and keep SMCLK at 1 MHz

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • felipe paulo
      Posted by felipe paulo
      on Jun 14 2012 12:59 PM
      Intellectual400 points

        BCSCTL1 = CALBC1_8MHZ;
        DCOCTL = CALDCO_8MHZ;
        BCSCTL2 = DIVS_3;

      I set up like this?

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • felipe paulo
      Posted by felipe paulo
      on Jun 15 2012 17:11 PM
      Intellectual400 points

      is almost solved the problem. Put 130 microseconds in timer e then exit, it worked. But now i trying do in the timer, a ADC converter, but he don´t want leave the interrupt.

        BCSCTL1 = CALBC1_8MHZ; //MCLK = 8MHZ
        DCOCTL = CALDCO_8MHZ;
        BCSCTL3 = DIVS_3;   //SMCLK = 8MHZ/8=1MHZ
       
        ADC10CTL1 = INCH_7 + CONSEQ_1;            // A2/A1/A0, single sequence
        ADC10CTL0 = ADC10SHT_2 + MSC + ADC10ON + ADC10IE;
        ADC10DTC1 = 0x03;                         // 3 conversions
        ADC10AE0 |= 0xC0;                         // P1.7,6 ADC10 option select
       
          InitLCD();  //Inica o LCD
          LCDClear(); //Limpa a tela
        __enable_interrupt();  //Habilita interrupções


        TACCTL0 = CCIE;                           // TACCR0 interrupt enabled
        TACCR0 = 16;            //Ciclos de SMCLK
        TACTL = TASSEL_2   MC_1   ID_3;                  // SMCLK/8 = 125Khz, upmode
        LPM0;   //Entra em MODO low power mode 0
        LCDSetPosition(0,0); //Define posição
        printDecimal(points); //Exibe a variável pontos
      }

      // Timer A0 interrupt service routine
      #pragma vector=TIMER0_A0_VECTOR
      __interrupt void Timer_A (void)
      {

          ADC10CTL0 &= ~ENC;
          while (ADC10CTL1 & BUSY);               // Wait if ADC10 core is active
          ADC10SA = (unsigned int)&conv_ADC10;    // Inicializa o buffer de dados
          ADC10CTL0 |= ENC   ADC10SC;             // Inicia a amostragem/conversão
       
      }
       
      // ADC10 interrupt service routine
      #pragma vector=ADC10_VECTOR
      __interrupt void ADC10_ISR(void)
      {    
        while (ADC10CTL1 & BUSY);
        points++; //Increment points for me know how many times the timer was executed
                  //if was executed 150 times, he leave of interrupt, get the values and show in LCD.
        if(points == 150){
        LPM0_EXIT;
        }
      }


      but does not work

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • felipe paulo
      Posted by felipe paulo
      on Jun 15 2012 22:18 PM
      Intellectual400 points

      if I put the TIMER with ACLK instead of SMCLK could be even faster?
      Why Are the SMCLK 1MHZ he does not do what I gotta do this time with this range.



      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 Jun 19 2012 07:37 AM
      Guru141810 points

      felipe paulo
          while (ADC10CTL1 & BUSY);               // Wait if ADC10 core is active

      This kind of statement ha sno place inside an ISR. It will execute for an indeterminate length. And since an ISR cannot interrupt anotehr ISR, this may lock-up the whole system.

      ISRs are fast-in and should be fast-out too. No waiting inside. The ISR is called when something happens, to immediately react on the event. They are definitely not meant to wait until something happens.

      Independent of that, ENC does not start the conversion. ADC10SC starts it. (SC for Start Conversion). ENC is just enabling or disabling the encoder (e.g. to emergency-stop a sequence)

      Finally, ADC10_VECTOR is called whenever a conversion is done. So if it is called, you know for sure that a conversion was done, and a result is ready. So you should copy the content here and not in the timer ISR.

      IN the tiemr ISR, there are two cases: either the sequence is ready when teh timer expires. Then it is superfluous to wait for the ADC: it's done and you only need to set ADC10SC again to start the next sequence. Or it isn't done. In this case your timer is too fast. Always. I tmakes no sense to wait for the ADC then, as you'll have to always wait. Since the ADC requires always the same tiemr for a sequence. You must either speed up the ADC by selecting a different SHTx or slow down the timer.
      Which one happens should be obvious after a little elementary school math.

      _____________________________________
      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