Beruflich Dokumente
Kultur Dokumente
/////////////////////////////////////////////////////////////////////////// //// //// //// RR_LCD.C Driver for common LCD modules //// //// //// ////
//// lcd_init() Must be called before any other function. //// ////
//// lcd_putc(c) Will display c on the next position of the LCD. //// //// //// //// //// The following have special meaning: \f Clear display \n Go to start of second line \b Move back one position //// //// //// //// ////
////
//// lcd_gotoxy(x,y) Set write position on LCD (upper left is 1,1) //// ////
////
////
///////////////////////////////////////////////////////////////////////////
////
////
//// This source code may only be used by licensed users of the CCS C //// //// compiler. This source code may only be distributed to other ////
//// licensed users of the CCS C compiler. No other use, reproduction //// //// or distribution is permitted without written permission. //// ////
//// Derivative programs created using this software in object code //// form are not restricted in any way. /////////////////////////////////////////////////////////////////////////// ////
// As defined in the following structure the pin connection is as follows: // // // // // // // // // // // E0 rs E1 enable E2 rw D0 D0 D1 D1 D2 D2 D3 D3 D4 D4 D5 D5 D6 D6 D7 D7 // Para que pueda trabajar con nuestro modulo
//
#include <16f877A.h>
} lcd_d;
//#byte lcd_d = 0xF81 //#byte lcd_c = 0xF83 #byte lcd_d = 0x08 #byte lcd_c = 0x09 #byte adcon1 = 0x9F
// direccin de la estructura "lcd_d" // direccin de la estructura "lcd_c" // direccin del puerto de datos D // direccin del puerto de control E // direccin del registro ADCON1
#define set_tris_puerto(x) set_tris_d(x) // Para definir sentido en puerto de datos #define set_tris_control(x) set_tris_e(x) // Para definir sentido en puerto de control #define lcd_line_two 0x40 // Define direccin de inicio de segunda lnea
struct lcd_pin_datos const LCD_WRITE_D = {0x00}; // Para escribir en puerto de datos struct lcd_pin_datos const LCD_READ_D = {0xFF}; // Para leer en puerto de datos struct lcd_pin_control const LCD_WRITE_C = {0x00}; // Para escribir en puerto de control
set_tris_control(LCD_WRITE_C); // define puerto E como salida lcd_c.rw = 1; delay_cycles(1); lcd_c.enable = 1; delay_cycles(1); datos_leidos = lcd_d.data; lcd_c.enable = 0; delay_cycles(1); // lee datos del mdulo LCD // Deshabilita mdulo LCD // Habilita mdulo LCD // r=1. Habilita lectura de datos del LCD
set_tris_puerto(LCD_WRITE_D);
return (datos_leidos); }
lcd_c.rs = 0;
while ( bit_test(lcd_read_byte(),7) ) ; // Espera hasta que LCD est libre lcd_c.rs = ins_dat; delay_cycles(1); lcd_c.rw = 0; delay_cycles(1); lcd_c.enable = 0; lcd_enviar(n); // Deshabilita mdulo LCD // Funcin que enva el byte n // habilita escritura de datos // rs=0, instruccin rs=1, dato
set_tris_control(LCD_WRITE_C); // define puerto E como salida set_tris_puerto(LCD_WRITE_D); // define puerto D como salida
lcd_send_byte(0, 0x0F);
void lcd_putc( char c) { switch (c) { case '\f' : lcd_send_byte(0,1); delay_ms(2); break; case '\n' : lcd_gotoxy(1,2); break;
} }
lcd_gotoxy(x,y); while ( bit_test(lcd_read_byte(),7) ); // wait until busy flag is low lcd_c.rs=1; value = lcd_read_byte(); lcd_c.rs=0; return(value); } // Habilita lectura del LCD // lee dato del LCD
lcd_putc("\f"); lcd_gotoxy(1,1);
lcd_putc("Microcontroladores"); delay_ms(1000); }