This type of conversion from binary to hexadecimal often needed during microprocessors registers configuration. By reading microprocessors datasheet you can found what specified registers bit must be set, but how to convert it to hexadecimal number and use it in program code? Below example with Atmega8 TCCR2 register.
Lets convert 01101001 to 0x69.
- Split byte by half
- Above both parts each bite write these numbers 8 4 2 1 (2^n)
- In both parts separately sum up numbers if bite below is 1
- Remember it’s hexadecimal number system, 10 – A, 11 -B, 12 -C, 13 -D, 14 -E, 15 – F.
- Congratulation, you now have two hexadecimal number digits.