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

Flex_lcd.c Code changes For 20 x 4 LCD

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



Joined: 03 Mar 2014
Posts: 7
Location: Gun Barrel City, Texas

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

Flex_lcd.c Code changes For 20 x 4 LCD
PostPosted: Wed Mar 19, 2014 3:00 pm     Reply with quote

Does anyone know what changes would need to be made to allow use of a 20 x 4 LCD instead of the 20 x 2?

I have the 20 x 2 running thanks to the great support CCS provided me.

The code indicates the following for the 20 x 2 version;

#define lcd_type 2 // 0=5x7, 1=5x10, 2=2 lines
#define lcd_line_two 0x40 // LCD RAM address for the 2nd line

What do I need to change / add for the 4 line LCD?
_________________
Ed Edmondson
206 Woodwind Street
Gun Barrel City, Texas 75156-3934
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Wed Mar 19, 2014 3:17 pm     Reply with quote

in the code library you can find the Flex 20x4 driver by PCM_Programmer.

G.
_________________
CCS PCM 5.078 & CCS PCH 5.093
dredwinphd1



Joined: 03 Mar 2014
Posts: 7
Location: Gun Barrel City, Texas

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

20 x 4 line LCD Display Code
PostPosted: Sat Mar 22, 2014 3:58 pm     Reply with quote

I downloaded this code from the library. I changed the pin-out to match the hardware and I was able to see were two lines (1 and 3) of 20 black squares when the contrast pot was turned up toward vdd.

The display was an Optrex C51847NFQJ-LW-AAN. These were supposed to be new display units and I had to solder the pins to the connector. With just the backlight connected I have nothing.

The 20x2 works fine on every 2 line display I tested.
_________________
Ed Edmondson
206 Woodwind Street
Gun Barrel City, Texas 75156-3934
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Mar 23, 2014 12:48 am     Reply with quote

Try this one in the CCS Code Library forum. See if it works.
http://www.ccsinfo.com/forum/viewtopic.php?t=38744
The basic configuration of that driver is to use PortD on the PIC:
Code:

// Connections between PIC and LCD:
// PIC pin D0 - lcd pin EN
// PIC pin D1 - lcd pin RS
// PIC pin D2 - lcd pin RW
// PIC pin D3 - not used
// PIC pin D4 - lcd pin DB4
// PIC pin D5 - lcd pin DB5
// PIC pin D6 - lcd pin DB6
// PIC pin D7 - lcd pin DB7

Though, it could be changed.
dredwinphd1



Joined: 03 Mar 2014
Posts: 7
Location: Gun Barrel City, Texas

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

OLED Display
PostPosted: Mon Mar 24, 2014 2:48 pm     Reply with quote

I am trying to get a OLED display to operate correctly. When I use the 20x2 driver I have what appears to be timing problems. I contacted the manufacturer (Newhaven Displays) and received the following information. The display is a NHD0220DZW-AG5.

I am new to this and trying my best to learn enough to fix / modify my own problems but when they start quoting AVR I am totally lost! All I am able to see is that this display (which is supposed to be HD44780 compatible) drop in replacement isn't?

If I can get this to work properly I will go back to attempting the 4 line displays.

" I set this display up with an Arduino Mega to try and replicate this issue and I was seeing what I believe to be the same thing as you are referring to.
Each time I pressed the reset button on the Arduino to reset the processor, I would get random characters about 50-75% of the time.
At the beginning of my code (just after I set all I/O lines used to OUTPUTS and initialize them all to ‘0’s, but before the initialization code for the OLED), I added a few lines that allowed me to successfully reset the processor every time.

Here is the very beginning of my code:

DDRA = 0xFF; //set PORTA (dat bus) as output
PORTA = 0x00; //initialize PORTA to 0x00
DDRC = 0xFF; //set PORTC (control lines) as output
PORTC = 0x00; //initialize PORTC to 0x00
delay(5); //*added line of code to fix reset issue*
toggle(); //*added line of code to fix reset issue*
delay(5); //*added line of code to fix reset issue*
//this is where my initialization occurs
//
//

The toggle function is simply:

void toggle()
{
digitalWrite(E, HIGH);
delay(1);
digitalWrite(E, LOW);
}

It sets the E pin to ‘1’, delays for 1ms, then resets it to ‘0’.

Question Question Rolling Eyes
_________________
Ed Edmondson
206 Woodwind Street
Gun Barrel City, Texas 75156-3934
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Mar 24, 2014 3:28 pm     Reply with quote

Are you asking a question or just notifying us of this ?
You only show up on this thread every 2-3 days for one post.
It's difficult for us to keep up a lot of interest in a thread that
is only worked on for a couple minutes every 2-3 days by the O.P.
temtronic



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

View user's profile Send private message

PostPosted: Mon Mar 24, 2014 5:03 pm     Reply with quote

Without seeing your test program and reading 'random' data... it could easily be an LCD startup issue.
Normally in main() just before you FIRST access the LCD using an 'lcd-init' function, you need to delay about 250-500ms. This is needed to allow the LCD module get 'organized' to it's factory defaults. If you try to access it (read or write) before it's properly initialized 'strange' things can happen.
You should post a small, compilable program that we can test.
Also it might be slower than the ones that flex_lcd.c was written for, so you'll need to read your LCD datasheet to see compare against other LCD modules.

