我的代码没有编译,CCTL0未定义

时间:2014-03-27 22:00:32

标签: embedded msp430 texas-instruments

抱歉新手问题。尝试将此代码移植到msp430f5529。它没有编译,“标识符CCTL0未定义”。我使用错误的时钟吗?错了.h?既?

//***************************************************************************************
// MSP430 Timer Blink LED Demo - Timer A Software Toggle P1.0 & P1.6
//
// Description; Toggle P1.0 and P1.6 by xor'ing them inside of a software loop.
// Since the clock is running at 1Mhz, an overflow counter will count to 8 and then toggle
// the LED. This way the LED toggles every 0.5s.
// ACLK = n/a, MCLK = SMCLK = default DCO
//4
// MSP430G2xx
// -----------------
// /|\| XIN|-
// | | |
// --|RST XOUT|-
// | P1.6|-->LED
// | P1.0|-->LED
//
// Aldo Briano
// Texas Instruments, Inc
// June 2010
// Built with Code Composer Studio v4
//***************************************************************************************
//#include <msp430g2231.h>
//#include <msp430.h>
#include <msp430f5529.h>

#define LED_0 BIT0
#define LED_1 BIT6
#define LED_OUT P1OUT
#define LED_DIR P1DIR

unsigned int timerCount = 0;

//----------------------------------------------------------------------------------------------
void main(void)
{
    WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
    LED_DIR |= (LED_0 + LED_1); // Set P1.0 and P1.6 to output direction
    LED_OUT &= ~(LED_0 + LED_1); // Set the LEDs off

    CCTL0 = CCIE;
    TACTL = TASSEL_2 + MC_2; // Set the timer A to SMCLCK, Continuous
// Clear the timer and enable timer interrupt

    __enable_interrupt();

    __bis_SR_register(LPM0 + GIE); // LPM0 with interrupts enabled

}

// Timer A0 interrupt service routine
#pragma vector=TIMERA0_VECTOR
//----------------------------------------------------------------------------------------------
__interrupt void Timer_A(void)
{
    timerCount = (timerCount + 1) % 8;

    if (timerCount == 0)
        P1OUT ^= (LED_0 + LED_1);
}

1 个答案:

答案 0 :(得分:4)

我没有使用F5529,但我曾与其他F5x家族合作,即F5437&amp; A54和非A版本的F5438。

您必须将示例移植到您的设备,因此CCTL0&amp;必须用您的微控制器寄存器替换TACTL寄存器。看看你device's datasheet。 它肯定会以下列形式出现: TAxCCTL0 和 TAxCTL 其中x是您正在使用的计时器。

从我在代码中看到的你将使用TimerA0,这样就可以使它们成为TA0CCTL0和TA0CTL。

希望这有帮助。