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

18f26k20 lcd (SOLVED)

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
asadi.siyavash@gmail.com



Joined: 22 Aug 2013
Posts: 22

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

18f26k20 lcd (SOLVED)
PostPosted: Tue Aug 27, 2013 3:44 am     Reply with quote

Hi,
I use pic 18f26k20 I write my code and simulate it without any problem in ISIS but now in real test the LCD 2*16 doesn't work not only it doesn't work but also my simple program that is LED blinker
Code:

#include <18F26K20.h>
#device adc=10

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES WDT128                   //Watch Dog Timer uses 1:128 Postscale
//#FUSES LP                       //Low power osc < 200 khz
#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOXINST                  //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#FUSES HS
#use delay(clock=20000000)


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

#include <lcd.c>
#use FIXED_IO( B_outputs=PIN_B3 )
#define LED PIN_C0
#define DELAY 100



void main()
{
   port_B_pullups(0x08);
   setup_timer_3(T3_DISABLED | T3_DIV_BY_1);

   setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard

   //Example blinking LED program
//   lcd_init();
//   lcd_putc("hi");
  while(true)
   {
      output_low(LED);
      delay_ms(DELAY);
      output_high(LED);
      delay_ms(DELAY);
   }



}

when I comment line : lcd_init();
at least the blinker work but when I initialize lcd blinker doesn't work,
and in both of them LCD doesn't work.
my compiler version is PCWHD 4.140.
sincerely yours.


Last edited by asadi.siyavash@gmail.com on Wed Aug 28, 2013 2:34 am; edited 2 times in total
Mike Walne



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

View user's profile Send private message

PostPosted: Tue Aug 27, 2013 4:13 am     Reply with quote

Proof once again, PIC and ISIS is a complete waste of time.

Check your connections to the LCD.
Then double check very carefully. Not all LCDs have the same pinouts, even with identical connectors.

Also insert a 1 second delay before initilising the LCD. They usually need time to settle after applying power.

Mike
temtronic



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

View user's profile Send private message

PostPosted: Tue Aug 27, 2013 5:27 am     Reply with quote

Mike is so right!!!
Have you even got POWER on the LCD correctly? ISIS ( Proteus ) simulates WITHOUT power pins connected to the 'PIC' or other 'parts' !!

My 'guess' is that you've got the LCD driver set for 'feedback' mode and the PIC program is 'stalled' waiting for the LCD to say 'I'm alive'.
If so it could be a wiring error or pin assignment or bad LCD module or ????
Without seeing a schematic of the REAL hardware it's difficult to say what is the cause.


hth
jay
asadi.siyavash@gmail.com



Joined: 22 Aug 2013
Posts: 22

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

PostPosted: Tue Aug 27, 2013 5:34 am     Reply with quote

Hi Mike thanks for your reply but connection is not important now because before inserting lcd initialize the blinker work correct but when I remove it it doesn't work.
My other problem was in simulate I change default connection of lcd but it work with default connection.

my connection is:
Code:

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

#include <lcd.c>


default connection is:
Code:

#define ENABLE_PIN B0
#define RS_PIN B1
#define RW_PIN B2
#define Data4 B4
#define Data5 B5
#define Data6 B6
#define Data7 B7
#define use_portb_lcd TRUE
#include <lcd.c>

AND MY TOTAL PROGRAM WITHOUT INITIALIZE IS:
Code:

#include <18F26K20.h>
#device adc=10

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES WDT128                   //Watch Dog Timer uses 1:128 Postscale
//#FUSES LP                       //Low power osc < 200 khz
#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOXINST                  //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#FUSES HS
#use delay(clock=20000000)


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

#include <lcd.c>
#use FIXED_IO( B_outputs=PIN_B3 )
#define LED PIN_C0
#define DELAY 100



void main()
{
   port_B_pullups(0x08);
   setup_timer_3(T3_DISABLED | T3_DIV_BY_1);

   setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard

   //Example blinking LED program
//   lcd_init();
//   lcd_putc("hi");
  while(true)
   {
      output_low(LED);
      delay_ms(DELAY);
      output_high(LED);
      delay_ms(DELAY);
   }



}



I am new in CCS , it work very hard i am confused.
best regards.


Last edited by asadi.siyavash@gmail.com on Tue Aug 27, 2013 1:14 pm; edited 2 times in total
asadi.siyavash@gmail.com



