【问题标题】:My code does not compile, CCTL0 undefined我的代码无法编译,CCTL0 未定义
【发布时间】:2014-03-27 22:00:31
【问题描述】:

很抱歉有一个新手问题。试图将此代码移植到 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);
}

【问题讨论】:

  • 您认为 CCTL0 是什么或应该是什么?你从哪里得到那个的?我假设您认为它是一个定时器寄存器,或者至少它是原始代码中的一个定时器寄存器。我想这个处理器的定时器寄存器的命名[稍微]不同,或者如果你从用不同编译器编译的代码移植它,原始编译器中的头文件是不同的。不知道你认为你正在编程的外围设备中的哪个寄存器很难说。

标签: embedded msp430 texas-instruments


【解决方案1】:

我没有使用过 F5529,但我使用过其他 F5x 系列,即 A 和非 A 版本的 F5437 和 F5438。

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

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

希望这会有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-13
    • 2020-09-22
    • 2014-12-06
    • 2016-07-08
    相关资源
    最近更新 更多