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

LCD 2X8
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
nailuy



Joined: 21 Sep 2010
Posts: 159

View user's profile Send private message

LCD 2X8
PostPosted: Sun Jan 12, 2014 11:51 am     Reply with quote

Hy guys I have next hardware I don't understand why is not working.
PIC16F76
PCWHD 4.140
LCD RC0802
between lcd and chip I put resistors 330ohm.
contrast adjust is okay
in main file is:
Code:

#include <16F76_test.h>

#define ENABLE_PIN B1
#define RS_PIN B0
#define RW_PIN B7
#define Data4 B2  //B2  //B4
#define Data5 B3  //B3  //B5
#define Data6 B5  //B5  //B6
#define Data7 B4  //B4  //B7

#include <lcd.c>
void main()
{
lcd_init();   
delay_ms(2);
lcd_putc("\fHello World\n");
   while(TRUE)
   {
    output_low (PIN_A5);
    output_low(PIN_C3);
    }
}

and in header is:
Code:

#include <16F76.h>
//#device *=16
//#device adc=8

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES XT
//#FUSES HS                       //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD)
#FUSES PROTECT                  //Code protected from reads

#use delay(clock=4M)


all first 8 words are black entire, like I have problems with contrast but next 8 words are white like I don't write.

Can somebody help me? to show correct word?
RW pin on LCD is to gnd, is okay?
Thank you.
How to put a picture in this post?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Jan 12, 2014 12:22 pm     Reply with quote

Quote:
#define Data4 B2 //B2 //B4
#define Data5 B3 //B3 //B5
#define Data6 B5 //B5 //B6
#define Data7 B4 //B4 //B7

This is defective Wizard code. Don't use the Wizard.


Quote:
RW pin on LCD is to gnd, is okay?

The CCS lcd.c driver does not support grounding the R/W line.

If you want to do that, you must use the flex_lcd.c driver in the Code
Library. The 16x2 driver should work for an 8x2 lcd.


Quote:
between lcd and chip I put resistors 330ohm

You mean on all data and control lines ? Why ? That's not normal procedure.
nailuy



Joined: 21 Sep 2010
Posts: 159

View user's profile Send private message

PostPosted: Sun Jan 12, 2014 5:07 pm     Reply with quote

PCM programmer
Thank you for your reply, but flex_lcd.c isn't on my computer.
I have an error.
File can not be opened.
RW is now connected but result are the same.
Resistors because if I make short on output, I don't destroy.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Jan 12, 2014 5:45 pm     Reply with quote

I said:
Quote:
you must use the flex_lcd.c driver in the Code Library.

Look in the Code Library forum.
nailuy



Joined: 21 Sep 2010
Posts: 159

View user's profile Send private message

PostPosted: Sun Jan 12, 2014 5:54 pm     Reply with quote

yes is true.
I try to find on forum and it is.
thanks
on the simulator all changes, but continue to not working not in the simulator, and not in real life.
with old code LCD on simulator even enable is not working.
Best regards.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Jan 12, 2014 6:22 pm     Reply with quote

Is the LCD mounted on a PIC development board ? Did you buy the
board ? If so, post a link to the website for it.

Or did you build the board by yourself ?


Quote:

#define RW_PIN B7

You have the R/W pin connected to pin B7, but pin B7 is used by the
ICD programmer to program the PIC. (Also pin B6 is used for that).
It's better if you don't use pins B6 and B7 for the LCD. Use some other pins.
nailuy



Joined: 21 Sep 2010
Posts: 159

View user's profile Send private message

PostPosted: Mon Jan 13, 2014 12:16 pm     Reply with quote

I build my own PCB development.
LCD is buy from here.
http://www.tme.eu/en/details/rc0802a-e/lcd-alphanumeric-displays/raystar-optronics/rc0802a-yhy-esx/
#define RW_PIN C7.
Result are the same.
In real life and in simulator.
Best regards.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jan 13, 2014 1:18 pm     Reply with quote

