Click here to Skip to main content
14,878,458 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.
 
AnswerRe: So my little arduino clone is fun but I was wondering something Pin
Robotek232-Oct-20 11:10
MemberRobotek232-Oct-20 11:10 
GeneralRe: So my little arduino clone is fun but I was wondering something Pin
honey the codewitch2-Oct-20 11:34
mvahoney the codewitch2-Oct-20 11:34 
AnswerRe: So my little arduino clone is fun but I was wondering something Pin
_WinBase_4-Oct-20 22:37
Member_WinBase_4-Oct-20 22:37 
AnswerRe: So my little arduino clone is fun but I was wondering something Pin
Member 148590765-Oct-20 2:54
MemberMember 148590765-Oct-20 2:54 
AnswerRe: So my little arduino clone is fun but I was wondering something Pin
Matt McGuire5-Oct-20 5:07
professionalMatt McGuire5-Oct-20 5:07 
AnswerRe: So my little arduino clone is fun but I was wondering something Pin
Peter Shaw6-Oct-20 9:41
professionalPeter Shaw6-Oct-20 9:41 
AnswerRe: So my little arduino clone is fun but I was wondering something Pin
Chad3F6-Oct-20 13:08
MemberChad3F6-Oct-20 13:08 
AnswerRe: So my little arduino clone is fun but I was wondering something Pin
Luc Pattyn9-Nov-20 6:08
sitebuilderLuc Pattyn9-Nov-20 6:08 
Hi honey the LCDwitch Big Grin | :-D

any progress?

I just happen to be working on a PIC+LCD project; my LCD is working, after some struggle, and here are my recent observations:

1. pin 3 is most relevant; a lot of documentation is misleading, this pin is not "LCD power" or some similar, suggesting 5V would be reasonable. It is a contrast control input, the official approach is using a little potmeter, say 10K, between GND and 5V, and turning it very close to ground, NOT close to 5V. A good alternative seems to be just a diode from pin 3 to GND; that is what I'm using now.

2. The LCD needs a few commands to become alive; one of them is the "function set" command, holding a "display ON" bit; so you need some correct toggling of E, RS, and 4 or 8 data lines.

