Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

What is the purpose of HEX in electronics?

Status
Not open for further replies.
I can do hex conversions off the top of my head - ten minutes ago I typed in h'AA' to test a uart transmission because I knew it was 10101010.

But using them to set up function registers is just silly. Use binary.
 
I can do hex conversions off the top of my head - ten minutes ago I typed in h'AA' to test a uart transmission because I knew it was 10101010.

But using them to set up function registers is just silly. Use binary.

If you were setting up a register bit by bit it makes sense to work and think in binary. At that point you could use the binary value in the code. But there is one subtle reason not to. It is easy to look at a 2 digit hex pattern and reconize it. It is a lot harder to do with eight bits. A seasoned program might look at a register value of 0x5A and know that it is right. The brain would have a more difficult time with 0b01011010.
 
AA and 55 are excluded. Anyone that deals with a UART knows those two.
 
Toss in 0x00 and 0xFF and you only have 12 more to go.

B and D give people problems but they are the reverse of each other as are 3 and C
B 1011 D 1101
3 0011 C 1100

E 1110 is easy because it is one less the F 1111

That about covers it.
 
WHAT A LOAD OF RUBBISH!

HEX in electronics is the voodoo curse someone has put into the circuit, which we are convinced we created correctly ;)
 
Toss in 0x00 and 0xFF and you only have 12 more to go.

Also exclude 1, 2, 4 and 8 - now you only have 8 to go. 1110 is kind of a gimme, so is 11, 101 (mentioned) and 1001 - now you have four to go, B, D, C, and 6 - which you memorize by remembering that B and D are those two inverse ones, and the 6 is the one with the two in the middle.

But setting bits in registers using hex is SILLY. It's like dates in roman numerals or something.
 
Most ASM code and almost all C code I've ever seen use bit shifts never hex declarations.
Only time I see hex declarations are for eeprom/flash tables or headers.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top