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.

[参考译文] 编译器/MSP430F5172:如何灵活使用timer0_d0?

Guru**** 2589245 points


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

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/620224/compiler-msp430f5172-how-to-use-the-timer0_d0-flexibly

部件号:MSP430F5172

工具/软件:TI C/C++编译器

尊敬的工程师:

我想用TD0来实现两个计时,两个计时 可以随时选择,但我不能完成。下面是我的代码。我的代码只能在计时时实现,另一个无法实现。 我需要工程师的帮助。

void main()
{
P1DIR |=BIT7;
TD0CCTL0 |=CCIE;
TD0CTL0=TDSSEL_2+MC_1;
Time_int();
while (1)
{
;}


未签名int select=0;
void time_int()
{

选择++;
如果(选择%2==1)
{
timer();
}
其他
{
timer_5();}

IF (SELECT==1000)
{
选择=0;
TD0CCTL0&=~CCIE;
}

void Timer()
{

TD0CCR0=873;
__bis_sr_register(GIE);
}
void Timer_5()
{
TD0CCR0=436;
__bis_sr_register(GIE);
}
#pragma vector=TIMER0_D0_vector
__interrupt void TIMER0_D0_ISR(void){

P1OUT ^=BIT7;
}