Add a large delay at the start of your program, as shown in bold below:
Quote:

#include <lcd.c>

void main()
{
delay_ms(500); // Add this delay

lcd_init();
delay_ms(2);
lcd_putc("\fHello World\n");
while(TRUE)
{
output_low (PIN_A5);
output_low(PIN_C3);
}
}



If that doesn't work, then post a link to the schematic of your board,
and post a link to a photograph of it. Make sure the photo is in focus.
If you don't have your own website, then upload the schematic and
photo to a free image hosting service such as http://imageshack.us
and post the links here.
nailuy



Joined: 21 Sep 2010
Posts: 159

View user's profile Send private message

PostPosted: Mon Jan 13, 2014 3:56 pm     Reply with quote

I see something else, not functioning.
When function lcd_init() is active,
output low A5, and C3 not functioning.
When lcd_init() is disable A5, and C3 is working.
I will back with complete post. img, etc.
Best regards.
Code:
void main()
{
delay_ms(500);
lcd_init();   
delay_ms(2);
lcd_putc("\fHello World\n");
output_low (PIN_A5);
output_low(PIN_C3);

}
nailuy



Joined: 21 Sep 2010
Posts: 159

View user's profile Send private message

I'm BACK
PostPosted: Fri Feb 07, 2014 12:22 am     Reply with quote

So as I said "I will back"
Now I'm back.
I make my own program for LCD and is working.
This is the code:
Code:

#define LCD_DAT4   PIN_B2
#define LCD_DAT5   PIN_B3
#define LCD_DAT6   PIN_B5
#define LCD_DAT7   PIN_B4

#define LCD_E     PIN_B1
#define LCD_RS    PIN_B0
#define LCD_RW    PIN_B6



#define LCD_ACTIV (output_bit(LCD_E,1), delay_ms(2), output_bit(LCD_E,0), delay_us(1))

static unsigned int8 LCD_DATA_1;

void LCD_BIT(void)
   {
   output_bit(LCD_DAT4, bit_test (LCD_DATA_1,4));
   output_bit(LCD_DAT5, bit_test (LCD_DATA_1,5));
   output_bit(LCD_DAT6, bit_test (LCD_DATA_1,6));
   output_bit(LCD_DAT7, bit_test (LCD_DATA_1,7));
   
   //output_bit(LCD_DAT4, (LCD_DATA_1 & 1));
   //output_bit(LCD_DAT5, (LCD_DATA_1 & 2)); 
   //output_bit(LCD_DAT6, (LCD_DATA_1 & 4));   
   //output_bit(LCD_DAT7, (LCD_DATA_1 & 8));   
   
   LCD_ACTIV;
   }


void LCD_SEND(unsigned int8 LCD_DATA_2)
   {
   LCD_DATA_1=LCD_DATA_2;
   LCD_BIT();
   LCD_DATA_1=LCD_DATA_1<<4;
   LCD_BIT();
   }


void LCD_INIT_1 ()
   {
   delay_ms(700);
   output_bit(LCD_E,0);
   output_bit(LCD_RS,0);
   output_bit(LCD_RW,0);
   output_bit(LCD_DAT7,0);
   output_bit(LCD_DAT6,0);
   output_bit(LCD_DAT5,1);
   output_bit(LCD_DAT4,0);
   LCD_ACTIV;
   LCD_SEND (0X28);
   LCD_SEND (0X0C);     //
   LCD_SEND (0X01);
   //LCD_SEND (0X07);
   //LCD_SEND (24);
   ////////////////////////////
   //LCD_SEND ()
   }


void LCD_RESET (void)
   {
   LCD_SEND (0X01);
   }

//
void LCD_SEND_ADDRESS_BYTE(int8 ADRESA, int8 VAR)
   {
   if(ADRESA==127){     
      goto BUCLA1;
      }

   ADRESA=ADRESA+128;   
   LCD_SEND (ADRESA);   
   output_bit(LCD_RS,1);
   LCD_SEND (VAR);
   delay_us(1);
   output_bit(LCD_RS,0);
   
   if(ADRESA==255){
   BUCLA1:
      LCD_SEND (VAR);
      delay_us(1);
      }
   }


