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 using flex.c only writes first 8 characters then freezes

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



Joined: 26 Apr 2010
Posts: 17
Location: Palatine, IL

View user's profile Send private message Visit poster's website

LCD using flex.c only writes first 8 characters then freezes
PostPosted: Thu Sep 16, 2010 5:04 pm     Reply with quote

Hi all,

I'm using a PIC18F4620 to drive a NHD-0420DZ-FL-Y8W in 4-bit mode. I am using the flex.c driver for the 4x20 display.

If I write all o's (code: 01101111) to the screen, I will only see the first 8 or 9 (the exact count seems to be random). If I ground Data7 of the LCD, I will see all 80 o's. If I loop the printing of the o's, I will see 80 g's (01100111) when the data7 line is grounded, but will see 8 or 9 o's when it is not.

I've combed this forum (and others), but after trying various suggestions, I haven't found a functional solution. A solution of using a transistor to GND DATA7 will allow the entire display to be written to, but will limit the usable command/character set to those with (bit7,bit3) = 0.

The display obviously sees DATA7 (as the o is displayed correctly in the first positions), but something is freezing the display until DATA7 is pulled LOW.

This behavior is seen irregardless of which pins are allocated for the LCD interface. Also, #USE STANDARD_IO(ALL) is set.

I'd love to hear any suggestions.

Lucas
temtronic



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

View user's profile Send private message

PostPosted: Thu Sep 16, 2010 5:16 pm     Reply with quote

Not familiar with the display, but can/have you tried using it in 8 bit mode?

Perhaps using another port from the PIC(setup/perhiperal issues ?)

If it works OK in 8 bit mode, then maybe there is a driver issue, some quirk with that display?
sturnfie



Joined: 26 Apr 2010
Posts: 17
Location: Palatine, IL

View user's profile Send private message Visit poster's website

PostPosted: Thu Sep 16, 2010 6:30 pm     Reply with quote

temtronic wrote:
Not familiar with the display, but can/have you tried using it in 8 bit mode?

Perhaps using another port from the PIC(setup/perhiperal issues ?)

If it works OK in 8 bit mode, then maybe there is a driver issue, some quirk with that display?


8-bit mode does work. However, my application doesn't have available I/O pins beyond the 7 currently allocated. I really want to get 4-bit mode working. I've tried various other ports/pins on the PIC, with the same results each time. I guess I can use some kind of shift register to keep the pin count down...

What I'm hoping for is that someone else has seen a similar issue and can make a recommendation. The confounding part of this problem is that everything seems to work when that DATA7 line is grounded.

Lucas
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Sep 16, 2010 7:11 pm     Reply with quote

Does your schematic look like the 4-bit schematic on page 4 of the
LCD data sheet ?
http://www.newhavendisplay.com/specs/NHD-0420DZ-FL-YBW.pdf

Post a short, complete, compilable test program that shows the problem.
Don't post the Flex lcd driver. Just #include it in your program.

Post the list of #define statements at the top of the Flex driver, that
define the connections between the PIC and the LCD. Also post the
#define statement concerning the R/W line.

Also post your compiler version.
sturnfie



Joined: 26 Apr 2010
Posts: 17
Location: Palatine, IL

View user's profile Send private message Visit poster's website

PostPosted: Thu Sep 16, 2010 8:10 pm     Reply with quote

PCM programmer wrote:
Does your schematic look like the 4-bit schematic on page 4 of the
LCD data sheet ?
http://www.newhavendisplay.com/specs/NHD-0420DZ-FL-YBW.pdf

Post a short, complete, compilable test program that shows the problem.
Don't post the Flex lcd driver. Just #include it in your program.

Post the list of #define statements at the top of the Flex driver, that
define the connections between the PIC and the LCD. Also post the
#define statement concerning the R/W line.

Also post your compiler version.


The schematic is identical to the wiring of my circuit. Compiler PCH v4.106

