I am now learning avr programming using c. I have a problem with bitshifting. Suppose I have a 8 bit register named jcb containing 01110011. I want to get the upper 4 bits in vh variable. So, I do vh = (jcb >> 4). Now the value of vh must be 0111. But if now I do vl = jcb , what is the binary value containing in vl in 8 bit?
01110011 again, since you didn't do anything to change jcb, such as jcb = jcb>>4;
If you wanted the lower 4 bits of jcb in vl, then mask the upper 4 bits off.
vl = 0x0F & jcb; // upper 4 bits = 0, lower 4 bits = 0011