• AVR Freaks

AnsweredHot!LCD interfacing with pic16f18426 microcontroller

Author
ceejay
New Member
  • Total Posts : 30
  • Reward points : 0
  • Joined: 2018/10/25 23:12:35
  • Location: 0
  • Status: offline
2018/11/07 16:36:45 (permalink)
0

LCD interfacing with pic16f18426 microcontroller

Hi, I have read all the threads and tutorials in interfacing LCD to pic microcontroller. I changed the configuration in such a way that it fits my microcontroller. But when I uploaded the code, it shows only the 1st row is on, however it doesn't show any character, just all the dots of each character. Does it has something to do with the clock or the xtal frequency? I am using the internal clock of the pic microcontroller. Thank you very much in advance.
post edited by ceejay - 2018/11/07 19:00:19
#1
MBedder
Circuit breaker
  • Total Posts : 6794
  • Reward points : 0
  • Joined: 2008/05/30 11:24:01
  • Location: Zelenograd, Russia
  • Status: offline
Re: LCD interfacing with pic16f1426 microcontroller 2018/11/07 16:48:30 (permalink)
0
The problem is in line #47 of your code.
#2
jack@kksound
code tags!
  • Total Posts : 3205
  • Reward points : 0
  • Joined: 2014/05/14 10:03:19
  • Location: 0
  • Status: offline
Re: LCD interfacing with pic16f1426 microcontroller 2018/11/07 16:57:48 (permalink)
0
The single line of block characters is usually a sign the LCD controller was not initialized correctly. Increase you delays between commands. But just a guess since we have seen no code...most likely is in line #47..
#3
ceejay
New Member
  • Total Posts : 30
  • Reward points : 0
  • Joined: 2018/10/25 23:12:35
  • Location: 0
  • Status: offline
Re: LCD interfacing with pic16f1426 microcontroller 2018/11/07 17:19:17 (permalink)
0
Hi. Thank you for your answer. Sorry for I didn't upload the code earlier. But now, you can see the code. The header file (lcd.txt) and the main file (LCD_test.c) 
#4
Aussie Susan
Super Member
  • Total Posts : 3618
  • Reward points : 0
  • Joined: 2008/08/18 22:20:40
  • Location: Melbourne, Australia
  • Status: offline
Re: LCD interfacing with pic16f1426 microcontroller 2018/11/07 18:20:01 (permalink)
0
Also check the contrast - if it is too high then all you will see are the dots.
Power up the LCD, increase the contract until the dots are visible and then back it off a little - the dots will disappear but when there is a character to display it will be visible.
Susan
#5
qhb
Superb Member
  • Total Posts : 9999
  • Reward points : 0
  • Joined: 2016/06/05 14:55:32
  • Location: One step ahead...
  • Status: offline
Re: LCD interfacing with pic16f1426 microcontroller 2018/11/07 18:58:54 (permalink) ☼ Best Answerby ceejay 2018/11/07 19:06:48
0
According to search on the Microchip website, their is no PIC device named "PIC16F1426".
Did you mean PIC16F1826?
 
Your main problem is that you have left all the PORTC pins in analog mode, AND you have used the PORTC bits rather than the LATC bits to control the pins.
These two mistakes together guarantee that the pins won't be controlled correctly.
 
Add "ANSELC=0;" to your startup code, and change
#define RS RC5
#define EN RC4
#define D4 RC3
#define D5 RC2
#define D6 RC1
#define D7 RC0

to
#define RS LATC5
#define EN LATC4
#define D4 LATC3
#define D5 LATC2
#define D6 LATC1
#define D7 LATC0

 
If you are interested why your version doesn't work, just search this forum for "RMW" or "Read-Modify-Write problem".
 

Nearly there...
#6
qhb
Superb Member
  • Total Posts : 9999
  • Reward points : 0
  • Joined: 2016/06/05 14:55:32
  • Location: One step ahead...
  • Status: offline
Re: LCD interfacing with pic16f1426 microcontroller 2018/11/07 19:13:48 (permalink)
0
I just received this via PM.
ceejay
Hi sir/ma'am! 
Thank you for your response. I apologize for the mistake of my thread. It was supposed to be PIC16F18426. Where should I put the command "ANSELC=0;"? and what does it mean?

ceejay, please do NOT use PMs for questions, keep everything in public. That's how forums work.
If you look in the datasheet for your PIC
http://ww1.microchip.com/downloads/en/DeviceDoc/Microchip-8-bit-PIC-MCU-PIC16(L)F18426_46-Datasheet-40001985A.pdf
start reading from "14.2 I/O Ports Description" on page#191 to see how the GPIO ports work, and what the TRIS register does.
 

Nearly there...
#7
qhb
Superb Member
  • Total Posts : 9999
  • Reward points : 0
  • Joined: 2016/06/05 14:55:32
  • Location: One step ahead...
  • Status: offline
Re: LCD interfacing with pic16f1426 microcontroller 2018/11/07 19:15:56 (permalink)
0
Your "startup code" is everything between the start of your main() function, and the start of the outermost while() loop. i.e. here:
int main()
{
  unsigned int a;
  TRISC = 0x00;
  Lcd_Init();
  while(1)

You should clear ANSELC right where you clear TRISC.
 
 

Nearly there...
#8
ceejay
New Member
  • Total Posts : 30
  • Reward points : 0
  • Joined: 2018/10/25 23:12:35
  • Location: 0
  • Status: offline
Re: LCD interfacing with pic16f1426 microcontroller 2018/11/19 21:02:43 (permalink)
0
Thank you very much!
#9
Jump to:
© 2019 APG vNext Commercial Version 4.5