Higher nibble of PORTB connected to Higher nibble of LCD DATA
*********************************************************************************
code here
*********************************************************************************
/*compiler-hitech c
frequency-4MHz */
#define _XTAL_FREQ 4e6
#define LCD_RS RB2
#define LCD_RW RB1
#define LCD_EN RB3
#define LCD_DATA PORTB
#define LCD_STROBE() ((LCD_EN = 1),(LCD_EN=0))
void
lcd_write(unsigned char c)
{
__delay_us(40);
LCD_DATA &= 0x0F;
LCD_DATA|=( c & 0xF0 );
LCD_STROBE();
LCD_DATA &= 0x0F;
LCD_DATA|= ( ( c<<4 ) & 0xF0 );
//
LCD_STROBE();
}
/*
* Clear and home the LCD
*/
void
lcd_clear(void)
{
LCD_RS = 0;
lcd_write(0x1);
__delay_ms(2);
}
/* write a string of chars to the LCD */
void
lcd_puts(const char * s)
{
LCD_RS = 1; // write characters
while(*s)
lcd_write(*s++);
}
/* write one character to the LCD */
void
lcd_putch(char c)
{
LCD_RS = 1; // write characters
lcd_write( c );
}
/*
* Go to the specified position
*/
void
lcd_goto(unsigned char pos)
{
LCD_RS = 0;
lcd_write(0x80+pos);
}
/* initialise the LCD - put into 4 bit mode */
void
lcd_init()
{
char init_value;
init_value = 0x30;
TRISB=0;
LCD_RS = 0;
LCD_EN = 0;
LCD_RW = 0;
__delay_ms(15); // wait 15mSec after power applied,
LCD_DATA = init_value;
LCD_STROBE();
__delay_ms(5);
LCD_STROBE();
__delay_us(200);
LCD_STROBE();
__delay_us(200);
LCD_DATA = 0x20; // Four bit mode
LCD_STROBE();
lcd_write(0x28); // Set interface length
lcd_write(0xC); // Display On, Cursor On, Cursor Blink
lcd_clear(); // Clear screen
lcd_write(0x6); // Set entry Mode
}
void main(){
lcd_init();
lcd_goto(0);
lcd_puts("1.it works");
for(;;)continue;
}
*********************************************************************************
hex here.
*********************************************************************************
:100000000A128A11692F00308A000408840A8207C4
:10001000003431342E3469347434203477346F34FE
:0800200072346B3473340034B8
:100ED20083010A128A116D2F0A128A119B270A12A4
:100EE2008A1100300A128A117F270A128A110130F0
:100EF2000A128A1183270A128A117E2FF200061122
:100F0200803ED92FF2000615720884000A128A1157
:100F120003200A128A11003803190800720884009B
:100F22000A128A1103200A128A11D9270A128A1177
:100F3200F20A852F83168601831214300611861158
:100F42008610F5007930F400F40BA52FF50BA52FD0
:100F5200AA2F3030FD278600073086158611F5004E
:100F62007D30F400F40BB32FF50BB32FFD27423085
:100F720086158611F400F40BBC2F6400FD27423065
:100F820086158611F400F40BC42F64002030FD276F
:100F92008600283086158611D9270A128A110C304C
:100FA200D9270A128A11EE270A128A110630D92F7E
:100FB200F1000D30F000F00BDC2F0F30FD2786051D
:100FC2007108F03986040F30861586118605710E78
:100FD200F039860486158611080001300611D927DA
:100FE2000A128A110330F3009730F200F20BF72F46
:0E0FF200F30BF72FFC2F0800831203130800E7
:00000001FF
*********************************************************************************
For any pin of pic to higher nibble of LCD DATA
*********************************************************************************
code here
*********************************************************************************
/*compiler-hitech c
frequency-4MHz */
frequency-4MHz */
#include "pic.h"
#define _XTAL_FREQ 4e6
#define LCD_RS RB2
#define LCD_RW RB1
#define LCD_EN RB3
#define LCD_D7 RB4 /*choose any pin here (example RD3,RC8............)
#define LCD_D6 RB5
#define LCD_D5 RB6
#define LCD_D4 RB7 */
#define LCD_STROBE() ((LCD_EN = 1),(LCD_EN=0))
/* write a byte to the LCD in 4 bit mode */
char LCD_DATA;
void data_split(char nibble);
void
lcd_write(unsigned char c)
{
__delay_us(40);
data_split( LCD_DATA &= 0x0F);
data_split(LCD_DATA|=( c & 0xF0 ));
LCD_STROBE();
data_split(LCD_DATA &= 0x0F);
data_split( LCD_DATA|= ( ( c<<4 ) & 0xF0 ));
//
LCD_STROBE();
}
/*
* Clear and home the LCD
*/
void
lcd_clear(void)
{
LCD_RS = 0;
lcd_write(0x1);
__delay_ms(2);
}
/* write a string of chars to the LCD */
void
lcd_puts(const char * s)
{
LCD_RS = 1; // write characters
while(*s)
lcd_write(*s++);
}
/* write one character to the LCD */
void
lcd_putch(char c)
{
LCD_RS = 1; // write characters
lcd_write( c );
}
/*
* Go to the specified position
*/
void
lcd_goto(unsigned char pos)
{
LCD_RS = 0;
lcd_write(0x80+pos);
}
/* initialise the LCD - put into 4 bit mode */
void
lcd_init()
{
char init_value;
init_value = 0x30;
TRISB=0; //initialize the pins used for lcd to output
LCD_RS = 0;
LCD_EN = 0;
LCD_RW = 0;
__delay_ms(15); // wait 15mSec after power applied,
LCD_DATA = init_value;
data_split(LCD_DATA);
LCD_STROBE();
__delay_ms(5);
LCD_STROBE();
__delay_us(200);
LCD_STROBE();
__delay_us(200);
LCD_DATA = 0x20; // Four bit mode
data_split(LCD_DATA);
LCD_STROBE();
lcd_write(0x28); // Set interface length
lcd_write(0xC); // Display On, Cursor On, Cursor Blink
lcd_clear(); // Clear screen
lcd_write(0x6); // Set entry Mode
}
void data_split( char nibble ) {
LCD_D7= (unsigned int)((nibble & 128)>>7);
LCD_D6 =(unsigned int)((nibble & 64)>>6);
LCD_D5 =(unsigned int)((nibble & 32)>>5);
LCD_D4 =(unsigned int)((nibble & 16)>>4);
}
void main(){
lcd_init();
lcd_goto(0);
lcd_puts("2-it works");
for(;;)continue;
}
*********************************************************************************
hex here.
*********************************************************************************
:100000000A128A11182F00308A000408840A820715
:10001000003432342D3469347434203477346F34FE
:0800200072346B3473340034B8
:100E3000F90183010A128A111D2F0A128A114B2708
:100E40000A128A1100300A128A112F270A128A11F7
:100E500001300A128A1133270A128A112E2FF40048
:100E60000611803E8F2FF4000615740884000A12C4
:100E70008A1103200A128A11003803190800740825
:100E800084000A128A1103200A128A118F270A127B
:100E90008A11F40A352F8316860183121430061145
:100EA00086118610F7007930F600F60B552FF70BF8
:100EB000552F5A2F3030F9007908B1270A128A11BC
:100EC000073086158611F7007D30F600F60B662F89
:100ED000F70B662FFD27423086158611F600F60BBC
:100EE0006F2F6400FD27423086158611F600F60B41
:100EF000772F64002030F9007908B1270A128A118F
:100F00002830861586118F270A128A110C308F27F8
:100F10000A128A11EE270A128A1106308F2FF30067
:100F20000D30F200F20B922F0F30F9057908B1273E
:100F30000A128A117308F039F9047908B1270A12E4
:100F40008A110F3086158611F9057908B1270A1222
:100F50008A11730EF039F9047908B12786158611C4
:100F60000800F100F00007300310F00CFF3E031DF5
:100F7000B42F701CBE2FFD270616C02FFD270612AA
:100F80007108F00006300310F00CFF3E031DC32F64
:100F9000701CCD2FFD278616CF2FFD2786127108D6
:100FA000F00005300310F00CFF3E031DD22F701C23
:100FB000DC2FFD270617DE2FFD2706137108F00032
:100FC00004300310F00CFF3E031DE12F701CEB2FCB
:100FD000FD2786170800FD2786130800013006113B
:100FE0008F270A128A110330F5009730F400F40BB2
:100FF000F72FF50BF72FFC2F0800831203130800BF
:00000001FF
*********************************************************************************