hth
jay
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Mar 24, 2014 5:51 pm     Reply with quote

He has two lcd threads going. We told him about the start-up delay
near the end of the other thread. But he only shows up every 2-3 days
so who knows if he saw it.
http://www.ccsinfo.com/forum/viewtopic.php?t=52092
dredwinphd1



Joined: 03 Mar 2014
Posts: 7
Location: Gun Barrel City, Texas

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

An apology
PostPosted: Tue Mar 25, 2014 3:54 pm     Reply with quote

Please accept my apology for any problems I am seeming to cause with these posts. I suffer from PTSD and have some problems getting my questions and comments across to everyone.

I am an 65 year old Veteran who is just trying to learn C and PIC microcontrollers and I am just trying to understand how everything works together.

This board is the only place I have found which has been gracious enough to assist me in this endeavour.

Again, sorry for the problems I have caused everyone.
_________________
Ed Edmondson
206 Woodwind Street
Gun Barrel City, Texas 75156-3934
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Mar 25, 2014 4:04 pm     Reply with quote

OK, sorry. I withdraw my comment.
dredwinphd1



Joined: 03 Mar 2014
Posts: 7
Location: Gun Barrel City, Texas

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

Thanks!
PostPosted: Wed Mar 26, 2014 10:15 am     Reply with quote

PCM, thank you for accepting my apology and I will try to keep all my questions short and to the point! If I do something wrong please let me know and I will do my best not to repeat the mistake.

What I would like to do is to get my 2 x 20 OLED display to work properly with the dev board I have constructed. When I get this display to work properly I will move on to the 4 x 20 type display. As mentioned the display is the NHD-0220DZW-AG5.

I one of my last posts I mentioned what the Oled manufacturer tech support guys said he tried to get around the problems I was seeing.

What he sent me was written in what appears to be assembly language. Since I have no idea, yet, what to do with this programming capability I decided to learn C and since I have friends at Microchip I have put all my meager resources into Microchip devices.

What I need to know is how and where to add all these additional enables, delays and waits I have been told to add. I have been trying to study the code as it is modified and/or already written to attempt to learn what each line of code does.

So, with your assistance, I just want to get the original 2 x 20 code I already (finally) running with my Oled display.

I am using the ICD-U64 and a homemade cable to program the 18F45K22 in circuit. When I program the pic and the Oled display comes up with information from the test program I get either a piece of the message or just plain garbage. If i manually reset the board with the reset button I get something different on the display from bits and pieces to just trash.

One thing which would be wonderful and helpful is having a brief explanation of what is being provided so I can learn to program and be able to return some assistance back to the forums.

Question: If the code is working properly and the hardware is working properly I should get the same information displayed after each reset. Is this correct?

Question: I think I have finally made the connection between FUNCTIONS and the program. A function is the file with most of the display control information and the test program is what I compile to get the display to work. Is this correct?

Finally, the development board I built works with all LCD and VFD character displays I have tried it with.

Question: Is the reason for the garbage on the Oled display due to a matter of timing? Or will using this type of display require a major re-write of the code which was posted?

Thanks for listening and in advance for helping. I will try to be more responsive to the comments, suggestions, and assistance so I don't leave everyone in the wind.
_________________
Ed Edmondson
206 Woodwind Street
Gun Barrel City, Texas 75156-3934
newguy



Joined: 24 Jun 2004
Posts: 1911

View user's profile Send private message

Re: OLED Display
PostPosted: Wed Mar 26, 2014 11:31 am     Reply with quote

dredwinphd1 wrote:

" I set this display up with an Arduino Mega to try and replicate this issue and I was seeing what I believe to be the same thing as you are referring to.
Each time I pressed the reset button on the Arduino to reset the processor, I would get random characters about 50-75% of the time.
At the beginning of my code (just after I set all I/O lines used to OUTPUTS and initialize them all to ‘0’s, but before the initialization code for the OLED), I added a few lines that allowed me to successfully reset the processor every time.

Here is the very beginning of my code:

DDRA = 0xFF; //set PORTA (dat bus) as output
PORTA = 0x00; //initialize PORTA to 0x00
DDRC = 0xFF; //set PORTC (control lines) as output
PORTC = 0x00; //initialize PORTC to 0x00
delay(5); //*added line of code to fix reset issue*
toggle(); //*added line of code to fix reset issue*
delay(5); //*added line of code to fix reset issue*
//this is where my initialization occurs
//
//

The toggle function is simply:

void toggle()
{
digitalWrite(E, HIGH);
delay(1);
digitalWrite(E, LOW);
}

It sets the E pin to ‘1’, delays for 1ms, then resets it to ‘0’.

Question Question Rolling Eyes


All this code does is: a) set all data and control lines that run from the display to the processor as output low (0), and b) waits 5ms (I think it's milliseconds) then sets the Enable line high for a ms, then back low and waits for another 5ms before proceeding with the "normal" initialization procedure.

Equivalent pic code would be:
Code:
output_a(0x00);
output_b(0x00); // NOTE: this is for example only - if you tell us how
// your LCD is actually connected to your PIC we can give you precise
// code
delay_ms(5);
output_high(LCD_ENABLE); // again, this is for example - give us the
// actual connections and we can give you precise code
delay_ms(1);
output_low(LCD_ENABLE);
delay_ms(5);

// and the rest of the lcd_init() function goes here
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