• 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 » Low Power RF & Wireless Connectivity » Low Power RF ZigBee® Software & IEEE 802.15.4 Forum » CC2530 Timer4 Input Capture Problem
Share
Low Power RF & Wireless Connectivity
  • Forums
  • Announcements
  • Files
  • E2E Wiki
Options
  • Subscribe via RSS

Forums

CC2530 Timer4 Input Capture Problem

This question is answered
Di Chen
Posted by Di Chen
on May 10 2012 04:31 AM
Prodigy180 points

Hi, all~

To parse IR signal,  use Timer 3 as timer and Timer 4 channel 0 as input capture channel. P1_0 is a input pin. 

the problem is that program can enter into timer 3 interrupt but not to timer 4 interrupt. That's why? The folling is the major code:

void main(void)
{
  RegisterInit();
  
  Timer4Init();
  
  Timer3Init();
  
  while(1)
  {
    asm("nop");
  }
}

void RegisterInit(void)
{
  //init clock and tick frequency
  CLKCONCMD &= ~0x7f;  //tick speed: 32M, clock speed: 32M
  
  while(CLKCONSTA & 0x40);  //wait for crystal
  
  //init TIMIF
  TIMIF = 0x00;
  
  //timer4 alternative 1
  PERCFG &= ~0x10;
  
  //init P1_0
  P1SEL |= 0x01;     //P1_0 peripheral I/O
  P1DIR &= ~0x01;    //P1_0 input
  
  //init variable
 timerIntCount = 0;
 captureIntCount = 0;
  
  //open global interrupts
  EA = 1;
}

void Timer3Init(void)
{
  T3CTL = 0x00;      //default
  T3CTL |= 0xA0;     //tick speed / 32 = 1MHz
  T3CTL |= 0x08;     //timer4 overflow interrupt
  T3CTL |= 0x04;     //clear counter
  T3CTL |= 0x01;     //down mode
  
  T3CC0 = 0xFA;     //250us interrupt

  T3IE = 1;
  
  T3CTL |= 0x10;    //Timer4 start
}

void Timer4Init(void)
{
  T4CTL = 0x00;     //default
  
  T4CCTL0 = 0x00;  //capture mode
  T4CCTL0 |= 0x40;  //open capture/compare interrupt
  T4CCTL0 |= 0x02;  //capture on failing edge
}


#pragma vector = T3_VECTOR
__interrupt void T3_ISR(void)
{

   T3OVFIF = 0;

   timerIntCount++;

   T3CTL |= 0x10;

   T3CC0 = 0xFA;

}

#pragma vector = T4_VECTOR
__interrupt void T4_ISR(void)
{

   captureIntCount++;
   //parse IR signal
}

Thanks everybody

CC2530 input capture timer 4
Report Abuse
  • Reply
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
All Replies
  • hec
    Posted by hec
    on May 10 2012 08:45 AM
    Expert8120 points

    As far as I can see from the code, you neither enable the Timer 4 interrupt (T4IE = 1) nor start Timer 4. You do enable the Timer 3 interrupt and start Timer 3, though, which is why you are seeing only that one.

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Di Chen
    Posted by Di Chen
    on May 10 2012 21:10 PM
    Prodigy180 points

    Thank you for your reply.

    add " T4IE = 1 ", it is uesless.

    add " T4CTL |= 0x10", start Timer4. Then, TIMIF.T4OVFIF = 1, but TIMIF.T4CH0IF is still 0. Therefore, progrom can enter into Timer4 interrupt because of T4OVFIF , not T4CH0IF.

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • hec
    Posted by hec
    on May 11 2012 02:38 AM
    Expert8120 points

    You have set up Timer 4 channel 0 in capture mode, so in order to observe a Ch 0 interrupt, you have to have a falling edge on the channel 0 input line (P1.0).

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Di Chen
    Posted by Di Chen
    on May 11 2012 04:10 AM
    Prodigy180 points

    i have set it.

    //init P1_0
      P1SEL |= 0x01;     //P1_0 peripheral I/O
      P1DIR &= ~0x01;    //P1_0 input

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • hec
    Posted by hec
    on May 11 2012 04:18 AM
    Expert8120 points

    Yes, but is there any external activity on the pin P1.0? If not, you will of course not get any interrupt.

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Di Chen
    Posted by Di Chen
    on May 11 2012 04:28 AM
    Prodigy180 points

    Yes, i have tested. There is a external activity.

    I can capture P0_7 external activity with timer 1 channel 3.

    P1_0 is neithrer pull-up nor pull down. Is external activity not capture because of it?

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • hec
    Posted by hec
    on May 11 2012 04:58 AM
    Verified Answer
    Verified by Di Chen
    Expert8120 points

    The lack of pull on P1.0 will only be an issue if the line is not driven externally. If your external driver switches between tri-state and GND, P1.0 will probably not be able to detect the change, while P0.7 will. In this case, you will need to add an external pull-up. If your external driver switches between VDD and GND, P1.0 should work fine in capturing the event.

    I tested your code after having added T4IE = 1; and T4CTL |= 0x10; in Timer4Init(), and it works fine. When I have a falling edge on P1.0, I get the interrupt.
     


    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Di Chen
    Posted by Di Chen
    on May 13 2012 20:43 PM
    Prodigy180 points

    Thanks a lot. I will try.

    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