Joined: 22 Aug 2013
Posts: 22

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

PostPosted: Tue Aug 27, 2013 6:06 am     Reply with quote

Quote:

Mike is so right!!!
Have you even got POWER on the LCD correctly? ISIS ( Proteus ) simulates WITHOUT power pins connected to the 'PIC' or other 'parts' !!

My 'guess' is that you've got the LCD driver set for 'feedback' mode and the PIC program is 'stalled' waiting for the LCD to say 'I'm alive'.
If so it could be a wiring error or pin assignment or bad LCD module or ????
Without seeing a schematic of the REAL hardware it's difficult to say what is the cause.

I cant understand your reason I don't connect the LCD 2*16 to my pic & even I don't write anything on it, just when I use lcd_init(); simple blinker doesn't work. so hardware is not important.
thank you.
asadi.siyavash@gmail.com



Joined: 22 Aug 2013
Posts: 22

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

PostPosted: Tue Aug 27, 2013 6:07 am     Reply with quote

this is my shematic:
Ttelmah



Joined: 11 Mar 2010
Posts: 19516

View user's profile Send private message

PostPosted: Tue Aug 27, 2013 7:49 am     Reply with quote

Data sheet for the specific LCD?....

Isis has no idea about the contrast voltage requirements of different LCD's. A lot of modern ones will display with Ve=0v, which looks like might may be what you have setup. However some displays _require_ Ve to be negative to display, and others require a particular positive voltage. It depends on the actual LCD 'element' used, hence the data sheet _must_ always be the starting point.

You also show a 'backlight' connection. Again the data sheet will tell you what current is needed on this, but typically something like 40 or 50mA at 5v. 1.8K is not going to get you very far if this is the case....

Then on the PIC, you show 'XTAL1', and 'XTAL2', but not what is connected to them. Isis will accept if you say "I'm running at xMHz", even if no circuitry is on these pins. The real PIC won't.

Then, no decoupling. The PIC _requires_ decoupling close to the chip. So does the display.

Best Wishes
asadi.siyavash@gmail.com



Joined: 22 Aug 2013
Posts: 22

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

PostPosted: Tue Aug 27, 2013 8:20 am     Reply with quote

Ttelmah wrote:
Data sheet for the specific LCD?....

Isis has no idea about the contrast voltage requirements of different LCD's. A lot of modern ones will display with Ve=0v, which looks like might may be what you have setup. However some displays _require_ Ve to be negative to display, and others require a particular positive voltage. It depends on the actual LCD 'element' used, hence the data sheet _must_ always be the starting point.

You also show a 'backlight' connection. Again the data sheet will tell you what current is needed on this, but typically something like 40 or 50mA at 5v. 1.8K is not going to get you very far if this is the case....

Then on the PIC, you show 'XTAL1', and 'XTAL2', but not what is connected to them. Isis will accept if you say "I'm running at xMHz", even if no circuitry is on these pins. The real PIC won't.

Then, no decoupling. The PIC _requires_ decoupling close to the chip. So does the display.

Best Wishes

thanks for your reply but this is not whole of my schematic, my schematic is very big so I can't insert it, I use 20Mhz external crystal by 15pf cap in each pin to ground, I seperate my work in some step that step one is simple blinker, step two was adding LCD function without showing anything, step three: showing "hello" word in LCD. &...
but in step two that I just called LCD function and again I tested it but the blinker doesn't work.
No, many project I do with this LCD with AVR atmega & FPGA with the same connection without any problem, before using PIC with CCS, I worked with ATMEGA never I seen problems like these problem, I change my micro controller because I know PIC have very feature, but now I see I can't do any project completely with PIC, I don't know how I can solve my problems.
thank you for spending time for solving my problem,
you are very nice,
best regards.
alan



Joined: 12 Nov 2012
Posts: 357
Location: South Africa

View user's profile Send private message

PostPosted: Tue Aug 27, 2013 8:48 am     Reply with quote

Quote:

My 'guess' is that you've got the LCD driver set for 'feedback' mode and the PIC program is 'stalled' waiting for the LCD to say 'I'm alive'.
If so it could be a wiring error or pin assignment or bad LCD module or ????

The lcd.c driver file requires a LCD to be connected and working, otherwise will wait for LCD to say 'I'm alive' as temtronic has already pointed out to you.

Alan
Mike Walne



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

