Ibrahim Dogan - Advanced PIC Microcontroller Projects in C

Здесь есть возможность читать онлайн «Ibrahim Dogan - Advanced PIC Microcontroller Projects in C» весь текст электронной книги совершенно бесплатно (целиком полную версию без сокращений). В некоторых случаях можно слушать аудио, скачать через торрент в формате fb2 и присутствует краткое содержание. Город: Burlington, Год выпуска: 2008, ISBN: 2008, Издательство: Elsevier Ltd, Жанр: Программирование, Компьютерное железо, на английском языке. Описание произведения, (предисловие) а так же отзывы посетителей доступны на портале библиотеки ЛибКат.

Advanced PIC Microcontroller Projects in C: краткое содержание, описание и аннотация

Предлагаем к чтению аннотацию, описание, краткое содержание или предисловие (зависит от того, что написал сам автор книги «Advanced PIC Microcontroller Projects in C»). Если вы не нашли необходимую информацию о книге — напишите в комментариях, мы постараемся отыскать её.

• The only project book on the PIC 18 series using the C programming language
• Features 20 complete, tried and test projects
• Includes a CD-ROM of all the programs, hex listings, diagrams, and data sheets

Advanced PIC Microcontroller Projects in C — читать онлайн бесплатно полную книгу (весь текст) целиком

Ниже представлен текст книги, разбитый по страницам. Система сохранения места последней прочитанной страницы, позволяет с удобством читать онлайн бесплатно книгу «Advanced PIC Microcontroller Projects in C», без необходимости каждый раз заново искать на чём Вы остановились. Поставьте закладку, и сможете в любой момент перейти на страницу, на которой закончили чтение.

Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать

EE 16 = 14 × 16 1 + 14 × 16 0

= 224 + 14

= 238

The decimal number is 238 10.

1.11 Converting Decimal Numbers into Hexadecimal

To convert a decimal number into hexadecimal, divide the number repeatedly by 16 and take the remainders. The first remainder is the LSD, and the last remainder is the MSD.

Example 1.13

Convert decimal number 238 10into hexadecimal.

Solution 1.13

Dividing the number repeatedly by 16:

238/16 → 14 Remainder 14 (E) (LSD)

14/16 → 0 Remainder 14 (E) (MSD)

The hexadecimal number is EE 16.

Example 1.14

Convert decimal number 684 10into hexadecimal.

Solution 1.14

Dividing the number repeatedly by 16:

684/16 → 42 Remainder 12 (C) (LSD)

42/16 → 2 Remainder 10 (A)

2/16 → 0 Remainder 2 (MSD)

The hexadecimal number is 2AC 16.

1.12 Converting Octal Numbers into Decimal

To convert an octal number into decimal, calculate the sum of the powers of 8 of the number.

Example 1.15

Convert octal number 15 8into decimal.

Solution 1.15

Calculating the sum of the powers of 8 of the number:

15 8 = 1 × 8 1 + 5 × 8 0

= 8 + 5

= 13

The decimal number is 13 10.

Example 1.16

Convert octal number 237 8into decimal.

Solution 1.16

Calculating the sum of the powers of 8 of the number:

237 8 = 2 × 8 2 + 3 × 8 1 + 7 × 8 0

= 128 + 24 + 7

= 159

The decimal number is 159 10.

1.13 Converting Decimal Numbers into Octal

To convert a decimal number into octal, divide the number repeatedly by 8 and take the remainders. The first remainder is the LSD, and the last remainder is the MSD.

Example 1.17

Convert decimal number 159 10into octal.

Solution 1.17

Dividing the number repeatedly by 8:

159/8 → 19 Remainder 7 (LSD)

19/8 → 2 Remainder 3

2/8 → 0 Remainder 2 (MSD)

The octal number is 237 8.

Example 1.18

Convert decimal number 460 10into octal.

Solution 1.18

Dividing the number repeatedly by 8:

460/8 → 57 Remainder 4 (LSD)

57/8 → 7 Remainder 1

7/8 → 0 Remainder 7 (MSD)

The octal number is 714 8.

