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

can not see input

Maybe someone can help me out...????

I am having the following problem....
I am using in- and outputs on P1 of a 87C51R+ micro.
As far as I can tell I have correctly set the inputs of the port by sending a "1" to them.
Even though it all seems to function in dscope, it doesn't on the micro board.
example:

sfr trigger = P1^0;
If not mistaken if I have code reading the bit, shouldn't it react in some way..???
eg:
if(trigger == 1){
    ........
}
this problem doesn't allways exist, only on some projects. Just seem to be able to find out what I am doing wrong. Any help appreciated.

Parents
  • By default, all lines of P1 are set as inputs. The following code:

    if(trigger == 1){
        ........
    }

    checks for all bits except bit 0 to be set to 0. If you are really only interested in bit 0, you should probably use the following:

    if(trigger & 0x01){
        ........
    }

    Jon

Reply
  • By default, all lines of P1 are set as inputs. The following code:

    if(trigger == 1){
        ........
    }

    checks for all bits except bit 0 to be set to 0. If you are really only interested in bit 0, you should probably use the following:

    if(trigger & 0x01){
        ........
    }

    Jon

Children
No data