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 support@ccsinfo.com

16x1 (GDM1601) Text Lcd Driver for PIC

 
Post new topic   Reply to topic    CCS Forum Index -> Code Library
View previous topic :: View next topic  
Author Message
tesla80



Joined: 23 May 2007
Posts: 81

View user's profile Send private message

16x1 (GDM1601) Text Lcd Driver for PIC
PostPosted: Wed May 23, 2007 3:35 pm     Reply with quote

Hi All,

16x1 (GDM1601) Text Lcd Driver for PIC



16x1_lcd_gdm1601.c
Code:
/*
      GDM1601(16 Character, 1 Row Text LCD) Driver for PIC
            Eray Ozturk 'SpeedyX' - 14.09.2006 00:33
            Mail: erayozturk1(at)gmail.com

      lcd_init                    : init (first and once)
      lcd_command(x)              : send a command
      lcd_data(x)                 : send a character
      printf(lcd_data,"SpeedyX"); : send a word

      lcd_goto1                   : cursor goto home
      lcd_ramch                   : lcd line 2 (after 8th char)
      lcd_clrscr                  : clear screen

         PIC             LCD
         lcd_port.0      D4
         lcd_port.1      D5
         lcd_port.2      D6
         lcd_port.3      D7
         lcd_port.4      RS
         lcd_port.5      E      lcd RW pin -> ground
         
*/

#define lcd_port     portb

#define t 2 // enable wait time (us)

#define lcd_putc(c)  lcd_data(c)
#define lcd_goto1    lcd_command(0b10000000)      // lcd goto home
#define lcd_ramch    lcd_command(0b11000000)      // lcd line 2
#define lcd_clrscr   lcd_command(0b00000001);bekle_ms(2)   // lcd clear

void bekle_ms(int x) {
   delay_ms(x);
}

void bekle_us(int y) {
   delay_us(y);
}

void lcd_gonder(char alt4, int1 tip) {
int ust4;
    ust4 = alt4 & 0b11110000;
    ust4 = ust4 >> 4;
    ust4 &= 0x0F;
    alt4 &= 0x0F;
    if(tip==1) ust4 |= 0b00010000;
    lcd_port=ust4;
    bekle_us(t);
    lcd_port |= 0b00100000; // enable=1
    bekle_us(t);
    lcd_port &= 0b11011111; // enable=0
    bekle_us(t);
    if(tip==1) alt4 |= 0b00010000;
    lcd_port=alt4;
    bekle_us(t);
    lcd_port |= 0b00100000; // enable=1
    bekle_us(t);
    lcd_port &= 0b11011111; // enable=0
    bekle_us(t);
}

void lcd_data(char c) { lcd_gonder(c,1); }

void lcd_command(char c) { lcd_gonder(c,0); }

void lcd_scroll_right(){lcd_command(0x1E);}

void lcd_scroll_left(){lcd_command(0x18);}

void lcd_gotox(int x) {
    int adr=0x80;
    if(x>8) adr=0xC0;
   lcd_command(adr|(x-1));
}

void lcd_init() {
   bekle_ms(20);
   lcd_command(0b00000010);
   lcd_command(0b00101000);
   bekle_us(50);
   lcd_command(0b00001100);
   bekle_us(50);
   lcd_clrscr;
   lcd_command(0b00000110);
   bekle_ms(10);
}


main.c
Code:
#include <16F88.h>
#FUSES INTRC_IO,NOWDT,NOMCLR,NOBROWNOUT,NOLVP,NOCPD,NOWRT,NODEBUG,NOPROTECT
#use delay(clock=4000000)

#use  fast_io(A)
#use  fast_io(B)
#byte porta = 5
#byte portb = 6

#include <16x1_lcd_gdm1601.c>

void main() {
   setup_oscillator(OSC_4MHZ);
   set_tris_a(0);
   set_tris_b(0);
   porta=0; portb=0;
   
   lcd_init();

   printf(lcd_data,"SpeedyX GDM1601");
   //printf(lcd_data,"SpeedyX "); lcd_ramch; printf(lcd_data,"GDM1601"); // for lcd-s with 8-8 ram structures
   
   for(;;); // loop forever
}
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> Code Library 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