Table 1.3 shows the octal equivalent of decimal numbers 0 to 31.

Table 1.3: Octal equivalent of decimal numbers

Decimal Octal Decimal Octal
0 0 16 20
1 1 17 21
2 2 18 22
3 3 19 23
4 4 20 24
5 5 21 25
6 6 22 26
7 7 23 27
8 10 24 30
9 11 25 31
10 12 26 32
11 13 27 33
12 14 28 34
13 15 29 35
14 16 30 36
15 17 31 37

1.14 Converting Octal Numbers into Binary

To convert an octal number into binary, write the 3-bit binary equivalent of each octal digit.

Example 1.19

Convert octal number 177 8into binary.

Solution 1.19

Write the binary equivalent of each octal digit:

1 = 001 27 = 111 27 = 111 2

The binary number is 001111111 2.

Example 1.20

Convert octal number 75 8into binary.

Solution 1.20

Write the binary equivalent of each octal digit:

7 = 111 25 = 101 2

The binary number is 111101 2.

1.15 Converting Binary Numbers into Octal

To convert a binary number into octal, arrange the number in groups of three and write the octal equivalent of each digit.

Example 1.21

Convert binary number 110111001 2into octal.

Solution 1.21

Arranging in groups of three:

110111001 = 110 111 001

6 7 1

The octal number is 671 8.

1.16 Negative Numbers

The most significant bit of a binary number is usually used as the sign bit. By convention, for positive numbers this bit is 0, and for negative numbers this bit is 1. Figure 1.5 shows the 4-bit positive and negative numbers. The largest positive and negative numbers are +7 and –8 respectively.

Binary number Decimal equivalent
0111 +7
0110 +6
0101 +5
0100 +4
0011 +3
0010 +2
0001 +1
0000 0
1111 −1
1110 −2
1101 −3
1100 −4
1011 −5
1010 −6
1001 −7
1000 −8
картинка 5

Figure 1.5: 4-bit positive and negative numbers

To convert a positive number to negative, take the complement of the number and add 1. This process is also called the 2’s complement of the number.

Example 1.22

Write decimal number −6 as a 4-bit number.

Solution 1.22

First, write the number as a positive number, then find the complement and add 1:

0110+6

1001complement

1add 1

−−−−

1010which is −6

Example 1.23

Write decimal number −25 as a 8-bit number.

Solution 1.23

First, write the number as a positive number, then find the complement and add 1:

00011001+25

11100110complement

1add 1

–––––––-

11100111 which is −25

1.17 Adding Binary Numbers

The addition of binary numbers is similar to the addition of decimal numbers. Numbers in each column are added together with a possible carry from a previous column. The primitive addition operations are:

0 + 0 = 0

0 + 1 = 1

1 + 0 = 1

1 + 1 = 10 generate a carry bit

1 + 1 + 1 = 11 generate a carry bit

Some examples follow.

Example 1.24

Find the sum of binary numbers 011 and 110.

Solution 1.24

We can add these numbers as in the addition of decimal numbers:

011First column: 1 + 0 + 1

+ 110Second column: 1 + 1 = 0 and a carry bit

-–––Third column: 1 + 1 = 10

1001

Example 1.25

Find the sum of binary numbers 01000011 and 00100010.

Solution 1.25

We can add these numbers as in the addition of decimal numbers:

Читать дальше
Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать

Похожие книги на «Advanced PIC Microcontroller Projects in C»

Представляем Вашему вниманию похожие книги на «Advanced PIC Microcontroller Projects in C» списком для выбора. Мы отобрали схожую по названию и смыслу литературу в надежде предоставить читателям больше вариантов отыскать новые, интересные, ещё непрочитанные произведения.


Отзывы о книге «Advanced PIC Microcontroller Projects in C»

Обсуждение, отзывы о книге «Advanced PIC Microcontroller Projects in C» и просто собственные мнения читателей. Оставьте ваши комментарии, напишите, что Вы думаете о произведении, его смысле или главных героях. Укажите что конкретно понравилось, а что нет, и почему Вы так считаете.

x