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

PIC16F628A and LCD driver

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



Joined: 13 Jul 2005
Posts: 7

View user's profile Send private message Send e-mail

PIC16F628A and LCD driver
PostPosted: Wed Jul 13, 2005 10:56 am     Reply with quote

I am writing my own LCD driver, because driver included in CCS inst alowing you to define each pin.

main.c
Code:
#include <16F628A.h>
#fuses NOWDT, PUT, NOPROTECT, BROWNOUT, NOMCLR, NOLVP, INTRC_IO, NOCPD
#use delay(clock=4000000)

#include <driver.lcd.c>


void main ()
{
   delay_ms(200);
   lcd_init();

   while (true)
   {
      
   }
}



driver.lcd.c
Code:
#define   LCD_rs   PIN_B1
#define   LCD_en   PIN_B0

#define   LCD_d4   PIN_B4
#define   LCD_d5   PIN_B5
#define   LCD_d6   PIN_B6
#define   LCD_d7   PIN_B7

BYTE const LCD_INIT_STRING[5] =
{
   0x28,   // function set         [2 lines, 5x10 dots]
   0x10,   // cursor or display shift   [cursor move=off, shift to the left]
   0x0C,   // display on/off control   [display=on, cursor displayed=off, cursor blinks=off]
   0x06,   // entry mode set         [decrement, don't shift display]
   0x01      // clear display
};

void lcd_clock ()
{
   delay_us(2);
   output_high(LCD_en);
   delay_us(2);
   output_low(LCD_en);
}

void lcd_send_nibble (byte n)
{
   output_bit(LCD_d4, shift_right(&n,1,0) );
   output_bit(LCD_d5, shift_right(&n,1,0) );
   output_bit(LCD_d6, shift_right(&n,1,0) );
   output_bit(LCD_d7, shift_right(&n,1,0) );

   lcd_clock();
}

void lcd_send_cmd (byte n)
{
   output_low(LCD_rs);
   lcd_send_nibble(n >> 4);
   delay_us(1);
   lcd_send_nibble(n & 0x0F);
}

void lcd_init()
{
   int count;

   output_low(LCD_rs);
   output_low(LCD_en);
   delay_ms(15);

   for (count=0; count < 3; ++count)
   {
      lcd_send_nibble(0x03);
      delay_ms(5);
   }

   lcd_send_nibble(0x02);

   for (count=0; count < 5; ++count)
   {
      lcd_send_cmd(LCD_INIT_STRING[count]);
   }
}



Lcd doesnt want to intialize.
R/W pin is connected to the ground, because i wont read nothing from lcd, just write.

p.s. sory for my bad English.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jul 13, 2005 11:39 am     Reply with quote

If you want to do it that way, then study Jon Ficks driver for ideas.
He's using a similar method:
http://www.vermontficks.org/lcdc2.htm
glavic



Joined: 13 Jul 2005
Posts: 7

View user's profile Send private message Send e-mail

PostPosted: Wed Jul 13, 2005 4:43 pm     Reply with quote

PCM programmer wrote:
If you want to do it that way, then study Jon Ficks driver for ideas.
He's using a similar method:
http://www.vermontficks.org/lcdc2.htm
Tnx, it works.
Kit
Guest







PostPosted: Thu Jul 14, 2005 3:34 am     Reply with quote

When I tried to compile the source code vermontficks.com
the compiler said that "cSkip" is undefined.

I have read through again the source code, and i have no idea what is that.
btw, i commented the if (!cSkip) and it works.

Can anyone answer my questions?
glavic



Joined: 13 Jul 2005
Posts: 7

View user's profile Send private message Send e-mail

PostPosted: Thu Jul 14, 2005 4:08 am     Reply with quote

Kit wrote:
When I tried to compile the source code vermontficks.com
the compiler said that "cSkip" is undefined.

I have read through again the source code, and i have no idea what is that.
btw, i commented the if (!cSkip) and it works.

Can anyone answer my questions?
Jep, cSkip is undefined.

Just change function >
Code:
#separate void LCD_PutChar ( unsigned int cX )
    {
    /* this subroutine works specifically for 4-bit Port A */
    if ( !cSkip )
        {
        output_high ( LCD_RS );
        LCD_SetData ( swap ( cX ) );     /* send high nibble */
        LCD_PulseEnable();
        LCD_SetData ( swap ( cX ) );     /* send low nibble */
        LCD_PulseEnable();
        output_low ( LCD_RS );
        }
    }


to

Code:
#separate void LCD_PutChar ( unsigned int cX )
    {
    /* this subroutine works specifically for 4-bit Port A */
        output_high ( LCD_RS );
        LCD_PutCmd( cX );
        output_low ( LCD_RS );
    }
guest
Guest







PostPosted: Sun Jul 24, 2005 1:36 pm     Reply with quote

Same here,

No way that i am able to get the picc lcd driver running.
It works perfectly with the pic16f877, but not with the 84a or the 628a.

Why i dunno.

http://www.vermontficks.org/lcdc2.htm

This one works without any problem.

regards,

Evert
guest
Guest







PostPosted: Sun Jul 24, 2005 2:04 pm     Reply with quote

Same here,

No way that i am able to get the picc lcd driver running.
It works perfectly with the pic16f877, but not with the 84a or the 628a.

Why i dunno.

http://www.vermontficks.org/lcdc2.htm

This one works without any problem.

regards,

Evert
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