This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] CCS/MSP430FR2355:CCS/MSP430FR2355

Guru**** 2524460 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/836593/ccs-msp430fr2355-ccs-msp430fr2355

器件型号:MSP430FR2355

工具/软件:Code Composer Studio

在该程序中、我们将在计时器以连续模式工作时添加偏移。我不知道该偏移值如何影响该代码中的计时器。请向我解释该程序背后的逻辑、因为我只是初学者。

#include 

int main (void)
{
WDTCTL = WDTPW | WDTHOLD; //停止 WDT

//配置 GPIO
P1DIR |= BIT0; // P1.0输出
P1OUT |= BIT0; // P1.0高位

//禁用 GPIO 上电默认高阻抗模式以激活
//先前配置的端口设置
PM5CTL0 &=~LOCKLPM5;

TB0CCTL0 |= CCIE; // TBCCR0中断被使能
TB0CCR0 = 50000;
TB0CTL |= TBSSEL_SMCLK | MC__Continous; // SMCLK、连续模式

_bis_SR_register (LPM0_bits | GIE); //输入带中断的 LPM3
__no_operation(); //用于调试
}

//计时器 B0中断服务例程
#if defined (__TI_Compiler_version__)|| Defined (__IAR_systems_ICC__)
#pragma vector = TIMER0_B0_Vector
__interrupt void Timer_B (void)
#Elif defined (__GNU__)
#void __attribute_(TIMER0_bvector

)(void Timer_b0)(void Timer_bid)(void Timer0_error)(void Timer0_bid)(void Timer0_bid)(void)
#endif
{
P1OUT ^= BIT0;
TB0CCR0 += 50000; //将偏移添加到 TBCCR0
}