Issues interfacing 16x2 LCD with PIC18F4550

howlingmadpanda

Jan 26, 2016
1
Joined
Jan 26, 2016
Messages
1
For some time I have been working with some more basic electronics projects and have been familiar with electronic theory and the physics behind it. I have now begun working on a geiger counter project, which has gone well for the most part. All of my actual electronics (creating GM tube voltage, detection or ionising radiation) have worked fine. I have only recently, however, begun to work with interfacing an LCD with a PIC18F4550. My intended use of this is to display CPM digitally -- x number of counts in a certain amount of time, display to LCD. I am familiar with PIC Timers, so I didn't think there would be an issue with that code. My issue here is that I attempted to write a "hello world" program on my 16x2 LCD, of course partially skidding the code from online as I had never used an LCD with a PIC before. I know that my PIC is hooked up to the LCD correctly and I am getting current on the pins, implying that a signal is being sent. Could anybody help?

Code:

<code>     

#if defined(__XC)
    #include <xc.h>         
#elif defined(HI_TECH_C)
    #include <htc.h>      
#endif

#include <stdint.h>        /
#include <stdbool.h>      
#include <xc.h>
#include "system.h"       
#include "user.h"        

  
  #include <htc.h>
#define _XTAL_FREQ 1000000
#define rs RA0
#define rw RA1
#define en RA2
//LCD Data pins
#define lcdport PORTB

void lcd_init();
void lcdcmd(unsigned char);
void lcddata(unsigned char);
unsigned char data[20]="hello world";
unsigned int i = 0;

void main(void)
{
TRISA=0;                             // Configure Port A as output port
//PORTA=0;
TRISB=0;                             // Configure Port B as output port
//PORTB=0;
lcd_init();                              // LCD initialization
while(data != '\0')
{
lcddata(data);     // Call lcddata function to send characters
// one by one from ?data? array
i++;
__delay_ms(300);
}
}

void lcd_init()
{
lcdcmd(0x38);
lcdcmd(0x0C);
lcdcmd(0x01);
lcdcmd(0x06);
lcdcmd(0x80);

}

void lcdcmd(unsigned char cmdout)
{
lcdport=cmdout;
rs=0;
rw=0;
en=1;
__delay_ms(10);
en=0;
}

void lcddata(unsigned char dataout)
{
lcdport=dataout;
rs=1;
rw=0;
en=1;
__delay_ms(10);
en=0;
}

 

 

 

</code>

 
Top