This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Reading Pins

Dear All,

I've tried to read the pin of Port1 , but i failed .
I should write one to it right ? , how do i read a one again ?
If i tried to write the following code,it works without checking the status of the pin

Port1_3=1;
if(Port1_3==1)
{
// execute code here ..
// code here executes in the simulator //without checking if the pin is //high or not
}
thanks in advance

Parents
  • its supposed to be
    sbit P1_3=P1^3;


    NO, do not use Px.y in code, only in definitions. use something like
    sbit SBG_P1_USB_SSI = 0x96; // USB SSI


    a surefire way (TCON as an example):

    sbit SB_TCON_TF1 = 0x8F;
    sbit SB_TCON_TR1 = 0x8E;
    sbit SB_TCON_TF0 = 0x8D;
    sbit SB_TCON_TR0 = 0x8C;
    sbit SB_TCON_IE1 = 0x8B;
    sbit SB_TCON_IT1 = 0x8A;
    sbit SB_TCON_IE0 = 0x89;
    sbit SB_TCON_IT0 = 0x88;

    This avoid ALL confusion. I like to remove confusion, that keeps me more productive.

    I find using SB_TCON_ in the definitions very helpful (a global search on TCON gives all uses whether bit set ot SFR load) but, if you find that distasteful, the method works with any naming convention.

    Erik

Reply
  • its supposed to be
    sbit P1_3=P1^3;


    NO, do not use Px.y in code, only in definitions. use something like
    sbit SBG_P1_USB_SSI = 0x96; // USB SSI


    a surefire way (TCON as an example):

    sbit SB_TCON_TF1 = 0x8F;
    sbit SB_TCON_TR1 = 0x8E;
    sbit SB_TCON_TF0 = 0x8D;
    sbit SB_TCON_TR0 = 0x8C;
    sbit SB_TCON_IE1 = 0x8B;
    sbit SB_TCON_IT1 = 0x8A;
    sbit SB_TCON_IE0 = 0x89;
    sbit SB_TCON_IT0 = 0x88;

    This avoid ALL confusion. I like to remove confusion, that keeps me more productive.

    I find using SB_TCON_ in the definitions very helpful (a global search on TCON gives all uses whether bit set ot SFR load) but, if you find that distasteful, the method works with any naming convention.

    Erik

Children