ѧϰMSP430֮Timer_A

qui26   2012-7-12 16:40 Â¥Ö÷

        MSP430F2xxxµÄT_AÊÇÒ»¸ö16λµÄ¶¨Ê±Æ÷/¼ÆÊýÆ÷£¬ÓÐ3¸ö"²¶»ñ/±È½Ï¼Ä´æÆ÷",¶¨Ê±Æ÷(T_A)Óë"²¶»ñ/±È½Ï¼Ä´æÆ÷"(CCRx)¹¤×÷ÊÇÏà¶Ô¶ÀÁ¢µÄ.

¼ÆÊýÆ÷TARÈýÖÖģʽ(Ôö¼ÆÊý£¬Á¬Ðø¼ÆÊý£¬Ôö¼õ¼ÆÊý)¡£·ÖÉèÖÃMC1¡¢MC0룬ÉèÖúó£¬T_A¾Í¿ªÊ¼¼ÆÊýÁË¡£ÉϵçĬÈÏΪMC1=0£¬MC0=0Ϊֹͣ¡£
ÄÇôÓû¶¨Ê±Ò»¶Îʱ¼äÖÜÆڵĻ°,¿ÉÒÔÓÐÁ½ÖÖ·½·¨:

      Ò»ÊÇT_A¼ÆÊý,¼Æµ½Ò»¶¨Öµ²úÉúT_AÖжÏ;

      ¶þÊÇÓÃCCRxºÍ¼ÆÊýÖµ±È½Ï,Ò»ÖµĻ°²úÉúCCRxÖжÏ.(±È½Ïģʽ£¬Ò²ÊÇÉϵçĬÈÏģʽ)Öжϡ£Ã¿µ±Ò»¶¨µÄʱ¼ä¼ä¸ô¶¼»á²úÉúÖжÏÇëÇó£¬ÄÇô£¬Ð轫ÏÂһʼþ·¢ÉúµÄʱ¼äÔÚµ±Ç°µÄÖжϳÌÐòÖмӵ½CCRxÖС£

 

     ¼û³ÌÐò£º

 

  1.  

  1. #include "msp430x22x4.h"
    int main( void )
    {
    WDTCTL=WDTPW+WDTHOLD;
    BCSCTL1=CALBC1_1MHZ;
    DCOCTL = CALDCO_1MHZ;
    TACTL=TASSEL1+TACLR; //SMCLK=VLOCLK=12KHZ£¬Çå³þTAR
    CCTL0=CCIE; //ÖжÏÔÊÐí
    CCR0=50000; //·½²¨ÆµÂÊ£º1m/50000
    P1DIR|=BIT0;
    TACTL|=MC1; //Á¬Ðø¼ÆÊý
    _EINT();
    _BIS_SR(LPM0_bits);
    return 0;
    }
    #pragma vector=TIMERA0_VECTOR
    __interrupt void TIMER_A(void)
    {
    P1OUT^=BIT0;
    CCR0+=50000;
    }

»Ø¸´ÆÀÂÛ £¨5£©

Ê×Ìù£¡
¸øÄã¸ö½±Àø£¬Ð»Ð»·ÖÏí
µãÔÞ  2012-7-12 17:13
ΪʲôҪÔÚÖжÏÀïÖØи³ÖµCCR0ÄØ£¿
µãÔÞ  2012-7-12 19:36
Äܲ»Äܽ²½²ÁíÖÖ·½·¨
µãÔÞ  2012-7-12 21:07
µÚÒ»´Î·¢Ìù£¬Ð»Ð»°æÖ÷µÄ¹ÄÀø¡£
µãÔÞ  2012-7-12 21:17
Ôõô²»ºÃʹ°¡

#include
int main( void )
{
        WDTCTL=WDTPW+WDTHOLD;
        BCSCTL1=CALBC1_1MHZ;  //g¹¤×÷ƵÂÊ
        DCOCTL = CALDCO_1MHZ; // ÉèÖù¤×÷ƵÂÊ
        TACTL=TASSEL1+TACLR; //SMCLK=VLOCLK=12KHZ£¬Çå³þTAR
CCTL0=CCIE; //ÖжÏÔÊÐí
CCR0=50000; //·½²¨ÆµÂÊ£º1m/50000
P1DIR|=BIT0;
TACTL|=MC1; //Á¬Ðø¼ÆÊý
_EINT();
_BIS_SR(LPM0_bits);
return 0;
}
#pragma vector=TIMERA0_VECTOR
__interrupt void TIMER_A(void)
{
P1OUT^=BIT0;
CCR0+=50000;
}
µãÔÞ  2012-7-12 21:39
µç×Ó¹¤³ÌÊÀ½ç°æȨËùÓÐ ¾©B2-20211791 ¾©ICP±¸10001474ºÅ-1 ¾©¹«Íø°²±¸ 11010802033920ºÅ
    д»Ø¸´