18.11.2014 Views

The Microcontroller Idea Book - Jan Axelson's Lakeview Research

The Microcontroller Idea Book - Jan Axelson's Lakeview Research

The Microcontroller Idea Book - Jan Axelson's Lakeview Research

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Appendix C<br />

This table shows the value of each digit in the decimal number 193:<br />

Decimal digit 1 9 3<br />

Digit multiplier 10 2 10 1 10 0<br />

Digit value 100 90 3<br />

Binary Numbers<br />

In the binary number system, each digit represents a value raised to a power of 2. <strong>The</strong><br />

numbers use only two of the ten decimal digits (0 and 1).<br />

Binary representations are useful when you need to quickly see the value of each bit in a<br />

byte. For example, you might want to set, clear, toggle, or read a bit in one of the 8052’s<br />

special function registers (TCON, PCON, and so on). Or, in a control circuit, individual bits<br />

might control switches or relays. BASIC-52’s logical operators offer a way to control and<br />

display individual bit values.<br />

This table shows the value of each digit in 1100 0001, which is the binary representation of<br />

the decimal number 193:<br />

Binary bit 1 1 0 0 0 0 0 1<br />

Bit multiplier 2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 0<br />

Bit value (decimal) 128 64 0 0 0 0 0 1<br />

Hexadecimal Numbers<br />

In the hexadecimal (or hex) number system, each character represents a value raised to a<br />

power of 16. <strong>The</strong>re are 16 characters, with the letters A through F representing the decimal<br />

values 10 through 15.<br />

Because each character in a hex number represents 4 bits, hex numbers are a convenient,<br />

compact way to express 8-bit or 16-bit numbers. In BASIC-52, you enter hex values at the<br />

host system’s keyboard by adding a trailing h to the number. (Example: 1Fh.) If the first<br />

character is in the range A-F, you must also add a leading 0. (Example: 0E9h.) BASIC-52’s<br />

PH0. and PH1. operators display numbers in hex format on the host computer’s screen.<br />

272 <strong>The</strong> <strong>Microcontroller</strong> <strong>Idea</strong> <strong>Book</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!