3. The pulses required on E are a bit special: the leading edge must fall after RS and RW have settled, and the falling edge after the data is presented. This is unlike most other micro-electronic peripherals I have ever seen (normally one edge is used to sample everything, and the other edge doesn't care much).

4. The data bus is either 8 or 4 bits wide; in order to get it in 4-bit mode RELIABLY you need a specific sequence of commands. Without proper initialization the display remains blank, as if no power were applied. And the display may remain confused as long as it is getting power (or a really correct command sequence).What Hitachi HD44780 LCD controller - Wikipedia[^] says is correct and effective, it is better then what a lot of data sheets provide! Some manufacturers that used to provide bad info are now refraining from providing initialization info at all. The mistakes can be blatant or subtle, I also found a github code sample that was wrong... This is what I'm using right now (using a 4-bit interface):

CALL    WAIT40msec      ; important!
BCF     LCD_RS_PP       ; set RS low
MOVLW   0x03            ; 8-bit interface
CALL    display_write_nibble
CALL    WAIT1msec
MOVLW   0x03            ; 8-bit interface
CALL    display_write_nibble
CALL    WAIT1msec
MOVLW   0x03            ; 8-bit interface
CALL    display_write_nibble
CALL    WAIT1msec
MOVLW   0x02            ; 4-bit interface
CALL    display_write_nibble
CALL    WAIT60usec
MOVLW   0x28            ; 4-bit interface, single line, 5*8 font
CALL    display_send_fast_command

MOVLW   0x08            ; display off
CALL    display_send_fast_command

MOVLW   0x01            ; clear
CALL    display_send_fast_command
CALL    WAIT2msec

MOVLW   0x0C            ; display on, no cursor, no blink
CALL    display_send_fast_command

MOVLW   0x06            ; mode: increment, no shift
CALL    display_send_fast_command

The display_write_nibble subroutine sets E high, outputs a nibble, and clears E, all without extra delays.
The display_send_fast_command subroutine calls display_write_nibble twice and then waits 60µsec.

I did not compare that to whatever is present in other libraries such as Arduino's. With all I saw on internet, I'm inclined to only trust my own code...

5. LCD commands take some time to execute; a TYPICAL time is listed in the datasheet.

I decided against reading the busy flag (which isn't working anyway during the fist half of the initialization), instead I simply provide ample time for each command to be executed. So my R/W line is at GND permanently; this also eliminates the chance that the driving code is stuck in a wait-for-display-ready loop, keeping the display in an uninitialized state.

So I used fixed timing. It is wise to provide at least double the datasheet values, because (1) the internal microcontroller might run at a different frequency, and (2) HD44780 clones may hold different firmware and hence different timing.

6. Final remark: backlight pins 15 and 16 may or may not be swapped, and may or may not have some resistance in them (some 12 ohm). It all depends on the specifics of the PCB. Anyhow, the backlight is not essential, the display can be seen to be functional without it.

Smile | :)
Luc Pattyn [My Articles]
If you can't find it on YouTube try TikTok...

GeneralRe: So my little arduino clone is fun but I was wondering something Pin
honey the codewitch9-Nov-20 6:11
mvahoney the codewitch9-Nov-20 6:11 
GeneralHas Win 10 Task Mangler changed... Pin
glennPattonContracting22-Oct-20 4:41
professionalglennPattonContracting22-Oct-20 4:41 
GeneralRe: Has Win 10 Task Mangler changed... Pin
Gerry Schmitz2-Oct-20 4:55
mveGerry Schmitz2-Oct-20 4:55 
GeneralRe: Has Win 10 Task Mangler changed... Pin
OriginalGriff2-Oct-20 5:43
mveOriginalGriff2-Oct-20 5:43 
GeneralRe: Has Win 10 Task Mangler changed... Pin
glennPattonContracting22-Oct-20 6:19
professionalglennPattonContracting22-Oct-20 6:19 
GeneralThought of the Day Pin
OriginalGriff2-Oct-20 4:36
mveOriginalGriff2-Oct-20 4:36 
GeneralRe: Thought of the Day Pin
Daniel Pfeffer2-Oct-20 5:00
professionalDaniel Pfeffer2-Oct-20 5:00 
GeneralRe: Thought of the Day Pin
megaadam2-Oct-20 5:06
professionalmegaadam2-Oct-20 5:06 
GeneralRe: Thought of the Day Pin
rnbergren2-Oct-20 5:43
Memberrnbergren2-Oct-20 5:43 
GeneralRe: Thought of the Day Pin
W Balboos, GHB2-Oct-20 6:21
mveW Balboos, GHB2-Oct-20 6:21 
GeneralChange signature Pin
pkfox2-Oct-20 3:37
professionalpkfox2-Oct-20 3:37 
AnswerRe: Change signature Pin
ZurdoDev2-Oct-20 3:40
professionalZurdoDev2-Oct-20 3:40 
GeneralRe: Change signature Pin
pkfox2-Oct-20 3:48
professionalpkfox2-Oct-20 3:48 
GeneralRe: Change signature Pin
  Forogar  2-Oct-20 3:40
professional  Forogar  2-Oct-20 3:40 
GeneralRe: Change signature Pin
pkfox2-Oct-20 3:49
professionalpkfox2-Oct-20 3:49 
GeneralRe: Change signature Pin
Gerry Schmitz2-Oct-20 4:56
mveGerry Schmitz2-Oct-20 4:56 
GeneralCovid versions - NOT POLITICAL (I promise) Pin
ZurdoDev2-Oct-20 2:46
professionalZurdoDev2-Oct-20 2:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.