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 2nd line
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
sebalitter



Joined: 05 May 2015
Posts: 47

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

lcd 2nd line
PostPosted: Tue Dec 01, 2015 6:58 pm     Reply with quote

HELLO!

The LCD 16x2 display all black in first line and second line dont show anything.
Hardware is ok and i changed the pins in flex_lcd.c to the correct ones, contrast is good as well.
With the rs232 it shows right in the pc but still dont work in LCD.

Detail.
Compiler 5.015
PIC18F46K20


Can you help me please?

This is the code

Code:


#include <18F46k20.h>

#device ICD=TRUE
#device ADC=10
#fuses NOWDT,NOPROTECT,NOLVP,MCLR
 
 #use delay(clock=4000000) // 4Mhz Crystal is Used
 //#use rs232(baud=9600, parity=N, xmit=PIN_C6, rcv=PIN_C7, bits=8)  // RS232 Configuration
 #include <flex_lcd.c>
//#include <lcd.c>
 #include <stdlib.h>


 void main()

 {

     //SET_TRIS_D( 0x00 );   // pone D4 y D7 como salidas
    //SET_TRIS_E( 0x00 );   // pone E como salidas 
    //setup_oscillator(OSC_4MHz);

delay_ms(500);
 lcd_init();
delay_ms(500);
int8 i =0;
//printf("\f");
 while(1)
 {
   
    lcd_gotoxy(1,2);
    printf(lcd_putc, "Hello World %u",i);
    //printf("Hello World %u.\r",i);

    delay_ms(1000);
    i++;
 }
}


Last edited by sebalitter on Wed Dec 02, 2015 7:24 am; edited 1 time in total
Ttelmah



Joined: 11 Mar 2010
Posts: 19552

View user's profile Send private message

PostPosted: Wed Dec 02, 2015 3:40 am     Reply with quote

The obvious thing is your clock settings are screwy.

This implies the LCD timings will be wrong, so making it very likely not to work.

You have a remark saying 16MHz crystal, HS fuse (correct for 16MHz), but the clock statement saying you are running at 4MHz....
sebalitter



Joined: 05 May 2015
Posts: 47

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

PostPosted: Wed Dec 02, 2015 7:36 am     Reply with quote

Ttelmah wrote:
The obvious thing is your clock settings are screwy.

This implies the LCD timings will be wrong, so making it very likely not to work.

You have a remark saying 16MHz crystal, HS fuse (correct for 16MHz), but the clock statement saying you are running at 4MHz....


I'm using 4Mhz clock.
I take out HS fuse, happens the same.
temtronic



Joined: 01 Jul 2010
Posts: 9246
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Dec 02, 2015 7:44 am     Reply with quote

