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
  • sorry, here's the whole code:

    #include <reg51.h>
    
     unsigned long a = 0xFA6;
     unsigned long b = 0xB82;
     unsigned long c = 0xE2A;
     unsigned long d = 0xC30;
     unsigned long y;
     unsigned long sum;
     unsigned long delta;
     unsigned long n;
     sbit pin37 = P3^7;
    
     int main(){
    
       pin37 = 1;
       while(1){
         sum = 0;
         delta = 0x9E3779B9;
         n = 32;
         y = P1;
    
         while(n-->0)
         {
           sum += delta;
           y += (y << 3) + a^y + sum^(y >> 6) + b;
         }
    
         for(n=0; n<32; n++)
         {
           y >>= 1;
           pin37 = y[1];
         }
       }
     }
    

Reply
  • sorry, here's the whole code:

    #include <reg51.h>
    
     unsigned long a = 0xFA6;
     unsigned long b = 0xB82;
     unsigned long c = 0xE2A;
     unsigned long d = 0xC30;
     unsigned long y;
     unsigned long sum;
     unsigned long delta;
     unsigned long n;
     sbit pin37 = P3^7;
    
     int main(){
    
       pin37 = 1;
       while(1){
         sum = 0;
         delta = 0x9E3779B9;
         n = 32;
         y = P1;
    
         while(n-->0)
         {
           sum += delta;
           y += (y << 3) + a^y + sum^(y >> 6) + b;
         }
    
         for(n=0; n<32; n++)
         {
           y >>= 1;
           pin37 = y[1];
         }
       }
     }
    

Children