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», без необходимости каждый раз заново искать на чём Вы остановились. Поставьте закладку, и сможете в любой момент перейти на страницу, на которой закончили чтение.

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

Интервал:

Закладка:

Сделать

Step 7 From the drop-down menu select Run→Start Debugger . The debugger form will pop up and select variables Sum, i , and PORTC as described in Example 5.2.

Step 8 Single-step through the program by pressing the F8 key. You should see the values of variables changing. At the end of the program, decimal value 55 will be sent to PORTC, and LEDs 0,1,2,4, and 5 should be turned ON, as shown in Figure 5.56, corresponding to this number.

Figure 556 Decimal number 55 shown in LEDs Step 9 Stop the debugger In - фото 160

Figure 5.56: Decimal number 55 shown in LEDs

Step 9 Stop the debugger.

In routines that contain delays, the Step Into [F7] and Step Over [F8] commands can take a long time. Run to Cursor [F4] and breakpoints should be used instead.

5.3.5 Using a Development Board

It is easy to develop microcontroller-based applications with the help of a development board. This section explains how to use the development board BIGPIC4, described earlier in this chapter. The program written in Example 5.1 is compiled and then loaded to the microcontroller using the on-board mikroICD in-circuit emulator. Then the program runs and displays the sum of the numbers 1 to 10 on the LEDs connected to PORTC.

However, before using the development board we need to know how the BIGPIC4 is organized and how to use the various devices on the board.

BIGPIC4 Development Board

Figure 5.57 shows the BIGPIC4 development board with the functions of various devices identified with arrows. The board can be powered either from an external power supply (8-to 16-C AC/DC) or from the USB port of a computer, using a jumper. In this application, the board is powered from a USB port.

Figure 557 BIGPIC4 development board A 2row by 16column LCD can be - фото 161

Figure 5.57: BIGPIC4 development board

A 2-row by 16-column LCD can be connected in the board’s upper left corner. The contrast of the LCD can be adjusted with a small potentiometer.

The forty-six LEDs on the board can be connected to the output ports of the microcontroller, selected by switch S2. Figure 5.58 shows how to select the LEDs, using PORTC as an example. 1K resistors are used in series with the LEDs to limit the current. For example, to connect eight LEDs to PORTC we have to set the switch arm marked PORTC of switch S2 to the ON position.

Figure 558 LED and pushbutton switch connections The fortysix pushbutton - фото 162

Figure 5.58: LED and push-button switch connections

The forty-six push-button switches on the board can be used to program digital inputs to the microcontroller. There is also a push-button switch that acts as the RESET. Jumper J12 determines whether a button press will bring logical 0 or logical 1 to the microcontroller. When the button is not pressed, the pin state is determined by jumper J5.

At the bottom central position, a 128×64 pixel graphics LCD can be connected to the board. The contrast of the LCD can be adjusted by a small potentiometer.

The MMC/SD card slot at the bottom right-hand corner of the board supports cards up to 2GB storage capacity.

The RESET button is located just above the MMC/SD card slot.

Above the RESET button are two potentiometers for analog-to-digital converter applications.

All of the microcontroller port pins are available at the connectors situated along the right-hand side of the board. In the top middle portion of the board are two RS232 ports and a connection to a PC keyboard.

The board supports both 64-pin and 80-pin microcontrollers. The board comes with a PIC18F8520 microcontroller connected to the board, operating with a 10MHz crystal. Further details about the operation of the board can be found in the BIGPIC4 user’s manual.

The steps in developing an application using the BIGPIC4 board are as follows:

Step 1 Double-click the mikroC icon to start the IDE.

Step 2 Create a new project called EXAMPLE2 (see Figure 5.59) and select the microcontroller type as PIC18F8520, the clock as 10MHz, and device flags as:

• _OSC_HS_1H

• _WDT_OFF_2H

• _LVP_OFF_4L

• _DEBUG_ON_4L

Figure 559 Creating a new project Step 3 Enter the following program into - фото 163

Figure 5.59: Creating a new project

Step 3 Enter the following program into the Code Editor section of the IDE:

/******************************************************************

EXAMPLE PROGRAM

This program uses the PICBIG4 Development Board. 8 LEDs are connected

to PORTC of the microcontroller which is a PIC18F8520 operating at 10MHz.

This program calculates the sum of integer numbers from 1 to 10

and then displays the sum on PORTC of the microcontroller.

Author: Dogan Ibrahim

File: EXAMPLE2.C

****************************************************************/

void main() {

unsigned int Sum,i;

TRISC = 0;

Sum = 0;

for(i=1; i <= 10; i++) {

Sum = Sum + i;

}

PORTC = Sum;

}

Step 4 Save the program with the name EXAMPLE2 by clicking File→Save As .

Step 5 Tick option ICD Debug in the Project Setup window. Compile the project by pressing CTRL+F9 or by clicking the Build Project button.

Step 6 Connect the BIGPIC4 development board to the USB port on the computer. Configure the development board by routing eight LEDs to PORTC: Set the arm marked PORTC on switch S2 to the ON position.

Step 7 Select Tools→PicFlash Programmer from the drop-down menu to program the microcontroller.

Step 8 Select Debugger→Select Debugger→mikroICD Debugger .

Step 9 Start the debugger by clicking Run→Start Debugger and select variables Sum, i , and PORTC from the Watch window.

Step 10 Single-step through the program until the end by repeatedly pressing F8. At the end of the program, the PORTC LEDs will turn ON to display decimal 55 (i.e., LEDs 0,1,2,4, and 5 will turn ON).

Step 11 Stop the debugger.

View the EEPROM Window The mikroICD EEPROM window is invoked from the mikroC IDE drop-down menu when the mikroICD debug mode is selected and started, and it displays contents of the PIC internal EEPROM memory. To view the memory, click View→Debug Windows→View EEPROM . Figure 5.60 shows an example EEPROM window display.

Figure 560 Display of EEPROM memory View the RAM Window The mikroICD RAM - фото 164

Figure 5.60: Display of EEPROM memory

View the RAM Window The mikroICD RAM window is invoked from the mikroC IDE drop-down menu when the mikroICD debug mode is selected and started, and it displays contents of the PIC internal RAM memory. To view the memory, click View→Debug Windows→View RAM . Figure 5.61 shows an example RAM window display.

Figure 561 Display of RAM memory View the Code Window The mikroICD Code - фото 165

Figure 5.61: Display of RAM memory

View the Code Window The mikroICD Code window is invoked from the mikroC IDE drop-down menu when the mikroICD debug mode is selected and started, and it displays the contents of the PIC internal code memory. To view the memory, click View→ Debug Windows→View Code . Figure 5.62 shows an example Code window display.

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

Интервал:

Закладка:

Сделать

Похожие книги на «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