We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Because of Layout I had connected P1.0 to LCD.7, P1.1 to LCD.6 ... P1.7 to LCD.0! Now I have to convert the sending and incoming data. MSB has to become LSB. Is their a esay way to do this? Thanks a lot
I would be tempted to try something like the following (I can't try it now because I am at a location without access to my Keil toolchain).
static unsigned char bdata src_byte; static unsigned char bdata dst_byte; static sbit src_bit0 = src_byte ^ 0; static sbit src_bit1 = src_byte ^ 1; static sbit src_bit2 = src_byte ^ 2; static sbit src_bit3 = src_byte ^ 3; static sbit src_bit4 = src_byte ^ 4; static sbit src_bit5 = src_byte ^ 5; static sbit src_bit6 = src_byte ^ 6; static sbit src_bit7 = src_byte ^ 7; static sbit dst_bit0 = dst_byte ^ 0; static sbit dst_bit1 = dst_byte ^ 1; static sbit dst_bit2 = dst_byte ^ 2; static sbit dst_bit3 = dst_byte ^ 3; static sbit dst_bit4 = dst_byte ^ 4; static sbit dst_bit5 = dst_byte ^ 5; static sbit dst_bit6 = dst_byte ^ 6; static sbit dst_bit7 = dst_byte ^ 7; unsigned char reverse_bits(unsigned char b) { src_byte = b; dst_bit0 = src_bit7; dst_bit1 = src_bit6; dst_bit2 = src_bit5; dst_bit3 = src_bit4; dst_bit4 = src_bit3; dst_bit5 = src_bit2; dst_bit6 = src_bit1; dst_bit7 = src_bit0; return dst_byte; }
MOV C,src_bit7 MOV dst_bit0,C ; ...