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

selecting a single bit from a 32-bit word

I've a simple question. I'm trying to send a 32-bit word serial on an AT89C1051U. I'm trying to use a for loop and send the LSB each time, and then shift to the right every iteration. This, in theory, would allow me to send each bit no problem. Here's the code I tried, but I kept getting array problems.

     for(n=0; n<32; n++)
     {
       p3 = y;
       y >>= 1;
     }

Parents
  • There's no array anywhere in that snippet. It usually helps if you cut-and-paste the exact source code from your project. When people rewrite it into an example, sometime they erase the problem.

    Exactly what error messages are you getting from the compiler? (And lint?)

    Is "p3" supposed to be a pointer? In that case, you need some sort of dereference (*p3 or p3[...]). Is it perhaps a bit variable?

    Either way, you probably should make it more clear that you are extracting the LSB from y, something like

    bitToSend = y & 1;

Reply
  • There's no array anywhere in that snippet. It usually helps if you cut-and-paste the exact source code from your project. When people rewrite it into an example, sometime they erase the problem.

    Exactly what error messages are you getting from the compiler? (And lint?)

    Is "p3" supposed to be a pointer? In that case, you need some sort of dereference (*p3 or p3[...]). Is it perhaps a bit variable?

    Either way, you probably should make it more clear that you are extracting the LSB from y, something like

    bitToSend = y & 1;

Children