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 Reply Children
  • p.s.
    The "^0" syntax only means "bit zero" in an sbit declaration. Anywhere else, it means "XOR 0", so:

    sfr trigger = P1^0;
    means exactly the same as
    sfr trigger = P1;
    which is why the compiler did not flag it as an error.
    As Jon pointed out, if the other bits of PORT1 are low, your test will work, but if any of them are high, it will fail, because you are testing the value read from the entire port.