rishiraj
Junior Member level 1
- Joined
- Dec 25, 2012
- Messages
- 15
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,393
My LCD interfacing code isn't working fine and it is showing garbage value. Here is the code
I am using a PIC18F26K22 microcontroller which has a bootloader.
PS: I did check other topics in this forum relating to this topic but none helped.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <p18f26k22.h>
#include <delays.h>
#include <string.h>
#include "oscillator.h"
#define RS LATBbits.LATB0
#define RW LATBbits.LATB1
#define E LATBbits.LATB2
#define lcd PORTC
void data(char *value1);
void cmd(unsigned short);
void main()
{
set_freq(f8Mhz); // 8Mhz frequency Set.
ANSELB=0;
TRISB=0;
ANSELC=0;
TRISC=0;
Delay100TCYx(100); //5ms delay
cmd(0x38);
cmd(0x0C);
cmd(0x01);
cmd(0x06);
cmd(0x80);
data("Hello");
while(1);
}
void cmd(unsigned short value)
{
lcd = value;
RS=0;
RW=0;
E=1;
Delay10TCYx(2); //10us delay
E=0;
Delay100TCYx(20); //1ms delay
}
void data(char *value1)
{
unsigned short i;
for(i=0;i<strlen(value1);i++)
{
lcd = value1[i];
RS=1;
RW=0;
E=1;
Delay10TCYx(2); //10us delay
E=0;
Delay100TCYx(20); //1ms delay
}
}
I am using a PIC18F26K22 microcontroller which has a bootloader.
PS: I did check other topics in this forum relating to this topic but none helped.