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.

2530输出方波

芯片:2530

协议栈:mesh1.0.0

问题:请问我用以下程序输出4khz的方波是否正确?用P1_2的IO翻转模拟方波。

void T3timerInit( void )
{
    P1SEL &= ~0x04;            //将P1_2设置为通用IO输出
    P1DIR |= 0x04;
    P1_2 = 0;
    T3CTL |= 0x08;             //开溢出中断
    T3IE = 1;                  //开T3定时器总中断  
    T3CTL|=0X80;               //16分频
    T3CTL &= ~0X03;            //自动重装
    T3CTL |= 0X10;             //启动
    EA = 1;                    //开总中断
}


/************************************

中断函数

************************************/

#pragma vector = T3_VECTOR  //定时器 T3

__interrupt void T3_ISR(void)
{

    TIMIF &= ~BV(0);    //清中断标志位
    P1_2 = ~P1_2;   // 电平翻转产生方波
}