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

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

Интервал:

Закладка:

Сделать

Low-level programming of a parallel LCD is usually a complex task and requires a good understanding of the internal operation of the LCD, including the timing diagrams. Fortunately, mikroC language provides functions for both text-based and graphic LCDs, simplifying the use of LCDs in PIC-microcontroller-based projects. The HD44780 controller is a common choice in LCD-based microcontroller applications. A brief description of this controller and information on some commercially available LCD modules follows.

The HD44780 LCD Controller

The HD44780 is one of the most popular LCD controllers, being used both in industrial and commercial applications and also by hobbyists. The module is monochrome and comes in different shapes and sizes. Modules with 8, 16, 20, 24, 32, and 40 characters are available. Depending on the model, the display provides a 14-pin or 16-pin connector for interfacing. Table 4.3 shows the pin configuration and pin functions of a typical 14-pin LCD.

Table 4.3: Pin configuration of the HD44780 LCD module

Pin no. Name Function
1 V SS Ground
2 V DD +ve supply
3 V EE Contrast
4 RS Register select
5 R/W Read/write
6 EN Enable
7 D0 Data bit 0
8 D1 Data bit 1
9 D2 Data bit 2
10 D3 Data bit 3
11 D4 Data bit 4
12 D5 Data bit 5
13 D6 Data bit 6
14 D7 Data bit 7

V SSis the 0V supply or ground. The V DDpin should be connected to the positive supply. Although the manufacturers specify a 5V DC supply, the modules usually work with as low as 3V or as high as 6V.

Pin 3 is named as V EEand is the contrast control pin. It is used to adjust the contrast of the display and should be connected to a DC supply. A potentiometer is usually connected to the power supply with its wiper arm connected to this pin and the other leg of the potentiometer connected to the ground. This way the voltage at the V EEpin, and hence the contrast of the display, can be adjusted as desired.

Pin 4 is the register select (RS) and when this pin is LOW, data transferred to the LCD is treated as commands. When RS is HIGH, character data can be transferred to and from the module.

Pin 5 is the read/write (R/W) pin. This pin is pulled LOW in order to write commands or character data to the LCD module. When this pin is HIGH, character data or status information can be read from the module.

Pin 6 is the enable (EN) pin, which is used to initiate the transfer of commands or data between the module and the microcontroller. When writing to the display, data is transferred only on the HIGH to LOW transition of this pin. When reading from the display, data becomes available after the LOW to HIGH transition of the enable pin, and this data remains valid as long as the enable pin is at logic HIGH.

Pins 7 to 14 are the eight data bus lines (D0 to D7). Data can be transferred between the microcontroller and the LCD module using either a single 8-bit byte or two 4-bit nibbles. In the latter case, only the upper four data lines (D4 to D7) are used. The 4-bit mode has the advantage of requiring fewer I/O lines to communicate with the LCD.

The mikroC LCD library provides a large number of functions to control text-based LCDs with 4-bit and 8-bit data interfaces, and for graphics LCDs. The most common are the 4-bit-interface text-based LCDs. This section describes the available mikroC functions for these LCDs. Further information on other text-or graphics-based LCD functions are available in the mikroC manual.

The following are the LCD functions available for 4-bit-interface text-based LCDs:

• Lcd_Config

• Lcd_Init

• Lcd_Out

• Lcd_Out_Cp

• Lcd_Chr

• Lcd_Chr_Cp

• Lcd_Cmd

Lcd_Config The Lcd_Config function is used to configure the LCD interface. The default connection between the LCD and the microcontroller is:

LCD Microcontroller port pin

RS 2

EN 3

D4 4

D5 5

D6 6

D7 7

The R/W pin of the LCD is not used and should be connected to the ground. This function should be used to change the default connection. It should be called with the parameters in the following order:

port name, RS pin, EN pin, R/W pin, D7 pin, D6 pin, D5 pin, D4 pin

The port name should be specified by passing its address. For example, if the RS pin is connected to RB0, EN pin to RB1, D7 pin to RB2, D6 pin to RB3, D5 pin to RB4, and the D4 pin to RB5, then the function should be called as follows:

Lcd_Config(&PORTB, 0, 1, 2, 3, 4, 5);

Lcd_Init The Lcd_Init function is called to configure the interface between the microcontroller and the LCD when the default connections are made as just illustrated. The port name should be specified by passing its address. For example, assuming that the LCD is connected to PORTB and the preceding default connections are used, the function should be called as:

Lcd_Init(&PORTB);

Lcd_Out The Lcd_Out function displays text at the specified row and column position of the LCD. The function should be called with the parameters in the following order:

row, column, text

For example, to display text “Computer” at row 1 and column 2 of the LCD we should call the function as:

Lcd_Out(1, 2, "Computer");

Lcd_Out_Cp The Lcd_Out_Cp function displays text at the current cursor position. For example, to display text “Computer” at the current cursor position the function should be called as:

Lcd_Out_Cp("Computer");

Lcd_Chr The Lcd_Chr function displays a character at the specified row and column position of the cursor. The function should be called with the parameters in the following order:

row, column, character

For example, to display character “K” at row 2 and column 4 of the LCD we should call the function as:

LCD_Chr(2, 4, 'K');

Lcd_Chr_Cp The Lcd_Chr_Cp function displays a character at the current cursor position. For example, to display character “M” at the current cursor position the function should be called as:

Lcd_Chr_Cp('M');

Lcd_Cmd The Lcd_Cmd function is used to send a command to the LCD. With the commands we can move the cursor to any required row, clear the LCD, blink the cursor, shift display, etc. A list of the most commonly used LCD commands is given in Table 4.4. For example, to clear the LCD we should call the function as:

Lcd_Cmd(Lcd_Clear);

Table 4.4: LCD commands

LCD command Description
LCD_CLEAR Clear display
LCD_RETURN_HOME Return cursor to home position
LCD_FIRST_ROW Move cursor to first row
LCD_SECOND_ROW Move cursor to second row
LCD_THIRD_ROW Move cursor to third row
LCD_FOURTH_ROW Move cursor to fourth row
LCD_BLINK_CURSOR_ON Blink cursor
LCD_TURN_ON Turn display on
LCD_TURN_OFF Turn display off
LCD_MOVE_CURSOR_LEFT Move cursor left
LCD_MOVE_CURSOR_RIGHT Move cursor right
LCD_SHIFT_LEFT Shift display left
LCD_SHIFT_RIGHT Shift display right

An example illustrates initialization and use of the LCD.

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

Интервал:

Закладка:

Сделать

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