Post your new program but be sure to delete all the commented (//) lines to make it easy to read.
Also post what pins are used for the LCD
Also does a 1Hz LED program run at the correct speed ?


jay
sebalitter



Joined: 05 May 2015
Posts: 47

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

PostPosted: Wed Dec 02, 2015 8:34 am     Reply with quote

Code:


#include <18F46k20.h>

#device ICD=TRUE
#device ADC=10
#fuses XT,NOWDT,NOPROTECT,NOLVP,MCLR
 
 #use delay(clock=4000000) // 4Mhz Crystal is Used 

 #include <flex_lcd.c>
 #include <stdlib.h>


 void main()

 { 
    setup_oscillator(OSC_4MHz);

delay_ms(500);
 lcd_init();
delay_ms(500);
int8 i =0;

 while(1)
 {
   
    printf(lcd_putc, "Hello World %u",i);
   
    //LED blinking in 1 Hz
    output_high(PIN_B3); 
    delay_ms(100);
    output_low(PIN_B3);

    delay_ms(1000);
    i++;
 }
}




In flex_lcd.c the configuration is this (6-pins):

#define LCD_DB4 PIN_D4
#define LCD_DB5 PIN_D5
#define LCD_DB6 PIN_D6
#define LCD_DB7 PIN_D7

//#define LCD_E PIN_E0
#define LCD_RS PIN_E1
#define LCD_RW PIN_E2

//#define USE_LCD_RW 1


PD: the blinking LED is in the correct speed, the clock is 4Mhz.
I tested before with the rs232. It was working.


Last edited by sebalitter on Wed Dec 02, 2015 8:38 am; edited 1 time in total
Ttelmah



Joined: 11 Mar 2010
Posts: 19552

View user's profile Send private message

PostPosted: Wed Dec 02, 2015 8:34 am     Reply with quote

Seriously, start with the 'flash an LED' program and check your chip is running, and running at the correct speed first. Temtronic's comment, except do it before anything else.
Once this is true, triple check the LCD connections. Remember D4 to D7, not D0 to D3 on the LCD.
Part number/model number/datasheet for LCD?. Though 99% are standard, there is always the odd exception.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Dec 02, 2015 3:14 pm     Reply with quote

And did you remember to connect the R/W pin on the LCD to ground ?
sebalitter



Joined: 05 May 2015
Posts: 47

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

PostPosted: Wed Dec 02, 2015 4:08 pm     Reply with quote

PCM programmer wrote:
And did you remember to connect the R/W pin on the LCD to ground ?


Yes, i did.
And the lcd works with other program and other compiler (xc8)
I dont know what else to do.

If i change the library, flex_lcd.c to lcd.c the program do the same ( show all positions of line 1 with black and the second , nothing) but the program get fatal error and finish, then restart again and so on. 1 time per second.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Dec 02, 2015 5:27 pm     Reply with quote

What's disturbing is that you keep changing everything. For example,
in your latest program, you took out this statement:
Code:
lcd_gotoxy(1,2);

Without that statement, the text goes off the end of the first line on the
lcd, and then goes to the 2nd line, and it's soon all messed up.
I know that because I tested your code just now with an 18F4620
(not 46K20) with vs. 5.015.

I wonder if your hardware is currently correct. Is the circuit a
breadboard that you built yourself ? If so, can you post a photo of it ?
sebalitter



Joined: 05 May 2015
Posts: 47

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

PostPosted: Wed Dec 02, 2015 5:57 pm     Reply with quote

I try to make the code as simple as posible to make it work.

The hardware is working, its a Kit that i bought.

Now it is showing something, i change flex_lcd.c but left it again as it was before.






thanks PCM programmer. Mr. Green


Last edited by sebalitter on Thu Dec 03, 2015 7:56 pm; edited 6 times in total
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Dec 02, 2015 6:04 pm     Reply with quote

You can't post an image by that method on the CCS forum.

How to post an image on the CCS forum:
Go to this website: http://postimage.org/
Upload your image. Select family safe. Then click the first button for
"Hotlink to Forum" to get a link to the image.
Then go to the CCS forum and type Ctrl-V to paste the link into a post.

If postimage.org doesn't work in your country, then use Google to find
another free image hosting site for forums.
sebalitter



Joined: 05 May 2015
Posts: 47

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

PostPosted: Fri Dec 04, 2015 3:58 pm     Reply with quote

Any Idea?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Dec 04, 2015 4:42 pm     Reply with quote

Here is the Google translated link to the webpage for your board:
https://translate.google.com/translate?hl=en&sl=es&u=http://mcelectronics.com.ar/site/producto/student

I can't find a link to the schematic for that board.

Do you have a schematic ? If it's a PDF file, can you upload it so we
look at it. Or if it's on a printed sheet of paper, can you scan it and
convert it to an image or a PDF and upload it, and post a link to it ?

------------------
The title of your post is "lcd 2nd line", but your photos show garbage text
on line 1, and line 2 is blank.

Also, in a previous post, we said:
Quote:
And did you remember to connect the R/W pin on the LCD to ground ?


Yes, i did.
And the lcd works with other program and other compiler (xc8)
I dont know what else to do.

But that's a manufactured board. Here is a direct link to a photo of it:
http://mcelectronics.com.ar/site/wp-content/uploads/2014/05/MG_8468.jpg
You didn't have the option to connect R/W to ground or to the PIC. It's
already done (one way or the other) by the manufacturer. So how can
you claim that "Yes, i did" ?

Please post a link to the board's schematic.
sebalitter



Joined: 05 May 2015
Posts: 47

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

PostPosted: Sat Dec 05, 2015 5:31 am     Reply with quote

I understand. I didn't do that, i saw it in the schematic.

This is it

jeremiah



Joined: 20 Jul 2010
Posts: 1358

View user's profile Send private message

PostPosted: Sat Dec 05, 2015 6:48 am     Reply with quote

In the #defines for the flex_lcd pinout you showed us, you don't have E defined and instead have RW defined with the pin that the schematic shows as going to E.

Here is what you provided:
Code:

In flex_lcd.c the configuration is this (6-pins):

#define LCD_DB4 PIN_D4
#define LCD_DB5 PIN_D5
#define LCD_DB6 PIN_D6
#define LCD_DB7 PIN_D7

//#define LCD_E PIN_E0
#define LCD_RS PIN_E1
#define LCD_RW PIN_E2

//#define USE_LCD_RW 1



Notice LCD_E is commented out and LCD_RW is set to PIN_E2, which is what the schematic says should be tied to LCD_E.
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