1228 views|1 replies

3836

Posts

19

Resources
The OP
 

CCP capture issue with MSP430F5438 [Copy link]

CCP capture problem void Init_Ta0(void){ P11DIR |= BIT0 + BIT1 + BIT2; // ACLK, MCLK, sMCLK output direction P11SEL |= BIT0 + BIT1 + BIT2; P1DIR |= BIT0; P2DIR &= ~BIT1; P2SEL |= BIT1; //Configure the second function of the input pin ccr0 capture TA0CCTL0 &=~(CCIS0+CCIS1); //CCIXA capture TA0CCTL0 |= CM_3 + SCS + CAP; //Capture on both the rising and falling edges, synchronize signal capture, capture mode TA0CTL = TASSEL_2; //SMCLK, //TA0CTL |= ID_3; //Input signal division TA0CTL |= MC_2; //Timer starts counting (continuous counting mode 0~0xFFFF) TA0CTL |= TACLR; //Counter clear TA0CCTL0 |= CCIE; _EINT(); } #pragma vector=TIMER0_A0_VECTOR __interrupt void Timer_A0(void){ if(TA0CCTL0 & CM1) //Capture falling edge{ TA0CTL |= TACLR; //Clear timerTA0CCTL0=(TA0CCTL0&(~CM1))| CM0; //Change to rising edge capture: CM1 is set to zero, CM0 is set to one} else if(TA0CCTL0 & CM_0) //Capture rising edge{ width = TA0CCR0; //Record the end timeTA0CCTL0=(TA0CCTL0&(~CM0))| CM1; //Change to falling edge capture: CM0 is set to zero, CM1 is set to one} } void main(void){ WDTCTL = WDTPW + WDTHOLD; //Turn off watchdogP7SEL |= 0x03; // XT1 starts to oscillateUCSCTL1 |= DCORSEL_2; // Select DCO frequency range UCSCTL3 |= SELREF__REFOCLK; // Select Fll reference frequency REFO UCSCTL4 = SELM__DCOCLK + SELA__XT1CLK + SELS__DCOCLKDIV; // Configure MCLK = DCOC,SMCLK =DCODIV,ACLK=XT1 while (SFRIFG1 & OFIFG) // Clear OFIFG,and XT1OFFG ,DCOFFG { UCSCTL7 &= ~(XT1LFOFFG + DCOFFG); SFRIFG1 &= ~OFIFG; } while(1){ P1OUT ^= BIT0; // LED flashes, indicating that there is no crystal failure for(unsigned int i=60000;i>0;i--); // Delay } } I use the P2.1 port of MSP5438 to do a capture test. I think the program is OK. I input an 8HZ square wave, but the program does not enter the interrupt. It is very strange. Can you help me find the above problem? Answer: The setting is wrong.
This post is from Microcontroller MCU

Latest reply

Answer: Wrong settings. What are the wrong settings?  Details Published on 2018-12-25 09:06
 

6366

Posts

4936

Resources
2
 
Answer: Wrong settings. What are the wrong settings?
This post is from Microcontroller MCU
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list