static unsigned int8 LCD_DATA_3;     
static int1 LCD_MEM_RESET;

void LCD_SEND_C(int8 LCD_DATA_4)
{
if (LCD_MEM_RESET){
   LCD_DATA_3=0;
   }
switch(LCD_DATA_4){
   case '\f':               
      delay_ms(2);
      LCD_SEND (1);
      delay_ms(2);
      break;
   //case "\n":               
   //   LCD_SEND_ADDRESS_BYTE(64,16);
   //   break;
     
   default:
      LCD_SEND_ADDRESS_BYTE(LCD_DATA_3, LCD_DATA_4);
      LCD_DATA_3++;
      break;
    }                      //*
 if (LCD_DATA_3==8){       
   LCD_DATA_3=64;         
   }                       //*/
}


and in main program I put code:
Code:

void main()
{
int8 asd=56;
LCD_INIT_1();
LCD_SEND ("value is" %,asd, "amp");


I want to show on display:
first row |value is|
secound row | 56amp |

Thank you.
nailuy



Joined: 21 Sep 2010
Posts: 159

View user's profile Send private message

PostPosted: Fri Feb 07, 2014 3:16 am     Reply with quote

I need help, because variable don't show value, show like error code.
Ttelmah



Joined: 11 Mar 2010
Posts: 19383

View user's profile Send private message

PostPosted: Fri Feb 07, 2014 4:30 am     Reply with quote

lcd_send, just sends one character. It does not format values etc..

You need to use printf, which is the generic 'formatter' function.

printf(lcd_send,"value is " %d\namp %d",asd,amp);

You haven't got an 'amp' variable declared in the main, and what character code you need for the vertical bar, will depend on the character set of your LCD.
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

Re: I'm BACK
PostPosted: Fri Feb 07, 2014 9:44 am     Reply with quote

You start with this:-
nailuy wrote:
I make my own program for LCD and is working.
But don't tell us what is working.

Then you say you want to do this:-
Code:
void main()
{
int8 asd=56;
LCD_INIT_1();
LCD_SEND ("value is" %,asd, "amp");

Quote:
I want to show on display:
first row |value is|
secound row | 56amp |

Followed by:-
Quote:
I need help, because variable don't show value, show like error code.


So, it's obviously not working.
In addition to Ttelmah's comment you will also probably need to tell the display "goto second row of display" or do a newline.

Strikes me you're trying to re-invent the wheel, flex_lcd.c seems to work for everyone else.

Mike
nailuy



Joined: 21 Sep 2010
Posts: 159

View user's profile Send private message

PostPosted: Fri Feb 07, 2014 12:51 pm     Reply with quote

Thank you Ttelmah,
I will test it.

Mike Walne I don't know why is not working "flex_lcd.c" on my project.
When I try to make on display is not working.
and other program to turn on and off one or two LED's not working, like is blocking entirely.

about problem...
I put wrong command on post but in program I used another command.
so command used in my program is:
LCD_SEND_C ("value is");
and I see on my display this text: value is
LCD_SEND_C ("value is" %d,asd );
on display show nothing.
and asd is declared like this:
int8 asd=56;
that why I want to ask you how to solve this problem.
My code is working, reset is not very god, must be make with unplug the power :P
I will back with reply.
nailuy



Joined: 21 Sep 2010
Posts: 159

View user's profile Send private message

PostPosted: Fri Feb 07, 2014 1:38 pm     Reply with quote

Yes Ttelmah.
as you said printf is the generic 'formatter' function.

solution's that I found is:

printf(LCD_SEND_C,"val is %u",asd); //for unsigned
printf(LCD_SEND_C,"val is %d",asd); //for signed

Thank you Ttelmah for your prompt answer.
Embarassed
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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