View user's profile Send private message

PostPosted: Tue Aug 27, 2013 9:32 am     Reply with quote

I don't care how big your circuit is.

Let's summarise.

1) With lcd_init(); commented out, blinker works.
2) PIC is running (I presume at the correct speed).
3) With lcd_init(); in place blinker does not work.

Conclusion lcd_init(); is getting stuck somewhere.

Try connecting a 'scope to LCD data and control pins to see what happens.
Then work out where it's sticking.

(OR Add diagnostic LED flashers to lcd_init(); code to tell you same thing.)

Whether connections are correct or not LCD won't come to life properly if it's not initialsed correctly.

Mike
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Aug 27, 2013 11:22 am     Reply with quote

Quote:
My other problem was in simulate I change default connection of lcd but it work with default connection.

default connection is:
Code:

#define TC_CLK PIN_B2
#define TC_DATA PIN_B0
#define TC_CS PIN_B7
#define TC_CS2 PIN_B5
#define TC_CS3 PIN_B6

#define use_portb_lcd TRUE
#include <lcd.c>

Quote:
TC_CLK TC_DATA TC_CS TC_CS2 TC_CS3

If I Google for these constants, I get only your post. Clearly, this stuff is
an invention. It's not a "default" for any CCS driver on the net. I also did
a text search on the whole CCS directory and it's not in any file.


Quote:

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

#include <lcd.c>

What is this stuff ? It's not listed in lcd.c as the correct way to do the
define statements for that driver. By doing some detective work with
Google, I found a post on EDA board that says this bad code is generated
by the CCS wizard. Don't use the Wizard.

The correct way to do it, would be to use the LCD pin names given in
the lcd.c driver file, and to use the real CCS pin numbers (not "B1", etc.).
If you do it as shown below, then at least it will compile the lcd.c driver
in the way that you expect it to be compiled. Then it has a chance to work.
Example:
Code:

#define LCD_ENABLE_PIN  PIN_B2
#define LCD_RS_PIN      PIN_B0
#define LCD_RW_PIN      PIN_B1

#define LCD_DATA4  PIN_B4
#define LCD_DATA5  PIN_B5
#define LCD_DATA6  PIN_B6
#define LCD_DATA7  PIN_B7

#include <lcd.c>


Also, your schematic doesn't use the correct names for the LCD control
signals. Instead of RS, RW, and EN, it uses some invented names of
LCD_Data0, LCD_Data1, and LCD_Data2. Don't do this. Use the
real names that are in all LCD documenation.
asadi.siyavash@gmail.com



Joined: 22 Aug 2013
Posts: 22

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

PostPosted: Tue Aug 27, 2013 1:11 pm     Reply with quote

alan wrote:
Quote:

My 'guess' is that you've got the LCD driver set for 'feedback' mode and the PIC program is 'stalled' waiting for the LCD to say 'I'm alive'.
If so it could be a wiring error or pin assignment or bad LCD module or ????

The lcd.c driver file requires a LCD to be connected and working, otherwise will wait for LCD to say 'I'm alive' as temtronic has already pointed out to you.

Alan

yes you are exactly correct when I connect LCD the blinker start to work, but it isn't very good in avr by Codevision compiler never I seen this issue, but my other problem doesn't solve maybe by guide of PCM programmer it will solve, when I test it, I tell result,

thank you,
you and other who spend their time for solving my problem are really humanitarian people.
best regards.
asadi.siyavash@gmail.com



Joined: 22 Aug 2013
Posts: 22

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

PostPosted: Tue Aug 27, 2013 1:30 pm     Reply with quote

Quote:
If I Google for these constants, I get only your post. Clearly, this stuff is an invention.

Very Happy yes I sent wrong code , I changed it. excuse me for my invention Very Happy
Quote:
this bad code is generated by the CCS wizard. Don't use the Wizard.
yes I use wizard because it is very simple and easy to use, & I add fuses and other setting to main code. thank you for your good suggestion I'll test it and tell you the result.
your idea was great and like a course for me really thanks for sharing your knowledge,
best regards.
asadi.siyavash@gmail.com



Joined: 22 Aug 2013
Posts: 22

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

PostPosted: Wed Aug 28, 2013 2:34 am     Reply with quote

Hi, thank you for replying,
My problem solved, I decide to don't use CodeWizard for LCD,

best regards,
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