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.

msp430g2412比较器的问题?

Other Parts Discussed in Thread: MSP430G2412

你好,我用msp430g2412的  P1.5(CA5)输入一个电压,  P1.0(CA0)为输入的参考电压2.5v,比较它们的大小。但是不管P1.5的电压怎样变化,CAOUT都没有变化呢?这是怎么回事。

void main(void)
{
    WDTCTL = WDTHOLD + WDTPW;         // 关看门狗

//    P1SEL |=BIT0+BIT5;
    CAPD |=BIT0+BIT5;
    P2DIR |=BIT2+BIT3+BIT4;
    P2OUT |=BIT2+BIT4;
    
    CACTL1 |= CAON+CAIE;   //使用 CA0接P1.0 这2.5V参考电压    
    CACTL2 |= P2CA0+P2CA1+P2CA3;        // 使用 CA5接P1.5  接比较电压
    
    
 
    while(1)
    {

      if((CACTL2 & CAOUT))
      {
        if(i++>2000)
        {
          i=0;
          P2OUT |=BIT3;
          P2OUT ^=BIT4;
        
  //      CACTL1 |=CAEX;
        }
      }

      else
      {
        if(i++>2000)
        {
          i=0;
          P2OUT |=BIT4;
          P2OUT ^=BIT3;
   //      CACTL1 &=~CAEX;
        }
       }
    
    
}
}