hadeelqasaimeh
Joined: 05 Jan 2006 Posts: 105
|
help with lcd |
Posted: Thu Mar 02, 2006 3:30 am |
|
|
hi all
im useing the following library with 2*16 lcd module and 4*16 lcd module
but i have no idea how to print some thing in a specific position
Code: |
#include <jonsinc.h>
#use delay(clock=4000000)
// These defines are specifically for a 4x16 line display.
#define LINE_16_1 0x00
#define LINE_16_2 0x40
#define LINE_16_3 0x10
#define LINE_16_4 0x50
// These defines are specifically for a 4x20 line display.
#define LINE_20_1 0x00
#define LINE_20_2 0x40
#define LINE_20_3 0x14
#define LINE_20_4 0x54
// Another define for use in LCD_PutCmd
#define CLEAR_DISP 0x01
// This is a macro used in the subroutines below */
#define PULSE_EN EN = 1; delay_us ( 10 ); EN = 0; delay_ms ( 5 )
#byte port_e = 9 /* set variable that maps to memory */
#byte PORT_A = 5 /* set variable that maps to memory */
#byte port_b= 6
#byte PORT_D= 8
#byte DATA = PORT_A
#bit RS = port_e.0
#bit EN = port_e.1
char kbd_getc(void);
char getkey ( void );
// These are prototype statements.
void LCD_SetPosition ( char cX );
void LCD_PutChar ( char cX );
void LCD_PutCmd ( char cX );
void LCD_Init ( void );
// These are the display subroutines.==============================
void LCD_Init ( void )
{
// Initializing into 4-bit mode is a very exact sequence
// as defined in the datasheets for these displays.
set_tris_a ( 0x00 ); /* outputs */
set_tris_b ( 0xFC ); /* Bits 0 & 1 are outputs */
set_tris_e ( 0xF0 );
DATA = 0x00;
delay_ms ( 200 ); /* wait enough time after Vdd rise */
RS =0;
DATA = 0x03; /* init with specific nibbles to start 4-bit mode */
PULSE_EN;
PULSE_EN;
PULSE_EN;
DATA = 0x02; /* set 4-bit interface */
PULSE_EN; /* send dual nibbles hereafter, MSN first */
LCD_PutCmd ( 0x2C ); /* function set (2 lines, 5x7 characters) */
LCD_PutCmd ( 0x0E ); /* display ON, cursor on, no blink */
LCD_PutCmd ( 0x01 ); /* clear display */
LCD_PutCmd ( 0x06 ); /* entry mode set, increment */
}
void LCD_SetPosition ( cX )
{
/*
This subroutine works specifically for 4-bit Port A.
Value received cX will place cursor at a particular line and offset.
16-char display 20-char display
=============== ===============
Line 1 is hex: 00 - 0F 00 - 13
Line 2 is hex: 40 - 4F 40 - 53
Line 3 is hex: 10 - 1F 14 - 27
Line 4 is hex: 50 - 5F 54 - 67
*/
DATA = swap ( cX ) | 0x08;
PULSE_EN;
DATA = swap ( cX );
PULSE_EN;
}
void LCD_PutChar ( cX )
{
/* this subroutine works specifically for 4-bit Port A */
RS = 1;
DATA = swap ( cX ); /* send high nibble */
PULSE_EN;
DATA = swap ( cX ); /* send low nibble */
PULSE_EN;
RS = 0;
}
void LCD_PutCmd ( cX )
{
/* this subroutine works specifically for 4-bit Port A */
DATA = swap ( cX ); /* send high nibble */
PULSE_EN;
DATA = swap ( cX ); /* send low nibble */
PULSE_EN;
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//----------------------------------------------------------------------------
|
for example if i want to print hello i do the following: Code: |
LCD_PutCmd ( CLEAR_DISP );
LCD_SetPosition ( LINE_16_1);
printf(LCD_PutChar,"hello")
|
but how to print h in some spcific cell
thanx alot |
|