This is example the part of
main.c
- CODE: SELECT_ALL_CODE
#include <htc.h>
#include "LibraryHD44780.h"
__CONFIG(FOSC_HS & //External Crystal at High Speed
WDTE_OFF & //Disable Watchdog Timer
PWRTE_ON & //Enable Power Up Timer
BOREN_OFF & //Disable Brown Out Reset
MCLRE_ON & //MCLR function is enabled
LVP_OFF); //Disable Low Voltage Programming
#define _XTAL_FREQ 20000000
void pic_init(void);
main()
{
pic_init(); //initialize PIC
lcd_init(); //initialize LCD
for(;;){
lcd_goto(0,0); //select first line
lcd_string(" PIC IS FUN "); //display string
lcd_goto(0,1); //select second line
lcd_string(" "); //display string
}}
and LibraryHD44780.h
- CODE: SELECT_ALL_CODE
#define LCD_RS RD0
#define LCD_RW RD1
#define LCD_EN RD2
#define LCD_LIGHT RD3
#define LCD_DATA PORTD //D7-D4
#define LCD_PULSE() ((LCD_EN=1),(LCD_EN=0))
#define _XTAL_FREQ 20000000
void lcd_init(void);
void lcd_write(unsigned char c);
void lcd_goto(unsigned char pos, unsigned char row);
void lcd_string(const char *s);
void lcd_number(unsigned int no, char base, char digit);
void lcd_scroll(int speed, unsigned char row, unsigned char pos, const char *s);
How I want remove the #define LCD port in the header file and insert into main fail, so that I no need to change on header file in the future?