-
顶!
-
谢谢!
-
看下截图,看到没它是不会溢出的,不够的移到下一周期了!这句话CCR0 += 50000; 不能去掉,这句话的意思是以1/5000为周期的,去掉的话周期为1/65535了!
-
谢谢!
-
顶,支持!
-
谢谢!
-
每个都测试了!你仔细想想再说吧!
-
#include "MSp430G2553.h"unsigned int start,end;unsigned char overflow;void main( void ){ WDTCTL = WDTPW + WDTHOLD; P1DIR|=BIT0+BIT6;//P1.6LED, P1SEL|=BIT0+BIT2;//P1.0->ACLK输出,P1.2->捕获输入 P1OUT&=~BIT6;//关闭LED BCSCTL1 =DIVA_3;//ACLK8分频(vlo=12Khz) CCTL1=CM_1+SCS+CCIS_0+CAP+CCIE;//上升沿+同步+CCI0A(p1.2)+捕获功能+捕获中断 TACTL=TASSEL_2+MC_2+ID_3+TAIE+TACLR;//SCLK(DCO=1.1Mhz)8分频,连续计数模式 _BIS_SR(LPM0_bits+GIE);}#pragma vector=TIMER0_A1_VECTOR__interrupt void Timer_A (void){ switch(TAIV) { case 2: if(CCTL1&CM_1) { CCTL1=(CCTL1&(~CM_1))|CM_2; start=TAR; overflow=0; } if(CCTL1&CM_2)//else if与if区别要注意 { CCTL1=(CCTL1&(~CM_2))|CM_1; end=TAR; } P1OUT|=BIT6; break; case 10: overflow++; break; default: break; }}
-
谢谢!我在试试吧!:)
-
补充楼上的……我用示波器测试过1)#include <msp430g2553.h>void main(void){ WDTCTL = WDTPW + WDTHOLD; P1DIR |= 0x01; CCTL0 = CCIE; // CCR0 = 50000;//不加这句话这个程序周期定为65535产生的周期 TACTL = TASSEL_2 + MC_2; _BIS_SR(LPM0_bits + GIE); // Enter LPM0 w/ interrupt}// Timer A0 interrupt service routine#pragma vector=TIMER0_A0_VECTOR__interrupt void Timer_A (void){ P1OUT ^= 0x01; //CCR0 += 50000; //不加这句话 } 2)#include <msp430g2553.h>void main(void){ WDTCTL = WDTPW + WDTHOLD; P1DIR |= 0x01; CCTL0 = CCIE; //CCR0 = 50000;//不加加这句话 TACTL = TASSEL_2 + MC_2; _BIS_SR(LPM0_bits + GIE); // Enter LPM0 w/ interrupt}// Timer A0 interrupt service routine#pragma vector=TIMER0_A0_VECTOR__interrupt void Timer_A (void){ P1OUT ^= 0x01; CCR0 += 50000; //加这句话这个程序周期定为50000产生的周期 } 3)#include <msp430g2553.h>void main(void){ WDTCTL = WDTPW + WDTHOLD; P1DIR |= 0x01; CCTL0 = CCIE; CCR0 = 50000;//加这句话 TACTL = TASSEL_2 + MC_2; _BIS_SR(LPM0_bits + GIE); // Enter LPM0 w/ interrupt}// Timer A0 interrupt service routine#pragma vector=TIMER0_A0_VECTOR__interrupt void Timer_A (void){ P1OUT ^= 0x01; CCR0 += 50000; //加这句话这个程序周期定为50000产生的周期 4)void main(void){ WDTCTL = WDTPW + WDTHOLD; P1DIR |= 0x01; CCTL0 = CCIE; CCR0 = 50000;//加这句话 TACTL = TASSEL_2 + MC_2; _BIS_SR(LPM0_bits + GIE); // Enter LPM0 w/ interrupt}// Timer A0 interrupt service routine#pragma vector=TIMER0_A0_VECTOR__interrupt void Timer_A (void){ P1OUT ^= 0x01; CCR0 = 50000; //加不加这句话这个程序周期定为65535产生的周期
-
几个浏览器都试了,都是这个问题……
[ 本帖最后由 亦轩阁 于 2012-7-10 00:11 编辑 ]
-
真不错!看了它很有收获!谢谢!
-
感谢楼主!:)
-
必须顶!
-
:Laugh:谢谢!
-
谢谢!
-
下载了!学习!!!谢谢!
-
支持!顶!!!
-
收藏……谢谢!