標(biāo)題: STC單片機(jī)IO配置函數(shù)1,源碼 [打印本頁]

作者: huangxia368    時(shí)間: 2021-10-20 10:13
標(biāo)題: STC單片機(jī)IO配置函數(shù)1,源碼
//高阻輸入狀態(tài)
//PXM0 = 0; PXM1 = 1
void Set_IO_Input(uchar nPort,uchar nBit)                //設(shè)置IO口為輸入狀態(tài)
{
    uchar M0,M1;       
        M1 = 0x01<<nBit;
        M0 = ~(M1);
        if(nPort==0)
        {        P0M0 &= M0;
                P0M1 |= M1;
        }
        else if(nPort==1)
        {        P1M0 &= M0;
                P1M1 |= M1;
        }
        else if(nPort==2)
        {        P2M0 &= M0;
                P2M1 |= M1;
        }
        else if(nPort==3)
        {        P3M0 &= M0;
                P3M1 |= M1;
        }

    else if(nPort==4)
        {        P4M0 &= M0;
                P4M1 |= M1;
        }
    else if(nPort==5)
        {        P5M0 &= M0;
                P5M1 |= M1;
        }
        else if(nPort==6)
        {        P6M0 &= M0;
                P6M1 |= M1;
        }
        else if(nPort==7)
        {        P7M0 &= M0;
                P7M1 |= M1;
        }
}






歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1