main.c

来自「PHILIPS LPC76X Comparator」· C语言 代码 · 共 39 行

C
39
字号
    #include <REG768.H>

    void main (void)
    {
        unsigned char i;

    /************************************************
    Set CIN1A(P0^4) and CIN2A(P0^2 as Input Only and
    CMP1 Out(P0^6) and CMP2 Out(P0^0) as Push-Pull
    Output
    ************************************************/

        P0M2 &= ~0x14;  // Set P0^4 and P0^2 Input Only
        P0M1 |=  0x14;  // Disable Dig Out on Cmp Input pins.
        PT0AD =  0x14;  // Disable Digital Input on CMP pins.

    /****************************************************
    Enable the Comparator 1 with Pos In on CIN1A and
    Neg In from internal Vref of 1.28V.
    ****************************************************/
        CMP1  = 0x2C;
   
    /****************************************************
    Enable the Comparator 2 with Pos In on CIN2A and
    Neg In from external CMPREF.
    ****************************************************/
        CMP2  = 0x24;

    /********************************************************
    Delay 10uSec to allow comparator to stabilize
    ********************************************************/
        for (i=0; i<= 10; i++);    // Do nothing delay 10uSec
        while(1)
        {
            ;  // Loop Forever
            ;  // Your software here 
        }
    }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?