• 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 » What is MSP430 maximum interrupt frequency?
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

    What is MSP430 maximum interrupt frequency?

    This question is answered
    peter charl
    Posted by peter charl
    on May 05 2012 13:18 PM
    Prodigy20 points

    Hey guys,

    I'm working with the MSP430F2617 running at a clockspeed of 3,9 Mhz. I'm using the Contiki OS on it to experiment in the WSN domain.

    I connected a light sensor to an interrupt pin and wanted to read out the frequency (number of pulses/interrupts generated in one second). For low frequencies my program doesn't encounter problems and can count the exact number of pulses. However, when the frequency goes to around 70, 80, 90 kHz It start reading out completely wrong values. Above a frequency of 90kHz the µC starts to have problems and seems to reboot itself and is not working properly.

    I was now wondering why this was happening. Can the µC not handle the interrupt frequencies above 70 kHz because they are generated too fast, or is there something happening in the register? Because the register in which I increment the number of pulses is 16 bit so 65536 pulses which is close to the frequency of 70kHz where things go wrong.

    How can I compute or now the maximum number of interrupts? I looked in the data sheet to see how many cycles an instruction takes, but I can not guess how many instructions there are executed in the interrupt routine.

    The interrupt routine is very short:

    interrupt(PORT2_VECTOR)
         irq_p2(void)
    {
      ENERGEST_ON(ENERGEST_TYPE_IRQ);
      P2IFG = 0x00;
      puls = puls+1;
      leds_toggle(LEDS_GREEN);
      ENERGEST_OFF(ENERGEST_TYPE_IRQ);
    }

    Hope someone can give me an answer.

    Best regards!

    MSP430 interrupt frequency
    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    All Replies
    • Roberto Romano
      Posted by Roberto Romano
      on May 05 2012 15:21 PM
      Mastermind6840 points

       Hi, just a moment I use my magic sphere:

      peter charl

      interrupt(PORT2_VECTOR)
           irq_p2(void)
      {
        ENERGEST_ON(ENERGEST_TYPE_IRQ);
        P2IFG = 0x00;
        puls = puls+1;
        leds_toggle(LEDS_GREEN);
        ENERGEST_OFF(ENERGEST_TYPE_IRQ);
      }

      Hope someone can give me an answer.

       The answer is : there where some obscure part we cannot imagine what are doing and can grow stack or mangle something or waste too much cpu time and also reenable interrupt too....

       Regards

       Roberto


       Please login & click    Verify Answer    if this post answered your question.

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • TonyKao
      Posted by TonyKao
      on May 06 2012 00:57 AM
      Verified Answer
      Verified by peter charl
      Genius3770 points

      peter charl

      How can I compute or now the maximum number of interrupts? I looked in the data sheet to see how many cycles an instruction takes, but I can not guess how many instructions there are executed in the interrupt routine.

      In the MSP430 2xx family user guide, it states that it takes 6 cycles from when an interrupt request is accepted to when the first instruction is executed. An interrupt service routine, at the very minimum, contains RETI (return from interrupt) instruction, which takes 5 cycles. So in total this bare-bone ISR takes 11 cycles. This then gives the theoretical maximum of ~354k interrupts per second for MCLK of 3.9MHz.

      Of course this ISR doesn't do much. If you add an instruction that toggles, say, the entire P2, then you need to add

      INV.B &P2OUT

      to the ISR, which takes 4 cycles (register to absolute addressing mode). Now the ISR takes 15 cycles, and you can toggle PORT2 at a frequency of 260KHz.

      However, this is all in pure assembly doing fairly trivial stuff. If you write the ISR in C with external function calls and possibly pushing/popping the stack, then you would get a lot more overhead; add in the RTOS, and I'd say you're lucky to get 70KHz at 3.9MHz.

      If you're counting input frequency, then I would suggest using Timer_A in MSP430 which can count, trigger, and capture much more precisely than in software, all without CPU intervention (works even down to LPM3). It's fairly painless to use, see TI's code examples for MSP430F261x.

      Tony

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • peter charl
      Posted by peter charl
      on May 06 2012 03:14 AM
      Prodigy20 points

      Hey Tony,

      Thanks for the answer, that's what I wanted to know. I was trying to guess the number of cycles like you did by looking in the user guide but found it hard to make assumptions since I work in higher level language instead of assembler.

      I just wanted to have an indication to be sure that the cpu was reaching maximum interrupt frequency and therfore stopped functioning normally.

      I already implemented the Timer_A for counting the pulses and like you say that worked fine for me. I did some tests a couple of days ago and I can count much higher frequencies pretty accurate. Now there is only 1 interrupt every 65536 pulses which is an ideal solution for my application.

      Thank you

      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 May 07 2012 13:40 PM
      Guru139900 points

      peter charl
      How can I compute or now the maximum number of interrupts?

      The maximum number of interrupts is the number of different interrupt sources. But I don't think that's what you want to know :)

      The maximum interrupt frequency is determined by the CPU speed, the tiem for exiting LPM (if used), the latency for entring and exiting the ISR (see users guide, about 11 MCLK cycles) and the execution time of the code inside the ISR.
      And here your code uses three function calls which may require an unknown execution time and also clobber soem registers which need to be saved and restored by the ISR entry/exit code.

      On 3.6MHz PCU speed and 70kHz pulse frequency, you have 3.6m/70k?51 clock cycles per interrupt.  Each function call (including the return from the function) takes 7, preparign the passed parameter rquires 1 or 3 each (depending on the parameter value), = 24 to 30 total. The ISR takes 11,  12 for the saving of registers during the function calls, the assignment and increment take 7. So we are at 54-60 cycles, without the code in the three funciton you call.

      Guess what happens? Yeah, you're losing interrupts. Plain math.

      For counting pulses at high frequencies, one usually uses a hardware counter. Such as one of the timers. Then you can go up to maximum system frequency without losing a pulse. Well, you cannot do fancy things then on every pulse. But who wants to see an LED blink with 70kHz anyway?

      _____________________________________
      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.
    • Roberto Romano
      Posted by Roberto Romano
      on May 07 2012 18:43 PM
      Mastermind6840 points

      Jens-Michael Gross
      Guess what happens? Yeah, you're losing interrupts. Plain math.

       Losing interrupt service never restart cpu, I suppose one of called routine reenable interrupt so stack grow to variable area then to empty space.

       Regards

       Roberto


       Please login & click    Verify Answer    if this post answered your question.

      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 May 08 2012 09:20 AM
      Guru139900 points

      Roberto Romano
      Losing interrupt service never restart cpu

      Yep, not directly (well, it can prevent main from triggerign the WDT in time, if main isn't executed at all anymore due to eternal ISR loop), bu tI was responding to 'start reading out completely wrng values'

      Without knowing the other code, trying to detect the cause for a reset is fruitless anyway.

      _____________________________________
      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