/* Microchip Technology Inc. and its subsidiaries. You may use this software * and any derivatives exclusively with Microchip products. * * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. * * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE * FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS * IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF * ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. * * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE * TERMS. */ /* * File: * Author: * Comments: * Revision history: */ // This is a guard condition so that contents of this file are not included // more than once. #ifndef XC_HEADER_TEMPLATE_H #define XC_HEADER_TEMPLATE_H #include // include processor files - each processor file is guarded. // TODO Insert appropriate #include <> // TODO Insert C++ class definitions if appropriate // TODO Insert declarations // Comment a function and leverage automatic documentation with slash star star /**

Function prototype:

Summary:

Description:

Precondition:

Parameters:

Returns:

Example:

Remarks:

*/ // TODO Insert declarations or function prototypes (right here) to leverage // live documentation #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ // TODO If C++ is being used, regular C code needs function names to have C // linkage so the functions can be used by the c code. #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* XC_HEADER_TEMPLATE_H */ //LCD Functions Developed by electroSome //modified by G. Panagopoulos #define RS PORTBbits.RB2 #define EN PORTBbits.RB3 #define D4 PORTBbits.RB4 #define D5 PORTBbits.RB5 #define D6 PORTBbits.RB6 #define D7 PORTBbits.RB7 void lcd_port(char a) { D4 = (a & 1?1:0); D5 = (a & 2?1:0); D6 = (a & 4?1:0); D7 = (a & 8?1:0); } void lcd_cmd(char a) { RS = 0; // => RS = 0 lcd_port(a); EN = 1; // => E = 1 __delay_ms(4); EN = 0; // => E = 0 } void lcd_clear() { lcd_cmd(0); lcd_cmd(1); } void lcd_set_cursor(char a, char b) { char temp,z,y; if(a == 1) { temp = 0x80 + b - 1; z = temp>>4; y = temp & 0x0F; lcd_cmd(z); lcd_cmd(y); } else if(a == 2) { temp = 0xC0 + b - 1; z = temp>>4; y = temp & 0x0F; lcd_cmd(z); lcd_cmd(y); } } void lcd_init() { lcd_port(0x00); __delay_ms(20); lcd_cmd(0x03); __delay_ms(5); lcd_cmd(0x03); __delay_ms(11); lcd_cmd(0x03); lcd_cmd(0x02); lcd_cmd(0x02); lcd_cmd(0x08); lcd_cmd(0x00); lcd_cmd(0x0C); lcd_cmd(0x00); lcd_cmd(0x06); } void lcd_write_char(char a) { char temp,y; temp = a&0x0F; y = a&0xF0; RS = 1; // => RS = 1 lcd_port(y>>4); //Data transfer EN = 1; __delay_us(40); EN = 0; lcd_port(temp); EN = 1; __delay_us(40); EN = 0; } void lcd_write_string_s(char *a,int length) { int i; for(i=0;i