Jump to content
Sign in to follow this  
wlam23

using lcd code by J.Winpenny

Recommended Posts

Has anyone tried the following function in v1.4 code:

 

WriteLCDString( const char *lcdptr)

 

I an trying in 4 bit mode 1 line display but LCD goes dark shortly after 1st string write.

 

Using following: const char lcd[4] {'T','e', 's', 't'};

To write: WriteLCDString(lcd);

 

Any comments...

Share this post


Link to post
Share on other sites

My guess here is that the array you have created is not Null terminated, the the code tries to access memory beyond the end of your string.

 

So change the string definition to:

const char lcd[4]= {'T','e', 's', 't', 0 }; // note zero on end

 

or

const char* lcd = "test";

which naturally terminates the string with a null.

 

Hope this helps

 

:)

Share this post


Link to post
Share on other sites
Guest Don Erickson

When I first tried J. Winpenny's LCD code on the older version of C2C, it worked fine with only changes due to the way I wired my LCD control lines.  Now, with the new C2C compiler, the code won't work.  The LCD doesn't get initialized.  An assembly language program I have works fine on the same board. I have tried this with and without optimization. Has anyone else seen problems with the new (V 4.5) C2C compiler?

Share this post


Link to post
Share on other sites
Guest Pavel
When I first tried J. Winpenny's LCD code on the older version of C2C, it worked fine with only changes due to the way I wired my LCD control lines.  Now, with the new C2C compiler, the code won't work.  The LCD doesn't get initialized.  An assembly language program I have works fine on the same board. I have tried this with and without optimization. Has anyone else seen problems with the new (V 4.5) C2C compiler?

This sounds rather serious. Can you compare the assembler code generated with old and new c2c compilers and pinpoint the error? If this is a compiler bug I'm more than willing to fix it.

 

Regards,

Pavel

Share this post


Link to post
Share on other sites
Guest Maurizio

Hi all!

I've the same Don Erickson's problem with LCD code.

If I touch one of two 22pF capacitors I can see some random characters on display. I think that the problem is the delay_ms() routine. Is it possible?

I hope that someone can help me!

Cheers.

MaU

Share this post


Link to post
Share on other sites
Guest Don Erickson

Looks like my earlier posting was a false alarm.  After I lengthened the delays in the LCD initialization routine, I am back to working again.  The original delay lengths must have been marginal for my particular LCD.

Sorry for the false alarm, Pavel.

Probably, Maurizio can clear up his problem the same way.

Share this post


Link to post
Share on other sites
Guest Maurizio

Hi!

I've a very strange problem! The code for LCD controls don't work because the program don't start. If I turn off the power supply, the program start correctly after few seconds.

Power supply is simply a 7805 regulator with 100uF capacitor.

/MCLR is pulled up by 10K resistor.

I also try to hold to GND the /MCLR pin during power on and pulled back to 5V after some second, but the program start only if I turn off the power supply!

WHY??

Thanks all.

Cheers.

MaU

Share this post


Link to post
Share on other sites
Guest Tristan

I'd like to add that you have to make sure to add the "#pragma " pre-processor command- if you're using the delay routines at all - they need to know the clock speed, otherwise as I found out they give the wrong delay.  I have found a value of 200us for LCD_Delay is sufficient for my LCD (aa16206).

Share this post


Link to post
Share on other sites

Hi,

I had a bit of trouble using Julian Winpenny's analog.c ADC-to-LCD code but now it works very well.

Important: The 4 data lines and the 3 LCD control lines (wr, enable (=sel) and rs) need to be tied to port D. I couldn't find any schematic, so here is the pinning:

/* LCD pin 6=E=SEL=PIC Port D bit 3 ( Enables LCD ) */

/* LCD pin 5=WR=PIC Port D bit 2 ( Logic 0 = Write ) */

/* LCD pin 4=RS=PIC Port D bit 1 ( Register select ) */

 

/* LCD pin 11=Port D BIT 4 */

/* LCD pin 12=Port D BIT 5 */

/* LCD pin 13=Port D BIT 6 */

/* LCD pin 14=Port D BIT 7 */

 

The voltage to be displayed has to be applied to pin 2=AN0, as far as I remember.

 

Julian sent me his lcd.c and lcd.h files (thanks again!), maybe he could post them on his website, too?

Alf

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...