How to reverse the bits in a byte, for e.g. i have
LSB----------MSB
0 1 1 0 0 1 1 1
should be convert to
MSB----------LSB
1 1 1 0 0 1 1 0
and vice versa?
Because no microcontroller has a built in hardware instruction for bit reversal, you usually do it in a loop, utilizing shift instructions. I guess, you can easily figure out the C code for the operation.
The fastest method is however a ROM table of 256 bytes, that holds the reversed code for each possible input byte.
---------- Post added at 11:01 ---------- Previous post was at 11:00 ----------
One more solution i got from somewhere which i want to share:
for(count=1;count<=8;count++)
{
bit = num & 0x01;
num = num>>1;
output = output<<1;
if(bit==1)
output = output+1;
}