CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

lcd problem

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
hadeelqasaimeh



Joined: 05 Jan 2006
Posts: 105

View user's profile Send private message

lcd problem
PostPosted: Sat Mar 31, 2007 3:42 pm     Reply with quote

hi all

i used to use an lcd library called "lcd_kbd1" but i find this library don't work with 18f devices...so i try to use lcd.c ,,it work,,but some characters dissapeard ,,,and its not clear how to write on line 1 or on line 2..

pcm i see your driver flex_lcd.c but it dose not run!...and again idont understand how to choose line

here is my test code:
Code:
#include <18F452.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#include <flex_lcd.c>
//#include <lcd.c>
void main()
{  int value;
   lcd_init();
   set_tris_b(0xff);

   while(TRUE)
  {
   value=input_b();
   lcd_putc('\f');
   printf(lcd_putc,"value is:%x",value);
   delay_ms(1000);
   lcd_putc('\n');
   printf(lcd_putc,"HELLO");
   delay_ms(1000);
  }
}



and here is my old driver....i dont know if you can correct it to work with 18f devices:
Code:


#include <jonsinc.h>
#use delay(clock=20000000)

// 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;
    }

//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//----------------------------------------------------------------------------


Code:
/* Include this file by inserting the line "#include <jonsinc.h>" at
the beginning of the C source code.  Or, if you prefer, you can embed it's
contents at the end of each of your 12C509H, 16F84H, 16F874.H, etc. files.*/

#case

#ifndef TRUE
#define TRUE 1
#endif

#ifndef FALSE
#define FALSE 0
#endif

#ifndef YES
#define YES 1
#endif

#ifndef NO
#define NO 0
#endif

#ifndef HIGH
#define HIGH 1
#endif

#ifndef LOW
#define LOW 0
#endif

#ifndef ON
#define ON 1
#endif

#ifndef OFF
#define OFF 0
#endif

#ifndef UP
#define UP 1
#endif

#ifndef DOWN
#define DOWN 0
#endif

#ifndef UCHAR
#define UCHAR char
#endif

#ifndef UINT
#define UINT long
#endif

#ifndef BIT
#define BIT short
#endif

#ifndef SCHAR
#define SCHAR signed int
#endif

#ifndef SINT
#define SINT signed long
#endif

#ifndef FLOAT
#define FLOAT float
#endif



thank you so much
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Mar 31, 2007 4:30 pm     Reply with quote

Code:

#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

These register addresses are different for the 18F452. Look in the
18F452 data sheet to find the correct register addresses.

Look in the section on: SPECIAL FUNCTION REGISTER MAP
There will be a table of register addresses in that section.
hadeelqasaimeh



Joined: 05 Jan 2006
Posts: 105

View user's profile Send private message

PostPosted: Sat Mar 31, 2007 5:04 pm     Reply with quote

i will try...thank you
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group