MSP430F2xxxµÄT_AÊÇÒ»¸ö16λµÄ¶¨Ê±Æ÷/¼ÆÊýÆ÷£¬ÓÐ3¸ö"²¶»ñ/±È½Ï¼Ä´æÆ÷",¶¨Ê±Æ÷(T_A)Óë"²¶»ñ/±È½Ï¼Ä´æÆ÷"(CCRx)¹¤×÷ÊÇÏà¶Ô¶ÀÁ¢µÄ.
¼ÆÊýÆ÷TARÈýÖÖģʽ(Ôö¼ÆÊý£¬Á¬Ðø¼ÆÊý£¬Ôö¼õ¼ÆÊý)¡£·ÖÉèÖÃMC1¡¢MC0룬ÉèÖúó£¬T_A¾Í¿ªÊ¼¼ÆÊýÁË¡£ÉϵçĬÈÏΪMC1=0£¬MC0=0Ϊֹͣ¡£
ÄÇôÓû¶¨Ê±Ò»¶Îʱ¼äÖÜÆڵĻ°,¿ÉÒÔÓÐÁ½ÖÖ·½·¨:
Ò»ÊÇT_A¼ÆÊý,¼Æµ½Ò»¶¨Öµ²úÉúT_AÖжÏ;
¶þÊÇÓÃCCRxºÍ¼ÆÊýÖµ±È½Ï,Ò»ÖµĻ°²úÉúCCRxÖжÏ.(±È½Ïģʽ£¬Ò²ÊÇÉϵçĬÈÏģʽ)Öжϡ£Ã¿µ±Ò»¶¨µÄʱ¼ä¼ä¸ô¶¼»á²úÉúÖжÏÇëÇó£¬ÄÇô£¬Ð轫ÏÂһʼþ·¢ÉúµÄʱ¼äÔÚµ±Ç°µÄÖжϳÌÐòÖмӵ½CCRxÖС£
¼û³ÌÐò£º
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;
}