lcd.h File Reference
LCD routines.
More...
Go to the source code of this file.
Detailed Description
This module contains routines to communicate with an LCD via the 4 bit parallel mode. All pins are protected from read-before-write problems with picpack's port latch simulation. Reads ready flag to check LCD isn't busy before sending more data.
Define Documentation
#define LCD_CLEAR_DISP 0b00000001 |
#define lcd_clear_display |
( |
|
) |
lcd_write_command(LCD_CLEAR_DISP); |
#define LCD_LINE1 0b10000000 |
#define LCD_LINE2 0b11000000 |
#define LCD_LINE3 0b10010100 |
#define LCD_LINE4 0b11010100 |
#define lcd_return_home |
( |
|
) |
lcd_write_command(LCD_RETURN_HOME); |
#define LCD_RETURN_HOME 0b00000010 |
Move cursor to top left position
#define LCD_SET_DRAM_ADDR 0b10000000 |
Move to DRAM address (cursor position)
Function Documentation
Configures LCD for 4 bit operation and gets ready for displaying text
Call this routine first, to set up tris bits correctly to talk to the LCD
00067 {
00068
00069
00070 make_output(lcd_e_port, lcd_e_pin);
00071 make_output(lcd_rs_port, lcd_rs_pin);
00072 make_output(lcd_rw_port, lcd_rw_pin);
00073 make_output(lcd_db7_port, lcd_db7_pin);
00074 make_output(lcd_db6_port, lcd_db6_pin);
00075 make_output(lcd_db5_port, lcd_db5_pin);
00076 make_output(lcd_db4_port, lcd_db4_pin);
00077
00078 clear_pin(lcd_e_port, lcd_e_pin);
00079 clear_pin(lcd_rs_port, lcd_rs_pin);
00080 clear_pin(lcd_rw_port, lcd_rw_pin);
00081 }
Internal routine to wait while the LCD is busy and unable to accept more data
00154 {
00155
00156
00157 set_bit(tris_array[lcd_db7_port - PORTA], lcd_db7_pin);
00158 set_bit(tris_array[lcd_db6_port - PORTA], lcd_db6_pin);
00159 set_bit(tris_array[lcd_db5_port - PORTA], lcd_db5_pin);
00160 set_bit(tris_array[lcd_db4_port - PORTA], lcd_db4_pin);
00161
00162
00163 clear_pin(lcd_rs_port, lcd_rs_pin);
00164 set_pin(lcd_rw_port, lcd_rw_pin);
00165
00166 char counter = 0;
00167
00168 set_pin(lcd_e_port, lcd_e_pin);
00169
00170
00171 while ((test_pin(lcd_db7_port, lcd_db7_pin) == 1) && counter < 0xF0){
00172 clear_pin(lcd_e_port, lcd_e_pin);
00173 set_pin(lcd_e_port, lcd_e_pin);
00174 delay_us(100);
00175 clear_pin(lcd_e_port, lcd_e_pin);
00176
00177 counter++;
00178 }
00179
00180
00181
00182 if (counter == 0xF0) {
00183 }
00184
00185 clear_bit(tris_array[lcd_db7_port - PORTA], lcd_db7_pin);
00186 clear_bit(tris_array[lcd_db6_port - PORTA], lcd_db6_pin);
00187 clear_bit(tris_array[lcd_db5_port - PORTA], lcd_db5_pin);
00188 clear_bit(tris_array[lcd_db4_port - PORTA], lcd_db4_pin);
00189
00190 return;
00191 }
void lcd_write_command |
( |
uns8 |
data |
) |
|
Use this to send commands to the LCD, eg, changing cursor position
void lcd_write_data |
( |
uns8 |
data |
) |
|
void lcd_write_data_int |
( |
uns16 |
i |
) |
|
Displays an unsigned 16 bit integer on the LCD
00145 {
00146
00147 char buffer[6];
00148
00149 itoa( i, buffer, 10 );
00150 lcd_write_data_str(buffer);
00151 }
void lcd_write_data_str |
( |
char * |
str |
) |
|
Display the string on the LCD from the current cursor position