Using a standard LCD display with a PIC microcontroller. - Page 1
Forum section: electronics / general

author: Dukov Ahzrukhal
author_rank: Regular Contributor
timestamp: June 08, 2018, 01:40:35 am
content: Hello everyone, this is my first post hereI've been working on a simple RS232 terminal using a pic microcontroller but im having trouble in a function that prints a message on a standard 16*2 display. The function is relatively simple and is not even essential to my code, everything else works fine just so long as I never call this function. after a whole day of scratching my head I decided to create a separate file with just this function and the other code it needs, sure enough it didn't work at all. the display just shows a bar like it was not initialized at all. Since ive been unable to get this working for so long I though id ask for help hereIts probably just a silly mistake. I'll attach my .ASM file, it is commented and specifies what micro im using as well as how I wired it up.Thanks in advance to all who read this.

author: rstofer
author_rank: Super Contributor
timestamp: June 08, 2018, 02:28:12 am
content: Did you check Google?https://electrosome.com/lcd-pic-mplab-xc8/I don't know that the library works but, if it doesn't, there are MANY other replys to the search for 'lcd driver code for pic 16'

author: JS
author_rank: Frequent Contributor
timestamp: June 08, 2018, 02:33:50 am
content: That might be a connection problem, they kind of do that when that happens.JS

author: Dukov Ahzrukhal
author_rank: Regular Contributor
timestamp: June 08, 2018, 05:31:13 am
content: Thanks for the reply. Yes I did read that and may other documents but if you read my code you'll see that im writing in assembly, not using the HI-TECH C or XC8 compilers. There are two reasons for this: the first is that I was originally using the PIC16f84A microcontroller and this is part of a much larger project so I had to make efficient use of the program memory. The second reason is that I don't want to use any libraries or other peoples code, purely in the interest of learning of course. Perhaps there is something about the PIC architecture or even something specific to the PIC16C65 microcontroller that im not seing? I forgot to mention earlier that although I have the assembler configured for the PIC16C65A im actually using the PIC16C65. Could this be the problem? The only difference that I can see between them is that the 'A' version is electrically erasable rather than UV erasable, and the power on timer configuration bit is inverted in the 'A' version (which is why in my code I have the power on timer set to "off", since i want it to be on). I will attach my entire .ASM file with the other functions in case something in there might give a hint of whats going on.

author: NASK
author_rank: Contributor
timestamp: June 08, 2018, 06:45:26 am
content: I have attach a PDF below which i have written in assembly using 16f887 & 20*4 LCD when i was in University. i think it will be helpful for you. your code is hard to understand you have used tradition assembly methods. ex- BSF STATUS,RP0 ;SWITCH TO BANK 1 , no need this, just write BANKSEL PORTD to select bank of PORTD.

author: Dukov Ahzrukhal
author_rank: Regular Contributor
timestamp: June 08, 2018, 05:03:23 pm
content: I see the problem! Well one of them at least. I was forgeting to set the display RS line before sending the text. Silly me, I'll program another chip and test again.EDIT:Yes that was the problem, I will upload my working code for anyone that wants to see/use it.

author: StillTrying
author_rank: Super Contributor
timestamp: June 08, 2018, 05:51:51 pm
content: I make SHORTDELAY_LCD about 1540us. For the slow "Clear Screen" and "Home" commands usually 1600us - 1700us is recommended.