The following code will display the error. When voltage is applied, the display will show 8 or 9 "o"s. If a GND connection is made to DATA7 after initialization, the full 80 "o"s will be seen. Modifying the loop to continously print "o"s will show all "g"s when DATA7 is GND, and only 8 or 9 "o"s when DATA7 is in a standard configuration. If a GND connection is made to DATA7 before initialization, the display will show two lines of block characters.

Code:

#include "18F4620.h"
#include "flex.c"

#FUSES NOWDT               
#FUSES HS                       
#FUSES NOPUT                   
#FUSES NOPROTECT             
#FUSES NOBROWNOUT             
#FUSES NOLVP                   

#use delay(clock=20000000)

#define USE_RW_PIN   1 
#define LCD_DB4   PIN_B4
#define LCD_DB5   PIN_B5
#define LCD_DB6   PIN_B6
#define LCD_DB7   PIN_B7
#define LCD_RW    PIN_B2
#define LCD_RS    PIN_B1
#define LCD_E     PIN_B0

void main()
{
   disable_interrupts(GLOBAL);
   lcd_init();
   
   byte i = 0;
 
    lcd_putc("\f");
       
    for(i=0; i<80; i++){
       if(i ==21 || i == 41 || i==61){
          printf(lcd_putc, "\n");
       }
       printf(lcd_putc, "o");
    }
    while (true) {}
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Sep 16, 2010 8:16 pm     Reply with quote

Quote:

#define USE_RW_PIN 1
#define LCD_DB4 PIN_B4
#define LCD_DB5 PIN_B5
#define LCD_DB6 PIN_B6
#define LCD_DB7 PIN_B7
#define LCD_RW PIN_B2
#define LCD_RS PIN_B1
#define LCD_E PIN_B0

Pins B6 and B7 are used by the ICD debugger/programmer. Do you
have a debugger or programmer plugged into the board ? Does your
board have a built-in ICD ?

Try using two other PIC pins for DB6 and DB7, other than B6 and B7.
sturnfie



Joined: 26 Apr 2010
Posts: 17
Location: Palatine, IL

View user's profile Send private message Visit poster's website

PostPosted: Thu Sep 16, 2010 8:24 pm     Reply with quote

PCM programmer wrote:
Quote:

#define USE_RW_PIN 1
#define LCD_DB4 PIN_B4
#define LCD_DB5 PIN_B5
#define LCD_DB6 PIN_B6
#define LCD_DB7 PIN_B7
#define LCD_RW PIN_B2
#define LCD_RS PIN_B1
#define LCD_E PIN_B0

Pins B6 and B7 are used by the ICD debugger/programmer. Do you
have a debugger or programmer plugged into the board ? Does your
board have a built-in ICD ?

Try using two other PIC pins for DB6 and DB7, other than B6 and B7.


I've used A1/A0 and D7/D6 as alternatives to B7/B6. Same result each time. Coincidently, I discovered that grounding DATA7 allows some level of operation when I left my PICKIT2 connected, with the USB disconnected, and noticed the entire display filling with characters (PICKIT2 has pulldowns on PGC/PGD, and shares GND with circuit).

Anyway, the ICSP does not seem to be the cause of these particular troubles.

Lucas
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Sep 16, 2010 8:48 pm     Reply with quote

Try using the CCS lcd driver for 4x20 lcds:
Quote:
c:\program files\picc\drivers\lcd420.c
sturnfie



Joined: 26 Apr 2010
Posts: 17
Location: Palatine, IL

View user's profile Send private message Visit poster's website

PostPosted: Thu Sep 16, 2010 9:55 pm     Reply with quote

PCM programmer wrote:
Try using the CCS lcd driver for 4x20 lcds:
Quote:
c:\program files\picc\drivers\lcd420.c


This worked. Thank you!

For anyone else encountering this error, this suggestion worked with the test example I posted above, with minor modifications. First I had to change the NOPUT to PUT (use Power Up Timer, otherwise the display didn't initialize properly) and secondly I included the lcd420.c file instead of the flex.c file.

Also, the compiler was complaining (with some cryptic error code) about the switch statement in the lcd_gotoxy function (of lcd420.c) not having a default case. Adding one will make that error go away and allow for a successful build.

Lucas
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